Skip to content

Commit ffcd335

Browse files
some test cases for try-catch
1 parent 9eaad3d commit ffcd335

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;; kept in delimited continuation example
2+
(module
3+
;; output: 1, 2, 6, 2, 3, 4, 4, 5
4+
(type (;0;) (func (param i32)))
5+
(type (;1;) (func))
6+
(import "console" "log" (func (;0;) (type 0)))
7+
(func (;1;) (type 1)
8+
(local i32)
9+
try
10+
i32.const 1
11+
call 0
12+
block
13+
block
14+
i32.const 42
15+
;; [42]
16+
throw
17+
i32.const 6
18+
call 0
19+
i32.const 42
20+
;; [42]
21+
throw
22+
end
23+
end
24+
i32.const 3
25+
call 0
26+
catch
27+
;; [42, resume]
28+
i32.const 2
29+
call 0
30+
drop
31+
resume0
32+
i32.const 4
33+
call 0
34+
end
35+
i32.const 5
36+
call 0
37+
)
38+
(start 1))
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
;; pushed to meta continuation example
2+
(module
3+
;; output: 1, 2, 6, 2, 3, 4, 5
4+
(type (;0;) (func (param i32)))
5+
(type (;1;) (func))
6+
(import "console" "log" (func (;0;) (type 0)))
7+
(func (;1;) (type 1)
8+
(local i32)
9+
try
10+
i32.const 1
11+
call 0
12+
block
13+
block
14+
i32.const 42
15+
;; [42]
16+
throw
17+
end
18+
i32.const 6
19+
call 0
20+
i32.const 42
21+
;; [42]
22+
throw
23+
end
24+
i32.const 3
25+
call 0
26+
catch
27+
;; [42, resume]
28+
i32.const 2
29+
call 0
30+
drop
31+
resume0
32+
i32.const 4 ;; |---> adk
33+
call 0 ;; |
34+
end
35+
i32.const 5
36+
call 0
37+
)
38+
(start 1))
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
;; ignored example
2+
(module
3+
;; output: 1, 2, 3, 5
4+
;; 4 is not printed, because the delimited continuation is dropped by break instruction
5+
(type (;0;) (func (param i32)))
6+
(type (;1;) (func))
7+
(import "console" "log" (func (;0;) (type 0)))
8+
(func (;1;) (type 1)
9+
(local i32)
10+
try
11+
i32.const 1
12+
call 0
13+
block
14+
block
15+
i32.const 42
16+
;; [42]
17+
throw
18+
br 0
19+
end
20+
end
21+
i32.const 3
22+
call 0
23+
catch
24+
;; [42, resume]
25+
i32.const 2
26+
call 0
27+
drop
28+
resume0
29+
i32.const 4
30+
call 0
31+
end
32+
i32.const 5
33+
call 0
34+
)
35+
(start 1))

src/test/scala/genwasym/TestFx.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,16 @@ class TestFx extends FunSuite {
144144
}
145145
*/
146146

147+
test("try-catch-throw-twice") {
148+
testFileOutput("./benchmarks/wasm/trycatch/throw_twice.wat", List(1, 2, 6, 2, 3, 4, 4, 5))
149+
}
150+
151+
test("try-catch-throw-twice2") {
152+
testFileOutput("./benchmarks/wasm/trycatch/throw_twice2.wat", List(1, 2, 6, 2, 3, 4, 4, 5))
153+
}
154+
155+
test("try-catch-br3") {
156+
testFileOutput("./benchmarks/wasm/trycatch/try_catch_br3.wat", List(1, 2, 3, 5))
157+
}
158+
147159
}

0 commit comments

Comments
 (0)