blob: 07b4deb58e497991b2d5873f3d4b88b6db8ad607 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
;; Test files can define multiple modules. Test that implementations treat
;; each module independently from the other.
(module
(func (export "foo") (result i32) (i32.const 0))
)
(assert_return (invoke "foo") (i32.const 0))
;; Another module, same function name, different contents.
(module
(func (export "foo") (result i32) (i32.const 1))
)
(assert_return (invoke "foo") (i32.const 1))
(module
;; Test that we can use the empty string as a symbol.
(func (export "") (result f32) (f32.const 0x1.91p+2))
;; Test that we can use names beginning with a digit.
(func (export "0") (result f32) (f32.const 0x1.97p+2))
;; Test that we can use names beginning with an underscore.
(func (export "_") (result f32) (f32.const 0x1.98p+2))
;; Test that we can use names beginning with a dollar sign.
(func (export "$") (result f32) (f32.const 0x1.99p+2))
;; Test that we can use names beginning with an at sign.
(func (export "@") (result f32) (f32.const 0x2.00p+2))
;; Test that we can use non-alphanumeric names.
(func (export "~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./ ") (result f32) (f32.const 0x1.96p+2))
;; Test that we can use names that have special meaning in JS.
(func (export "NaN") (result f32) (f32.const 0x2.01p+2))
(func (export "Infinity") (result f32) (f32.const 0x2.02p+2))
(func (export "if") (result f32) (f32.const 0x2.03p+2))
;; Test that we can use common libc names without conflict.
(func (export "malloc") (result f32) (f32.const 0x1.92p+2))
;; Test that we can use some libc hidden names without conflict.
(func (export "_malloc") (result f32) (f32.const 0x1.93p+2))
(func (export "__malloc") (result f32) (f32.const 0x1.94p+2))
)
(assert_return (invoke "") (f32.const 0x1.91p+2))
(assert_return (invoke "malloc") (f32.const 0x1.92p+2))
(assert_return (invoke "_malloc") (f32.const 0x1.93p+2))
(assert_return (invoke "__malloc") (f32.const 0x1.94p+2))
(assert_return (invoke "~!@#$%^&*()_+`-={}|[]\\:\";'<>?,./ ") (f32.const 0x1.96p+2))
(assert_return (invoke "0") (f32.const 0x1.97p+2))
(assert_return (invoke "_") (f32.const 0x1.98p+2))
(assert_return (invoke "$") (f32.const 0x1.99p+2))
(assert_return (invoke "@") (f32.const 0x2.00p+2))
(assert_return (invoke "NaN") (f32.const 0x2.01p+2))
(assert_return (invoke "Infinity") (f32.const 0x2.02p+2))
(assert_return (invoke "if") (f32.const 0x2.03p+2))
(module
;; Test that we can use indices instead of names to reference imports,
;; exports, functions and parameters.
(import "spectest" "print" (func (param i32)))
(func (import "spectest" "print") (param i32))
(func (param i32) (param i32)
(call 0 (get_local 0))
(call 1 (get_local 1))
)
(export "print32" (func 2))
)
(invoke "print32" (i32.const 42) (i32.const 123))
|