asmble/src/test/resources/local-spec/stack-diff.wast

31 lines
784 B
Plaintext
Raw Normal View History

2017-04-23 16:17:11 -05:00
(module
(global $foo (mut i32) (i32.const 20))
(global $bar (mut f32))
;; This was breaking because stack diff was wrong for get_global and set_global
(func (export "testGlobals") (param $p i32) (result i32)
(local i32)
(get_global $foo)
(set_local 1)
(get_global $foo)
(get_local $p)
(i32.add)
(set_global $foo)
(get_global $foo)
(i32.const 15)
(i32.add)
(i32.const -16)
(i32.and)
(set_global $foo)
(get_global $foo)
)
;; Sqrt had bad stack diff
(func (export "testSqrt") (param $p f32) (result f32)
(set_global $bar (f32.sqrt (get_local $p)))
(get_global $bar)
)
)
(assert_return (invoke "testGlobals" (i32.const 7)) (i32.const 32))
(assert_return (invoke "testSqrt" (f32.const 144)) (f32.const 12))