diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/binary/bad-names-duplicate-locals.txt | 34 | ||||
-rw-r--r-- | test/binary/bad-names-duplicates.txt | 26 | ||||
-rw-r--r-- | test/binary/bad-names-function-locals-out-of-order.txt | 37 | ||||
-rw-r--r-- | test/binary/bad-names-locals-out-of-order.txt | 34 | ||||
-rw-r--r-- | test/binary/bad-names-out-of-order.txt | 27 | ||||
-rw-r--r-- | test/link/function_calls.txt | 46 |
6 files changed, 181 insertions, 23 deletions
diff --git a/test/binary/bad-names-duplicate-locals.txt b/test/binary/bad-names-duplicate-locals.txt new file mode 100644 index 00000000..90d23f26 --- /dev/null +++ b/test/binary/bad-names-duplicate-locals.txt @@ -0,0 +1,34 @@ +;;; ERROR: 1 +;;; TOOL: run-gen-wasm +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[1] type[0] } +section(CODE) { + count[1] + func { + locals[decl_count[1] i32_count[2] i32] + get_local 0 + } +} +section("name") { + subsection[1] + length[5] + func_count[1] + index[0] + str("F0") + subsection[2] + length[11] + func_count[1] + index[0] + local_count[2] + index[0] + str("L0") + index[0] + str("L1") +} +(;; STDERR ;;; +Error running "wasm2wast": +error: @0x00000035: duplicate local index: 0 + +;;; STDERR ;;) diff --git a/test/binary/bad-names-duplicates.txt b/test/binary/bad-names-duplicates.txt new file mode 100644 index 00000000..87c3d6f4 --- /dev/null +++ b/test/binary/bad-names-duplicates.txt @@ -0,0 +1,26 @@ +;;; ERROR: 1 +;;; TOOL: run-gen-wasm +;; This test file contains a name section that names that same function twice +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[2] type[0] type[0] } +section(CODE) { + count[2] + func { locals[decl_count[0]] } + func { locals[decl_count[0]] } +} +section("name") { + subsection[1] + length[9] + func_count[2] + index[0] + str("F0") + index[0] + str("F1") +} +(;; STDERR ;;; +Error running "wasm2wast": +error: @0x0000002c: duplicate function name: 0 + +;;; STDERR ;;) diff --git a/test/binary/bad-names-function-locals-out-of-order.txt b/test/binary/bad-names-function-locals-out-of-order.txt new file mode 100644 index 00000000..5ecc80a8 --- /dev/null +++ b/test/binary/bad-names-function-locals-out-of-order.txt @@ -0,0 +1,37 @@ +;;; ERROR: 1 +;;; TOOL: run-gen-wasm +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[2] type[0] type[0] } +section(CODE) { + count[2] + func { locals[decl_count[1] i32_count[2] i32] } + func { locals[decl_count[1] i32_count[2] i32] } +} +section("name") { + subsection[1] + length[9] + func_count[2] + index[0] + str("F0") + index[1] + str("F2") + + subsection[2] + length[13] + func_count[2] + index[1] + local_count[1] + index[0] + str("L0") + index[0] + local_count[1] + index[0] + str("L0") +} +(;; STDERR ;;; +Error running "wasm2wast": +error: @0x0000003d: locals function index out of order: 0 + +;;; STDERR ;;) diff --git a/test/binary/bad-names-locals-out-of-order.txt b/test/binary/bad-names-locals-out-of-order.txt new file mode 100644 index 00000000..746f15b3 --- /dev/null +++ b/test/binary/bad-names-locals-out-of-order.txt @@ -0,0 +1,34 @@ +;;; ERROR: 1 +;;; TOOL: run-gen-wasm +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[1] type[0] } +section(CODE) { + count[1] + func { + locals[decl_count[1] i32_count[2] i32] + get_local 0 + } +} +section("name") { + subsection[1] + length[5] + func_count[1] + index[0] + str("F0") + subsection[2] + length[11] + func_count[1] + index[0] + local_count[2] + index[1] + str("L1") + index[0] + str("L0") +} +(;; STDERR ;;; +Error running "wasm2wast": +error: @0x00000035: local index out of order: 0 + +;;; STDERR ;;) diff --git a/test/binary/bad-names-out-of-order.txt b/test/binary/bad-names-out-of-order.txt new file mode 100644 index 00000000..d3f28447 --- /dev/null +++ b/test/binary/bad-names-out-of-order.txt @@ -0,0 +1,27 @@ +;;; ERROR: 1 +;;; TOOL: run-gen-wasm +;; This test file contains two functions, but their names are listed in the +;; names section out of order (1 first, then 0) which is an error. +magic +version +section(TYPE) { count[1] function params[0] results[1] i32 } +section(FUNCTION) { count[2] type[0] type[0] } +section(CODE) { + count[2] + func { locals[decl_count[0]] } + func { locals[decl_count[0]] } +} +section("name") { + subsection[1] + length[9] + func_count[2] + index[1] + str("F1") + index[0] + str("F0") +} +(;; STDERR ;;; +Error running "wasm2wast": +error: @0x0000002c: function index out of order: 0 + +;;; STDERR ;;) diff --git a/test/link/function_calls.txt b/test/link/function_calls.txt index 0d094eb0..e6993c27 100644 --- a/test/link/function_calls.txt +++ b/test/link/function_calls.txt @@ -10,13 +10,13 @@ call $import1) ) (module - (import "__extern" "baz" (func $import0 (param f64))) - (export "foo" (func $local_func)) - (func $local_func (param i64) + (import "__extern" "baz" (func $m2_import0 (param f64))) + (export "foo" (func $m2_local_func)) + (func $m2_local_func (param i64) f64.const 1 - call $import0 + call $m2_import0 i64.const 10 - call $local_func) + call $m2_local_func) ) (;; STDOUT ;;; @@ -29,8 +29,8 @@ Sections: Function start=0x00000047 end=0x0000004a (size=0x00000003) count: 2 Export start=0x00000050 end=0x00000057 (size=0x00000007) count: 1 Code start=0x00000059 end=0x0000008b (size=0x00000032) count: 2 - Custom start=0x00000091 end=0x000000c7 (size=0x00000036) "name" - Custom start=0x000000cd end=0x000000e9 (size=0x0000001c) "reloc.Code" + Custom start=0x00000091 end=0x000000cd (size=0x0000003c) "name" + Custom start=0x000000d3 end=0x000000ef (size=0x0000001c) "reloc.Code" Section Details: @@ -41,18 +41,18 @@ Type: - [3] (i64) -> nil Import: - func[0] sig=0 <import1> <- __extern.bar - - func[1] sig=2 <import0> <- __extern.baz + - func[1] sig=2 <m2_import0> <- __extern.baz Function: - - func[2] sig=1 - - func[3] sig=3 <local_func> + - func[2] sig=1 <local_func> + - func[3] sig=3 <m2_local_func> Export: - - func[3] <local_func> -> "foo" + - func[3] <m2_local_func> -> "foo" Custom: - name: "name" - func[0] import1 + - func[1] m2_import0 - func[2] local_func - - func[1] import0 - - func[3] local_func + - func[3] m2_local_func Custom: - name: "reloc.Code" - section: Code @@ -64,21 +64,21 @@ Custom: Code Disassembly: -00005a func[2]: +00005a <local_func>: 00005c: 20 00 | get_local 0 - 00005e: 10 82 80 80 80 00 | call 2 - 00005f: R_FUNC_INDEX_LEB 2 - 000064: 10 83 80 80 80 00 | call 3 <local_func> - 000065: R_FUNC_INDEX_LEB 3 <local_func> + 00005e: 10 82 80 80 80 00 | call 2 <local_func> + 00005f: R_FUNC_INDEX_LEB 2 <local_func> + 000064: 10 83 80 80 80 00 | call 3 <m2_local_func> + 000065: R_FUNC_INDEX_LEB 3 <m2_local_func> 00006a: 10 80 80 80 80 00 | call 0 <import1> 00006b: R_FUNC_INDEX_LEB 0 <import1> 000070: 0b | end -000071 <local_func>: +000071 <m2_local_func>: 000073: 44 00 00 00 00 00 00 f0 3f | f64.const 0x1p+0 - 00007c: 10 81 80 80 80 00 | call 1 <import0> - 00007d: R_FUNC_INDEX_LEB 1 <import0> + 00007c: 10 81 80 80 80 00 | call 1 <m2_import0> + 00007d: R_FUNC_INDEX_LEB 1 <m2_import0> 000082: 42 0a | i64.const 10 - 000084: 10 83 80 80 80 00 | call 3 <local_func> - 000085: R_FUNC_INDEX_LEB 3 <local_func> + 000084: 10 83 80 80 80 00 | call 3 <m2_local_func> + 000085: R_FUNC_INDEX_LEB 3 <m2_local_func> 00008a: 0b | end ;;; STDOUT ;;) |