Skip to content

Commit

Permalink
add test files
Browse files Browse the repository at this point in the history
  • Loading branch information
artoy committed Nov 30, 2023
1 parent 26acaa9 commit b0b5055
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/test/list/reverse2-debug.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
_reverse(l, l_next) {
match l_next with
Nil -> {
// alias(*(l.Cons.2) = l_next);
return l
}
| Cons(h, t) -> {
let t_deref = *t in {
t := l;
alias(l_next.Cons.2 = t);
let reversed = _reverse(l_next, t_deref) in
reversed
}
}
}

reverse(l) {
match l with
Nil -> l
| Cons(h, r) -> {
let reversed = _reverse(Nil, l) in
reversed
}
}

{
let n = mkref Nil in
let m = mkref Cons(1, n) in
let l = Cons(2, m) in
let rev_l = reverse(l) in
()
}
2 changes: 1 addition & 1 deletion src/test/list/reverse2.imp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mklist(n) {
_reverse(l, l_next) {
match l_next with
Nil -> {
alias(*(l.Cons.2) = l_next);
// alias(*(l.Cons.2) = l_next);
return l
}
| Cons(h, t) -> {
Expand Down

0 comments on commit b0b5055

Please sign in to comment.