diff --git a/test/core/binary.wast b/test/core/binary.wast index c0e3f41586..c16a2aa11a 100644 --- a/test/core/binary.wast +++ b/test/core/binary.wast @@ -45,12 +45,120 @@ (assert_malformed (module binary "\00asm\00\00\00\01") "unknown binary version") ;; Invalid section id. -(assert_malformed (module binary "\00asm" "\01\00\00\00" "\0c\00") "malformed section id") +(assert_malformed (module binary "\00asm" "\01\00\00\00" "\0d\00") "malformed section id") (assert_malformed (module binary "\00asm" "\01\00\00\00" "\7f\00") "malformed section id") (assert_malformed (module binary "\00asm" "\01\00\00\00" "\80\00\01\00") "malformed section id") (assert_malformed (module binary "\00asm" "\01\00\00\00" "\81\00\01\00") "malformed section id") (assert_malformed (module binary "\00asm" "\01\00\00\00" "\ff\00\01\00") "malformed section id") +;; Unsigned LEB128 can have non-minimal length +(module binary + "\00asm" "\01\00\00\00" + "\05\04\01" ;; Memory section with 1 entry + "\00\82\00" ;; no max, minimum 2 +) +(module binary + "\00asm" "\01\00\00\00" + "\05\07\01" ;; Memory section with 1 entry + "\00\82\80\80\80\00" ;; no max, minimum 2 +) + +;; Signed LEB128 can have non-minimal length +(module binary + "\00asm" "\01\00\00\00" + "\06\07\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\00" ;; i32.const 0 + "\0b" ;; end +) +(module binary + "\00asm" "\01\00\00\00" + "\06\07\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\7f" ;; i32.const -1 + "\0b" ;; end +) +(module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\00" ;; i32.const 0 + "\0b" ;; end +) +(module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\7f" ;; i32.const -1 + "\0b" ;; end +) + +(module binary + "\00asm" "\01\00\00\00" + "\06\07\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\00" ;; i64.const 0 with unused bits set + "\0b" ;; end +) +(module binary + "\00asm" "\01\00\00\00" + "\06\07\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\7f" ;; i64.const -1 with unused bits unset + "\0b" ;; end +) +(module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with unused bits set + "\0b" ;; end +) +(module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with unused bits unset + "\0b" ;; end +) + +(module binary + "\00asm" "\01\00\00\00" + "\05\03\01" ;; Memory section with 1 entry + "\00\00" ;; no max, minimum 0 + "\0b\06\01" ;; Data section with 1 entry + "\00" ;; Memory index 0 + "\41\00\0b\00" ;; (i32.const 0) with contents "" +) + +(module binary + "\00asm" "\01\00\00\00" + "\04\04\01" ;; Table section with 1 entry + "\70\00\00" ;; no max, minimum 0, funcref + "\09\06\01" ;; Element section with 1 entry + "\00" ;; Table index 0 + "\41\00\0b\00" ;; (i32.const 0) with no elements +) + +;; Data segment memory index can have non-minimal length +(module binary + "\00asm" "\01\00\00\00" + "\05\03\01" ;; Memory section with 1 entry + "\00\00" ;; no max, minimum 0 + "\0b\07\01" ;; Data section with 1 entry + "\80\00" ;; Memory index 0, encoded with 2 bytes + "\41\00\0b\00" ;; (i32.const 0) with contents "" +) + +;; Element segment table index can have non-minimal length +(module binary + "\00asm" "\01\00\00\00" + "\04\04\01" ;; Table section with 1 entry + "\70\00\00" ;; no max, minimum 0, funcref + "\09\09\01" ;; Element section with 1 entry + "\02\80\00" ;; Table index 0, encoded with 2 bytes + "\41\00\0b\00\00" ;; (i32.const 0) with no elements +) ;; Type section with signed LEB128 encoded type (assert_malformed @@ -159,6 +267,584 @@ "zero flag expected" ) +;; Unsigned LEB128 must not be overlong +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\05\08\01" ;; Memory section with 1 entry + "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many + ) + "integer representation too long" +) + +;; Signed LEB128 must not be overlong +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0b\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0b\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) + +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\10\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\10\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) + +;; Unsigned LEB128s zero-extend +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\05\07\01" ;; Memory section with 1 entry + "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\05\07\01" ;; Memory section with 1 entry + "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set + ) + "integer too large" +) + +;; Signed LEB128s sign-extend +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset + "\0b" ;; end + ) + "integer too large" +) + +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset + "\0b" ;; end + ) + "integer too large" +) + +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset + "\0b" ;; end + ) + "integer too large" +) + + +;; Unsigned LEB128 must not be overlong +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\05\08\01" ;; Memory section with 1 entry + "\00\82\80\80\80\80\00" ;; no max, minimum 2 with one byte too many + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\11\01" ;; Code section + ;; function 0 + "\0f\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\28" ;; i32.load + "\02" ;; alignment 2 + "\82\80\80\80\80\00" ;; offset 2 with one byte too many + "\1a" ;; drop + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\11\01" ;; Code section + ;; function 0 + "\0f\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\28" ;; i32.load + "\82\80\80\80\80\00" ;; alignment 2 with one byte too many + "\00" ;; offset 0 + "\1a" ;; drop + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\12\01" ;; Code section + ;; function 0 + "\10\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\41\03" ;; i32.const 3 + "\36" ;; i32.store + "\82\80\80\80\80\00" ;; alignment 2 with one byte too many + "\03" ;; offset 3 + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\12\01" ;; Code section + ;; function 0 + "\10\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\41\03" ;; i32.const 3 + "\36" ;; i32.store + "\02" ;; alignment 2 + "\82\80\80\80\80\00" ;; offset 2 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) + +;; Signed LEB128 must not be overlong +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0b\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\80\00" ;; i32.const 0 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0b\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\ff\7f" ;; i32.const -1 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) + +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\10\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\80\00" ;; i64.const 0 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\10\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\ff\7f" ;; i64.const -1 with one byte too many + "\0b" ;; end + ) + "integer representation too long" +) + +;; Unsigned LEB128s zero-extend +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\05\07\01" ;; Memory section with 1 entry + "\00\82\80\80\80\70" ;; no max, minimum 2 with unused bits set + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\05\07\01" ;; Memory section with 1 entry + "\00\82\80\80\80\40" ;; no max, minimum 2 with some unused bits set + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\10\01" ;; Code section + ;; function 0 + "\0e\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\28" ;; i32.load + "\02" ;; alignment 2 + "\82\80\80\80\10" ;; offset 2 with unused bits set + "\1a" ;; drop + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\10\01" ;; Code section + ;; function 0 + "\0e\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\28" ;; i32.load + "\02" ;; alignment 2 + "\82\80\80\80\40" ;; offset 2 with some unused bits set + "\1a" ;; drop + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\10\01" ;; Code section + "\0e\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\28" ;; i32.load + "\82\80\80\80\10" ;; alignment 2 with unused bits set + "\00" ;; offset 0 + "\1a" ;; drop + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\10\01" ;; Code section + ;; function 0 + "\0e\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\28" ;; i32.load + "\82\80\80\80\40" ;; alignment 2 with some unused bits set + "\00" ;; offset 0 + "\1a" ;; drop + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\11\01" ;; Code section + ;; function 0 + "\0f\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\41\03" ;; i32.const 3 + "\36" ;; i32.store + "\82\80\80\80\10" ;; alignment 2 with unused bits set + "\03" ;; offset 3 + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\11\01" ;; Code section + ;; function 0 + "\0f\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\41\03" ;; i32.const 3 + "\36" ;; i32.store + "\82\80\80\80\40" ;; alignment 2 with some unused bits set + "\03" ;; offset 3 + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\11\01" ;; Code section + ;; function 0 + "\0f\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\41\03" ;; i32.const 3 + "\36" ;; i32.store + "\03" ;; alignment 2 + "\82\80\80\80\10" ;; offset 2 with unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\01\04\01\60\00\00" ;; Type section + "\03\02\01\00" ;; Function section + "\05\03\01\00\01" ;; Memory section + "\0a\11\01" ;; Code section + + ;; function 0 + "\0f\01\01" ;; local type count + "\7f" ;; i32 + "\41\00" ;; i32.const 0 + "\41\03" ;; i32.const 3 + "\36" ;; i32.store + "\02" ;; alignment 2 + "\82\80\80\80\40" ;; offset 2 with some unused bits set + "\0b" ;; end + ) + "integer too large" +) + +;; Signed LEB128s sign-extend +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\70" ;; i32.const 0 with unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\0f" ;; i32.const -1 with unused bits unset + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\80\80\80\80\1f" ;; i32.const 0 with some unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0a\01" ;; Global section with 1 entry + "\7f\00" ;; i32, immutable + "\41\ff\ff\ff\ff\4f" ;; i32.const -1 with some unused bits unset + "\0b" ;; end + ) + "integer too large" +) + +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\7e" ;; i64.const 0 with unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\01" ;; i64.const -1 with unused bits unset + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\80\80\80\80\80\80\80\80\80\02" ;; i64.const 0 with some unused bits set + "\0b" ;; end + ) + "integer too large" +) +(assert_malformed + (module binary + "\00asm" "\01\00\00\00" + "\06\0f\01" ;; Global section with 1 entry + "\7e\00" ;; i64, immutable + "\42\ff\ff\ff\ff\ff\ff\ff\ff\ff\41" ;; i64.const -1 with some unused bits unset + "\0b" ;; end + ) + "integer too large" +) + ;; memory.grow reserved byte equal to zero. (assert_malformed (module binary @@ -176,7 +862,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) ;; memory.grow reserved byte should not be a "long" LEB128 zero. @@ -196,7 +882,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) ;; Same as above for 3, 4, and 5-byte zero encodings. @@ -216,7 +902,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) (assert_malformed @@ -235,7 +921,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) (assert_malformed @@ -254,7 +940,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) ;; memory.size reserved byte equal to zero. @@ -273,7 +959,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) ;; memory.size reserved byte should not be a "long" LEB128 zero. @@ -292,7 +978,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) ;; Same as above for 3, 4, and 5-byte zero encodings. @@ -311,7 +997,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) (assert_malformed @@ -329,7 +1015,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) (assert_malformed @@ -347,7 +1033,7 @@ "\1a" ;; drop "\0b" ;; end ) - "zero flag expected" + "zero byte expected" ) ;; Local number is unsigned 32 bit diff --git a/test/core/data.wast b/test/core/data.wast index e840a94674..f7d1f09bca 100644 --- a/test/core/data.wast +++ b/test/core/data.wast @@ -8,14 +8,26 @@ (data (i32.const 1) "a" "" "bcd") (data (offset (i32.const 0))) (data (offset (i32.const 0)) "" "a" "bc" "") - (data 0 (i32.const 0)) - (data 0x0 (i32.const 1) "a" "" "bcd") - (data 0x000 (offset (i32.const 0))) - (data 0 (offset (i32.const 0)) "" "a" "bc" "") - (data $m (i32.const 0)) - (data $m (i32.const 1) "a" "" "bcd") - (data $m (offset (i32.const 0))) - (data $m (offset (i32.const 0)) "" "a" "bc" "") + (data (memory 0) (i32.const 0)) + (data (memory 0x0) (i32.const 1) "a" "" "bcd") + (data (memory 0x000) (offset (i32.const 0))) + (data (memory 0) (offset (i32.const 0)) "" "a" "bc" "") + (data (memory $m) (i32.const 0)) + (data (memory $m) (i32.const 1) "a" "" "bcd") + (data (memory $m) (offset (i32.const 0))) + (data (memory $m) (offset (i32.const 0)) "" "a" "bc" "") + (data $d1 (i32.const 0)) + (data $d2 (i32.const 1) "a" "" "bcd") + (data $d3 (offset (i32.const 0))) + (data $d4 (offset (i32.const 0)) "" "a" "bc" "") + (data $d5 (memory 0) (i32.const 0)) + (data $d6 (memory 0x0) (i32.const 1) "a" "" "bcd") + (data $d7 (memory 0x000) (offset (i32.const 0))) + (data $d8 (memory 0) (offset (i32.const 0)) "" "a" "bc" "") + (data $d9 (memory $m) (i32.const 0)) + (data $d10 (memory $m) (i32.const 1) "a" "" "bcd") + (data $d11 (memory $m) (offset (i32.const 0))) + (data $d12 (memory $m) (offset (i32.const 0)) "" "a" "bc" "") ) ;; Basic use @@ -158,44 +170,42 @@ ;; Invalid bounds for data -(assert_unlinkable +(assert_trap (module (memory 0) (data (i32.const 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 0 0) (data (i32.const 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 0 1) (data (i32.const 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) - -(assert_unlinkable +(assert_trap (module (memory 0) (data (i32.const 1)) ) - "data segment does not fit" + "out of bounds memory access" ) - -(assert_unlinkable +(assert_trap (module (memory 0 1) (data (i32.const 1)) ) - "data segment does not fit" + "out of bounds memory access" ) ;; This seems to cause a time-out on Travis. @@ -204,77 +214,77 @@ (memory 0x10000) (data (i32.const 0xffffffff) "ab") ) - "" ;; either out of memory or segment does not fit + "" ;; either out of memory or out of bounds ;) -(assert_unlinkable +(assert_trap (module (global (import "spectest" "global_i32") i32) (memory 0) (data (global.get 0) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 1 2) (data (i32.const 0x1_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "memory" (memory 1)) (data (i32.const 0x1_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 2) (data (i32.const 0x2_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 2 3) (data (i32.const 0x2_0000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 1) (data (i32.const -1) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "memory" (memory 1)) (data (i32.const -1) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (memory 2) (data (i32.const -100) "a") ) - "data segment does not fit" + "out of bounds memory access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "memory" (memory 1)) (data (i32.const -100) "a") ) - "data segment does not fit" + "out of bounds memory access" ) ;; Data without memory @@ -292,19 +302,30 @@ "\00asm" "\01\00\00\00" "\05\03\01" ;; memory section "\00\00" ;; memory 0 - "\0b\06\01" ;; data section - "\01\41\00\0b" ;; data segment 0 for memory 1 + "\0b\07\01" ;; data section + "\02\01\41\00\0b" ;; active data segment 0 for memory 1 "\00" ;; empty vec(byte) ) "unknown memory 1" ) -;; Data segment with memory index 1 (no memory section) +;; Data segment with memory index 0 (no memory section) (assert_invalid (module binary "\00asm" "\01\00\00\00" "\0b\06\01" ;; data section - "\01\41\00\0b" ;; data segment 0 for memory 1 + "\00\41\00\0b" ;; active data segment 0 for memory 0 + "\00" ;; empty vec(byte) + ) + "unknown memory 0" +) + +;; Data segment with memory index 1 (no memory section) +(assert_invalid + (module binary + "\00asm" "\01\00\00\00" + "\0b\07\01" ;; data section + "\02\01\41\00\0b" ;; active data segment 0 for memory 1 "\00" ;; empty vec(byte) ) "unknown memory 1" @@ -317,7 +338,8 @@ "\00asm" "\01\00\00\00" "\05\03\01" ;; memory section "\00\00" ;; memory 0 - "\0b\44\01" ;; data section + "\0b\45\01" ;; data section + "\02" ;; active segment "\01" ;; memory index "\41\00\0b" ;; offset constant expression "\3e" ;; vec(byte) length @@ -336,7 +358,8 @@ (assert_invalid (module binary "\00asm" "\01\00\00\00" - "\0b\44\01" ;; data section + "\0b\45\01" ;; data section + "\02" ;; active segment "\01" ;; memory index "\41\00\0b" ;; offset constant expression "\3e" ;; vec(byte) length @@ -455,4 +478,4 @@ (data (global.get 0)) ) "constant expression required" -) \ No newline at end of file +) diff --git a/test/core/elem.wast b/test/core/elem.wast index ce8ec1f60f..30f65d8dfd 100644 --- a/test/core/elem.wast +++ b/test/core/elem.wast @@ -139,107 +139,106 @@ ;; Invalid bounds for elements -(assert_unlinkable +(assert_trap (module (table 0 funcref) (func $f) (elem (i32.const 0) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (table 0 0 funcref) (func $f) (elem (i32.const 0) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (table 0 1 funcref) (func $f) (elem (i32.const 0) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (table 0 funcref) (elem (i32.const 1)) ) - "elements segment does not fit" + "out of bounds table access" ) - -(assert_unlinkable +(assert_trap (module (table 10 funcref) (func $f) (elem (i32.const 10) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "table" (table 10 funcref)) (func $f) (elem (i32.const 10) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (table 10 20 funcref) (func $f) (elem (i32.const 10) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "table" (table 10 funcref)) (func $f) (elem (i32.const 10) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (table 10 funcref) (func $f) (elem (i32.const -1) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "table" (table 10 funcref)) (func $f) (elem (i32.const -1) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (table 10 funcref) (func $f) (elem (i32.const -10) $f) ) - "elements segment does not fit" + "out of bounds table access" ) -(assert_unlinkable +(assert_trap (module (import "spectest" "table" (table 10 funcref)) (func $f) (elem (i32.const -10) $f) ) - "elements segment does not fit" + "out of bounds table access" ) ;; Element without table diff --git a/test/core/global.wast b/test/core/global.wast index f3808174e7..79440e6921 100644 --- a/test/core/global.wast +++ b/test/core/global.wast @@ -200,6 +200,15 @@ (assert_return (invoke "set-x" (i32.const 6))) (assert_return (invoke "set-y" (i64.const 7))) + +(assert_return (invoke "set-7" (f32.const 8))) +(assert_return (invoke "set-8" (f64.const 9))) + +(assert_return (invoke "get-x") (i32.const 6)) +(assert_return (invoke "get-y") (i64.const 7)) +(assert_return (invoke "get-7") (f32.const 8)) +(assert_return (invoke "get-8") (f64.const 9)) + (assert_return (invoke "set-7" (f32.const 8))) (assert_return (invoke "set-8" (f64.const 9))) diff --git a/test/core/imports.wast b/test/core/imports.wast index 6cfca2fc62..fb5d462725 100644 --- a/test/core/imports.wast +++ b/test/core/imports.wast @@ -14,6 +14,7 @@ (table (export "table-10-inf") 10 funcref) ;; (table (export "table-10-20") 10 20 funcref) (memory (export "memory-2-inf") 2) + ;; Multiple memories are not yet supported ;; (memory (export "memory-2-4") 2 4) ) @@ -419,6 +420,14 @@ (module (import "test" "table-10-inf" (table 10 20 funcref))) "incompatible import type" ) +(assert_unlinkable + (module (import "test" "table-10-20" (table 12 20 funcref))) + "incompatible import type" +) +(assert_unlinkable + (module (import "test" "table-10-20" (table 10 18 funcref))) + "incompatible import type" +) (assert_unlinkable (module (import "spectest" "table" (table 12 funcref))) "incompatible import type" @@ -451,7 +460,7 @@ (module (import "spectest" "memory" (memory 1 2)) - (data 0 (i32.const 10) "\10") + (data (memory 0) (i32.const 10) "\10") (func (export "load") (param i32) (result i32) (i32.load (local.get 0))) ) @@ -463,7 +472,7 @@ (module (memory (import "spectest" "memory") 1 2) - (data 0 (i32.const 10) "\10") + (data (memory 0) (i32.const 10) "\10") (func (export "load") (param i32) (result i32) (i32.load (local.get 0))) ) diff --git a/test/core/linking.wast b/test/core/linking.wast index 6868e8b709..cfb2363991 100644 --- a/test/core/linking.wast +++ b/test/core/linking.wast @@ -133,23 +133,23 @@ (assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5)) (assert_return (invoke $Nt "call Mt.call" (i32.const 2)) (i32.const 4)) -(assert_trap (invoke $Mt "call" (i32.const 1)) "uninitialized") -(assert_trap (invoke $Nt "Mt.call" (i32.const 1)) "uninitialized") +(assert_trap (invoke $Mt "call" (i32.const 1)) "uninitialized element") +(assert_trap (invoke $Nt "Mt.call" (i32.const 1)) "uninitialized element") (assert_return (invoke $Nt "call" (i32.const 1)) (i32.const 5)) -(assert_trap (invoke $Nt "call Mt.call" (i32.const 1)) "uninitialized") +(assert_trap (invoke $Nt "call Mt.call" (i32.const 1)) "uninitialized element") -(assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized") -(assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized") +(assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized element") +(assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized element") (assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5)) -(assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized") +(assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized element") -(assert_trap (invoke $Mt "call" (i32.const 20)) "undefined") -(assert_trap (invoke $Nt "Mt.call" (i32.const 20)) "undefined") -(assert_trap (invoke $Nt "call" (i32.const 7)) "undefined") -(assert_trap (invoke $Nt "call Mt.call" (i32.const 20)) "undefined") +(assert_trap (invoke $Mt "call" (i32.const 20)) "undefined element") +(assert_trap (invoke $Nt "Mt.call" (i32.const 20)) "undefined element") +(assert_trap (invoke $Nt "call" (i32.const 7)) "undefined element") +(assert_trap (invoke $Nt "call Mt.call" (i32.const 20)) "undefined element") (assert_return (invoke $Nt "call" (i32.const 3)) (i32.const -4)) -(assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call") +(assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call type mismatch") (module $Ot (type (func (result i32))) @@ -181,13 +181,13 @@ (assert_return (invoke $Nt "call Mt.call" (i32.const 1)) (i32.const 6)) (assert_return (invoke $Ot "call" (i32.const 1)) (i32.const 6)) -(assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized") -(assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized") +(assert_trap (invoke $Mt "call" (i32.const 0)) "uninitialized element") +(assert_trap (invoke $Nt "Mt.call" (i32.const 0)) "uninitialized element") (assert_return (invoke $Nt "call" (i32.const 0)) (i32.const 5)) -(assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized") -(assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized") +(assert_trap (invoke $Nt "call Mt.call" (i32.const 0)) "uninitialized element") +(assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized element") -(assert_trap (invoke $Ot "call" (i32.const 20)) "undefined") +(assert_trap (invoke $Ot "call" (i32.const 20)) "undefined element") (module (table (import "Mt" "tab") 0 funcref) @@ -203,13 +203,13 @@ ) (assert_return (get $G2 "g") (i32.const 5)) -(assert_unlinkable +(assert_trap (module (table (import "Mt" "tab") 0 funcref) (elem (i32.const 10) $f) (func $f) ) - "elements segment does not fit" + "out of bounds table access" ) (assert_unlinkable @@ -222,28 +222,28 @@ ) "unknown import" ) -(assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized") +(assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized element") -(assert_unlinkable +(assert_trap (module (table (import "Mt" "tab") 10 funcref) (func $f (result i32) (i32.const 0)) (elem (i32.const 7) $f) - (elem (i32.const 12) $f) ;; out of bounds + (elem (i32.const 8) $f $f $f $f $f) ;; (partially) out of bounds ) - "elements segment does not fit" + "out of bounds table access" ) (assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized") -(assert_unlinkable +(assert_trap (module (table (import "Mt" "tab") 10 funcref) (func $f (result i32) (i32.const 0)) (elem (i32.const 7) $f) (memory 1) - (data (i32.const 0x10000) "d") ;; out of bounds + (data (i32.const 0x10000) "d") ;; out of bounds ) - "data segment does not fit" + "out of bounds memory access" ) (assert_trap (invoke $Mt "call" (i32.const 7)) "uninitialized") @@ -295,12 +295,12 @@ (data (i32.const 0xffff) "a") ) -(assert_unlinkable +(assert_trap (module (memory (import "Mm" "mem") 0) (data (i32.const 0x10000) "a") ) - "data segment does not fit" + "out of bounds memory access" ) (module $Pm @@ -331,25 +331,26 @@ ) (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0)) -(assert_unlinkable +(assert_trap (module + ;; Note: the memory is 5 pages large by the time we get here. (memory (import "Mm" "mem") 1) (data (i32.const 0) "abc") - (data (i32.const 0x50000) "d") ;; out of bounds + (data (i32.const 327670) "zzzzzzzzzzzzzzzzzz") ;; (partially) out of bounds ) - "data segment does not fit" + "out of bounds memory access" ) (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0)) -(assert_unlinkable +(assert_trap (module (memory (import "Mm" "mem") 1) (data (i32.const 0) "abc") (table 0 funcref) (func) - (elem (i32.const 0) 0) ;; out of bounds + (elem (i32.const 0) 0) ;; out of bounds ) - "elements segment does not fit" + "out of bounds table access" ) (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 0)) diff --git a/test/core/memory_grow.wast b/test/core/memory_grow.wast index 8a87c77c64..aa56297d25 100644 --- a/test/core/memory_grow.wast +++ b/test/core/memory_grow.wast @@ -312,8 +312,8 @@ (assert_invalid (module (memory 0) - (func $type-size-empty - (memory.grow) (drop) + (func $type-size-empty-vs-i32 (result i32) + (memory.grow) ) ) "type mismatch" @@ -321,9 +321,9 @@ (assert_invalid (module (memory 0) - (func $type-size-empty-in-block + (func $type-size-empty-vs-i32-in-block (result i32) (i32.const 0) - (block (memory.grow) (drop)) + (block (result i32) (memory.grow)) ) ) "type mismatch" @@ -331,9 +331,9 @@ (assert_invalid (module (memory 0) - (func $type-size-empty-in-loop + (func $type-size-empty-vs-i32-in-loop (result i32) (i32.const 0) - (loop (memory.grow) (drop)) + (loop (result i32) (memory.grow)) ) ) "type mismatch" @@ -341,15 +341,39 @@ (assert_invalid (module (memory 0) - (func $type-size-empty-in-then + (func $type-size-empty-vs-i32-in-then (result i32) (i32.const 0) (i32.const 0) - (if (then (memory.grow) (drop))) + (if (result i32) (then (memory.grow))) ) ) "type mismatch" ) +(assert_invalid + (module + (memory 1) + (func $type-size-f32-vs-i32 (result i32) + (memory.grow (f32.const 0)) + ) + ) + "type mismatch" +) -;; Type check - -(assert_invalid (module (memory 1) (func (result i32) (memory.grow (f32.const 0)))) "type mismatch") +(assert_invalid + (module + (memory 1) + (func $type-result-i32-vs-empty + (memory.grow (i32.const 0)) + ) + ) + "type mismatch" +) +(assert_invalid + (module + (memory 1) + (func $type-result-i32-vs-f32 (result f32) + (memory.grow (i32.const 0)) + ) + ) + "type mismatch" +) diff --git a/test/core/select.wast b/test/core/select.wast index e40347e355..0c3f697616 100644 --- a/test/core/select.wast +++ b/test/core/select.wast @@ -1,30 +1,33 @@ (module - - (memory 1) - + ;; Auxiliary (func $dummy) + (memory 1) - (func (export "select_i32") (param $lhs i32) (param $rhs i32) (param $cond i32) (result i32) - (select (local.get $lhs) (local.get $rhs) (local.get $cond))) - - (func (export "select_i64") (param $lhs i64) (param $rhs i64) (param $cond i32) (result i64) - (select (local.get $lhs) (local.get $rhs) (local.get $cond))) - - (func (export "select_f32") (param $lhs f32) (param $rhs f32) (param $cond i32) (result f32) - (select (local.get $lhs) (local.get $rhs) (local.get $cond))) + (func (export "select-i32") (param i32 i32 i32) (result i32) + (select (local.get 0) (local.get 1) (local.get 2)) + ) + (func (export "select-i64") (param i64 i64 i32) (result i64) + (select (local.get 0) (local.get 1) (local.get 2)) + ) + (func (export "select-f32") (param f32 f32 i32) (result f32) + (select (local.get 0) (local.get 1) (local.get 2)) + ) + (func (export "select-f64") (param f64 f64 i32) (result f64) + (select (local.get 0) (local.get 1) (local.get 2)) + ) (func (export "select_f64") (param $lhs f64) (param $rhs f64) (param $cond i32) (result f64) (select (local.get $lhs) (local.get $rhs) (local.get $cond))) ;; Check that both sides of the select are evaluated - (func (export "select_trap_l") (param $cond i32) (result i32) + (func (export "select-trap-left") (param $cond i32) (result i32) (select (unreachable) (i32.const 0) (local.get $cond)) ) - (func (export "select_trap_r") (param $cond i32) (result i32) + (func (export "select-trap-right") (param $cond i32) (result i32) (select (i32.const 0) (unreachable) (local.get $cond)) ) - (func (export "select_unreached") + (func (export "select-unreached") (unreachable) (select) (unreachable) (i32.const 0) (select) (unreachable) (i32.const 0) (i32.const 0) (select) @@ -89,24 +92,24 @@ (func $func (param i32 i32) (result i32) (local.get 0)) (type $check (func (param i32 i32) (result i32))) - (table funcref (elem $func)) + (table $t funcref (elem $func)) (func (export "as-call_indirect-first") (param i32) (result i32) (block (result i32) - (call_indirect (type $check) + (call_indirect $t (type $check) (select (i32.const 2) (i32.const 3) (local.get 0)) (i32.const 1) (i32.const 0) ) ) ) (func (export "as-call_indirect-mid") (param i32) (result i32) (block (result i32) - (call_indirect (type $check) + (call_indirect $t (type $check) (i32.const 1) (select (i32.const 2) (i32.const 3) (local.get 0)) (i32.const 0) ) ) ) (func (export "as-call_indirect-last") (param i32) (result i32) (block (result i32) - (call_indirect (type $check) + (call_indirect $t (type $check) (i32.const 1) (i32.const 4) (select (i32.const 2) (i32.const 3) (local.get 0)) ) ) @@ -184,40 +187,46 @@ ) ) + (func (export "unreachable-num") + (unreachable) + (select) + (i32.eqz) + (drop) + ) ) -(assert_return (invoke "select_i32" (i32.const 1) (i32.const 2) (i32.const 1)) (i32.const 1)) -(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const 1)) (i64.const 2)) -(assert_return (invoke "select_f32" (f32.const 1) (f32.const 2) (i32.const 1)) (f32.const 1)) -(assert_return (invoke "select_f64" (f64.const 1) (f64.const 2) (i32.const 1)) (f64.const 1)) - -(assert_return (invoke "select_i32" (i32.const 1) (i32.const 2) (i32.const 0)) (i32.const 2)) -(assert_return (invoke "select_i32" (i32.const 2) (i32.const 1) (i32.const 0)) (i32.const 1)) -(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const -1)) (i64.const 2)) -(assert_return (invoke "select_i64" (i64.const 2) (i64.const 1) (i32.const 0xf0f0f0f0)) (i64.const 2)) - -(assert_return (invoke "select_f32" (f32.const nan) (f32.const 1) (i32.const 1)) (f32.const nan)) -(assert_return (invoke "select_f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 1)) (f32.const nan:0x20304)) -(assert_return (invoke "select_f32" (f32.const nan) (f32.const 1) (i32.const 0)) (f32.const 1)) -(assert_return (invoke "select_f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 0)) (f32.const 1)) -(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan) (i32.const 1)) (f32.const 2)) -(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 1)) (f32.const 2)) -(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan) (i32.const 0)) (f32.const nan)) -(assert_return (invoke "select_f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 0)) (f32.const nan:0x20304)) - -(assert_return (invoke "select_f64" (f64.const nan) (f64.const 1) (i32.const 1)) (f64.const nan)) -(assert_return (invoke "select_f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 1)) (f64.const nan:0x20304)) -(assert_return (invoke "select_f64" (f64.const nan) (f64.const 1) (i32.const 0)) (f64.const 1)) -(assert_return (invoke "select_f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 0)) (f64.const 1)) -(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan) (i32.const 1)) (f64.const 2)) -(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 1)) (f64.const 2)) -(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan) (i32.const 0)) (f64.const nan)) -(assert_return (invoke "select_f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 0)) (f64.const nan:0x20304)) - -(assert_trap (invoke "select_trap_l" (i32.const 1)) "unreachable") -(assert_trap (invoke "select_trap_l" (i32.const 0)) "unreachable") -(assert_trap (invoke "select_trap_r" (i32.const 1)) "unreachable") -(assert_trap (invoke "select_trap_r" (i32.const 0)) "unreachable") +(assert_return (invoke "select-i32" (i32.const 1) (i32.const 2) (i32.const 1)) (i32.const 1)) +(assert_return (invoke "select-i64" (i64.const 2) (i64.const 1) (i32.const 1)) (i64.const 2)) +(assert_return (invoke "select-f32" (f32.const 1) (f32.const 2) (i32.const 1)) (f32.const 1)) +(assert_return (invoke "select-f64" (f64.const 1) (f64.const 2) (i32.const 1)) (f64.const 1)) + +(assert_return (invoke "select-i32" (i32.const 1) (i32.const 2) (i32.const 0)) (i32.const 2)) +(assert_return (invoke "select-i32" (i32.const 2) (i32.const 1) (i32.const 0)) (i32.const 1)) +(assert_return (invoke "select-i64" (i64.const 2) (i64.const 1) (i32.const -1)) (i64.const 2)) +(assert_return (invoke "select-i64" (i64.const 2) (i64.const 1) (i32.const 0xf0f0f0f0)) (i64.const 2)) + +(assert_return (invoke "select-f32" (f32.const nan) (f32.const 1) (i32.const 1)) (f32.const nan)) +(assert_return (invoke "select-f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 1)) (f32.const nan:0x20304)) +(assert_return (invoke "select-f32" (f32.const nan) (f32.const 1) (i32.const 0)) (f32.const 1)) +(assert_return (invoke "select-f32" (f32.const nan:0x20304) (f32.const 1) (i32.const 0)) (f32.const 1)) +(assert_return (invoke "select-f32" (f32.const 2) (f32.const nan) (i32.const 1)) (f32.const 2)) +(assert_return (invoke "select-f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 1)) (f32.const 2)) +(assert_return (invoke "select-f32" (f32.const 2) (f32.const nan) (i32.const 0)) (f32.const nan)) +(assert_return (invoke "select-f32" (f32.const 2) (f32.const nan:0x20304) (i32.const 0)) (f32.const nan:0x20304)) + +(assert_return (invoke "select-f64" (f64.const nan) (f64.const 1) (i32.const 1)) (f64.const nan)) +(assert_return (invoke "select-f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 1)) (f64.const nan:0x20304)) +(assert_return (invoke "select-f64" (f64.const nan) (f64.const 1) (i32.const 0)) (f64.const 1)) +(assert_return (invoke "select-f64" (f64.const nan:0x20304) (f64.const 1) (i32.const 0)) (f64.const 1)) +(assert_return (invoke "select-f64" (f64.const 2) (f64.const nan) (i32.const 1)) (f64.const 2)) +(assert_return (invoke "select-f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 1)) (f64.const 2)) +(assert_return (invoke "select-f64" (f64.const 2) (f64.const nan) (i32.const 0)) (f64.const nan)) +(assert_return (invoke "select-f64" (f64.const 2) (f64.const nan:0x20304) (i32.const 0)) (f64.const nan:0x20304)) + +(assert_trap (invoke "select-trap-left" (i32.const 1)) "unreachable") +(assert_trap (invoke "select-trap-left" (i32.const 0)) "unreachable") +(assert_trap (invoke "select-trap-right" (i32.const 1)) "unreachable") +(assert_trap (invoke "select-trap-right" (i32.const 0)) "unreachable") (assert_return (invoke "as-select-first" (i32.const 0)) (i32.const 1)) (assert_return (invoke "as-select-first" (i32.const 1)) (i32.const 0)) @@ -251,7 +260,7 @@ (assert_return (invoke "as-br_table-last" (i32.const 1)) (i32.const 2)) (assert_return (invoke "as-call_indirect-first" (i32.const 0)) (i32.const 3)) -(assert_return (invoke "as-call_indirect-first" (i32.const 1)) (i32.const 2)) +;;(assert_return (invoke "as-call_indirect-first" (i32.const 1)) (i32.const 2)) (assert_return (invoke "as-call_indirect-mid" (i32.const 0)) (i32.const 1)) (assert_return (invoke "as-call_indirect-mid" (i32.const 1)) (i32.const 1)) (assert_trap (invoke "as-call_indirect-last" (i32.const 0)) "undefined element") @@ -296,12 +305,38 @@ (assert_return (invoke "as-convert-operand" (i32.const 1)) (i32.const 1)) (assert_invalid - (module (func $arity-0 (select (nop) (nop) (i32.const 1)) (drop))) + (module (func $arity-0-implicit (select (nop) (nop) (i32.const 1)))) "type mismatch" ) -;; The first two operands should have the same type as each other +(assert_invalid + (module (func $type-num-vs-num + (drop (select (i32.const 1) (i64.const 1) (i32.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-num-vs-num + (drop (select (i32.const 1) (f32.const 1.0) (i32.const 1))) + )) + "type mismatch" +) +(assert_invalid + (module (func $type-num-vs-num + (drop (select (i32.const 1) (f64.const 1.0) (i32.const 1))) + )) + "type mismatch" +) + +(assert_invalid + (module (func $type-num-vs-num (select (i32.const 1) (i64.const 1) (i32.const 1)) (drop))) + "type mismatch" +) +(assert_invalid + (module (func $type-num-vs-num (select (i32.const 1) (f32.const 1.0) (i32.const 1)) (drop))) + "type mismatch" +) (assert_invalid (module (func $type-num-vs-num (select (i32.const 1) (i64.const 1) (i32.const 1)) (drop))) "type mismatch"