summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/spec/names.wast
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/wasm/spec/names.wast
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/wasm/spec/names.wast')
-rw-r--r--js/src/jit-test/tests/wasm/spec/names.wast76
1 files changed, 76 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/spec/names.wast b/js/src/jit-test/tests/wasm/spec/names.wast
new file mode 100644
index 000000000..07b4deb58
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/spec/names.wast
@@ -0,0 +1,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))