Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion binary-leb128.wast
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\08\01" ;; type section
"\01\0c\01" ;; type section
"\60" ;; func type
"\02" ;; num params
"\7f\7e" ;; param type
Expand Down
56 changes: 56 additions & 0 deletions elem.wast
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,59 @@
(assert_return (invoke $module1 "call-7") (i32.const 67))
(assert_return (invoke $module1 "call-8") (i32.const 69))
(assert_return (invoke $module1 "call-9") (i32.const 70))

;; Element segments must match element type of table

(assert_invalid
(module (func $f) (table 1 externref) (elem (i32.const 0) $f))
"type mismatch"
)

(assert_invalid
(module (table 1 funcref) (elem (i32.const 0) externref (ref.null extern)))
"type mismatch"
)

(assert_invalid
(module
(func $f)
(table $t 1 externref)
(elem $e funcref (ref.func $f))
(func (table.init $t $e (i32.const 0) (i32.const 0) (i32.const 1))))
"type mismatch"
)

(assert_invalid
(module
(table $t 1 funcref)
(elem $e externref (ref.null extern))
(func (table.init $t $e (i32.const 0) (i32.const 0) (i32.const 1))))
"type mismatch"
)

;; Initializing a table with an externref-type element segment

(module $m
(table $t (export "table") 2 externref)
(func (export "get") (param $i i32) (result externref)
(table.get $t (local.get $i)))
(func (export "set") (param $i i32) (param $x externref)
(table.set $t (local.get $i) (local.get $x))))

(register "exporter" $m)

(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern))
(assert_return (invoke $m "get" (i32.const 1)) (ref.null extern))

(assert_return (invoke $m "set" (i32.const 0) (ref.extern 42)))
(assert_return (invoke $m "set" (i32.const 1) (ref.extern 137)))

(assert_return (invoke $m "get" (i32.const 0)) (ref.extern 42))
(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137))

(module
(import "exporter" "table" (table $t 2 externref))
(elem (i32.const 0) externref (ref.null extern)))

(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern))
(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137))
15 changes: 5 additions & 10 deletions imports.wast
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@
(type $func_f64 (func (param f64)))

(import "spectest" "print_i32" (func (param i32)))
;; JavaScript can't handle i64 yet.
;; (func (import "spectest" "print_i64") (param i64))
(func (import "spectest" "print_i64") (param i64))
(import "spectest" "print_i32" (func $print_i32 (param i32)))
;; JavaScript can't handle i64 yet.
;; (import "spectest" "print_i64" (func $print_i64 (param i64)))
(import "spectest" "print_i64" (func $print_i64 (param i64)))
(import "spectest" "print_f32" (func $print_f32 (param f32)))
(import "spectest" "print_f64" (func $print_f64 (param f64)))
(import "spectest" "print_i32_f32" (func $print_i32_f32 (param i32 f32)))
Expand Down Expand Up @@ -72,14 +70,12 @@
(func (export "print64") (param $i i64)
(local $x f64)
(local.set $x (f64.convert_i64_s (call $i64->i64 (local.get $i))))
;; JavaScript can't handle i64 yet.
;; (call 1 (local.get $i))
(call 1 (local.get $i))
(call $print_f64_f64
(f64.add (local.get $x) (f64.const 1))
(f64.const 53)
)
;; JavaScript can't handle i64 yet.
;; (call $print_i64 (local.get $i))
(call $print_i64 (local.get $i))
(call $print_f64 (local.get $x))
(call $print_f64-2 (local.get $x))
(call_indirect (type $func_f64) (local.get $x) (i32.const 1))
Expand Down Expand Up @@ -234,8 +230,7 @@
(import "spectest" "global_i32" (global $x i32))
(global $y (import "spectest" "global_i32") i32)

;; JavaScript can't handle i64 yet.
;; (import "spectest" "global_i64" (global i64))
(import "spectest" "global_i64" (global i64))
(import "spectest" "global_f32" (global f32))
(import "spectest" "global_f64" (global f64))

Expand Down
15 changes: 5 additions & 10 deletions proposals/exception-handling/imports.wast
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
(type $func_f64 (func (param f64)))

(import "spectest" "print_i32" (func (param i32)))
;; JavaScript can't handle i64 yet.
;; (func (import "spectest" "print_i64") (param i64))
(func (import "spectest" "print_i64") (param i64))
(import "spectest" "print_i32" (func $print_i32 (param i32)))
;; JavaScript can't handle i64 yet.
;; (import "spectest" "print_i64" (func $print_i64 (param i64)))
(import "spectest" "print_i64" (func $print_i64 (param i64)))
(import "spectest" "print_f32" (func $print_f32 (param f32)))
(import "spectest" "print_f64" (func $print_f64 (param f64)))
(import "spectest" "print_i32_f32" (func $print_i32_f32 (param i32 f32)))
Expand Down Expand Up @@ -79,14 +77,12 @@
(func (export "print64") (param $i i64)
(local $x f64)
(local.set $x (f64.convert_i64_s (call $i64->i64 (local.get $i))))
;; JavaScript can't handle i64 yet.
;; (call 1 (local.get $i))
(call 1 (local.get $i))
(call $print_f64_f64
(f64.add (local.get $x) (f64.const 1))
(f64.const 53)
)
;; JavaScript can't handle i64 yet.
;; (call $print_i64 (local.get $i))
(call $print_i64 (local.get $i))
(call $print_f64 (local.get $x))
(call $print_f64-2 (local.get $x))
(call_indirect (type $func_f64) (local.get $x) (i32.const 1))
Expand Down Expand Up @@ -266,8 +262,7 @@
(import "spectest" "global_i32" (global $x i32))
(global $y (import "spectest" "global_i32") i32)

;; JavaScript can't handle i64 yet.
;; (import "spectest" "global_i64" (global i64))
(import "spectest" "global_i64" (global i64))
(import "spectest" "global_f32" (global f32))
(import "spectest" "global_f64" (global f64))

Expand Down
56 changes: 56 additions & 0 deletions proposals/extended-const/elem.wast
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,59 @@
(assert_return (invoke $module1 "call-7") (i32.const 67))
(assert_return (invoke $module1 "call-8") (i32.const 69))
(assert_return (invoke $module1 "call-9") (i32.const 70))

;; Element segments must match element type of table

(assert_invalid
(module (func $f) (table 1 externref) (elem (i32.const 0) $f))
"type mismatch"
)

(assert_invalid
(module (table 1 funcref) (elem (i32.const 0) externref (ref.null extern)))
"type mismatch"
)

(assert_invalid
(module
(func $f)
(table $t 1 externref)
(elem $e funcref (ref.func $f))
(func (table.init $t $e (i32.const 0) (i32.const 0) (i32.const 1))))
"type mismatch"
)

(assert_invalid
(module
(table $t 1 funcref)
(elem $e externref (ref.null extern))
(func (table.init $t $e (i32.const 0) (i32.const 0) (i32.const 1))))
"type mismatch"
)

;; Initializing a table with an externref-type element segment

(module $m
(table $t (export "table") 2 externref)
(func (export "get") (param $i i32) (result externref)
(table.get $t (local.get $i)))
(func (export "set") (param $i i32) (param $x externref)
(table.set $t (local.get $i) (local.get $x))))

(register "exporter" $m)

(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern))
(assert_return (invoke $m "get" (i32.const 1)) (ref.null extern))

(assert_return (invoke $m "set" (i32.const 0) (ref.extern 42)))
(assert_return (invoke $m "set" (i32.const 1) (ref.extern 137)))

(assert_return (invoke $m "get" (i32.const 0)) (ref.extern 42))
(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137))

(module
(import "exporter" "table" (table $t 2 externref))
(elem (i32.const 0) externref (ref.null extern)))

(assert_return (invoke $m "get" (i32.const 0)) (ref.null extern))
(assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137))
Loading