forked from WebAssembly/spec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor local init tests to local_init.wast; add more (WebAssembly#84)
- Loading branch information
Showing
2 changed files
with
74 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
;; Uninitialized undefaulted locals | ||
|
||
(module | ||
(func (export "get-after-set") (param $p (ref extern)) (result (ref extern)) | ||
(local $x (ref extern)) | ||
(local.set $x (local.get $p)) | ||
(local.get $x) | ||
) | ||
(func (export "get-after-tee") (param $p (ref extern)) (result (ref extern)) | ||
(local $x (ref extern)) | ||
(drop (local.tee $x (local.get $p))) | ||
(local.get $x) | ||
) | ||
(func (export "get-in-block-after-set") (param $p (ref extern)) (result (ref extern)) | ||
(local $x (ref extern)) | ||
(local.set $x (local.get $p)) | ||
(block (result (ref extern)) (local.get $x)) | ||
) | ||
) | ||
|
||
(assert_return (invoke "get-after-set" (ref.extern 1)) (ref.extern 1)) | ||
(assert_return (invoke "get-after-tee" (ref.extern 2)) (ref.extern 2)) | ||
(assert_return (invoke "get-in-block-after-set" (ref.extern 3)) (ref.extern 3)) | ||
|
||
(assert_invalid | ||
(module (func $uninit (local $x (ref extern)) (drop (local.get $x)))) | ||
"uninitialized local" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $uninit-after-end (param $p (ref extern)) | ||
(local $x (ref extern)) | ||
(block (local.set $x (local.get $p)) (drop (local.tee $x (local.get $p)))) | ||
(drop (local.get $x)) | ||
) | ||
) | ||
"uninitialized local" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $uninit-in-else (param $p (ref extern)) | ||
(local $x (ref extern)) | ||
(if (i32.const 0) | ||
(then (local.set $x (local.get $p))) | ||
(else (local.get $x)) | ||
) | ||
) | ||
) | ||
"uninitialized local" | ||
) | ||
|
||
(assert_invalid | ||
(module | ||
(func $uninit-from-if (param $p (ref extern)) | ||
(local $x (ref extern)) | ||
(if (i32.const 0) | ||
(then (local.set $x (local.get $p))) | ||
(else (local.set $x (local.get $p))) | ||
) | ||
(drop (local.get $x)) | ||
) | ||
) | ||
"uninitialized local" | ||
) | ||
|
||
(module | ||
(func (export "tee-init") (param $p (ref extern)) (result (ref extern)) | ||
(local $x (ref extern)) | ||
(drop (local.tee $x (local.get $p))) | ||
(local.get $x) | ||
) | ||
) | ||
|
||
(assert_return (invoke "tee-init" (ref.extern 1)) (ref.extern 1)) |