mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-07-30 21:52:18 +00:00
Fixes; Builtins; Testing in the interpreter
This commit is contained in:
510
tests/compiler/builtins.wast
Normal file
510
tests/compiler/builtins.wast
Normal file
@@ -0,0 +1,510 @@
|
||||
(module
|
||||
(type $v (func))
|
||||
(global $builtins/i (mut i32) (i32.const 0))
|
||||
(global $builtins/I (mut i64) (i64.const 0))
|
||||
(global $builtins/f (mut f32) (f32.const 0))
|
||||
(global $builtins/b (mut i32) (i32.const 0))
|
||||
(global $builtins/F (mut f64) (f64.const 0))
|
||||
(global $builtins/s (mut i32) (i32.const 0))
|
||||
(memory $0 1)
|
||||
(data (i32.const 4) "\08\00\00\00")
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $start (; 0 ;) (type $v)
|
||||
(local $0 f32)
|
||||
(local $1 f32)
|
||||
(local $2 f32)
|
||||
(local $3 f32)
|
||||
(local $4 f64)
|
||||
(local $5 f64)
|
||||
(local $6 f64)
|
||||
(local $7 f64)
|
||||
(drop
|
||||
(i32.clz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.ctz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.popcnt
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.rotl
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.rotr
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.clz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.ctz
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.popcnt
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.rotl
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/i
|
||||
(i32.rotr
|
||||
(i32.const 1)
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.clz
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.ctz
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.popcnt
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.rotl
|
||||
(i64.const 1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i64.rotr
|
||||
(i64.const 1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(i64.clz
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(i64.ctz
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(i64.popcnt
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(i64.rotl
|
||||
(i64.const 1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/I
|
||||
(i64.rotr
|
||||
(i64.const 1)
|
||||
(i64.const 1)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
(drop
|
||||
(f32.const inf)
|
||||
)
|
||||
(drop
|
||||
(f32.abs
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.ceil
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.copysign
|
||||
(f32.const 1.25)
|
||||
(f32.const 2.5)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.floor
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.max
|
||||
(f32.const 1.25)
|
||||
(f32.const 2.5)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.min
|
||||
(f32.const 1.25)
|
||||
(f32.const 2.5)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.nearest
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.sqrt
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.trunc
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f32.ne
|
||||
(tee_local $0
|
||||
(f32.const 1.25)
|
||||
)
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(i32.const 0)
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(get_local $1)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(f32.ne
|
||||
(tee_local $1
|
||||
(f32.const 1.25)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.const nan:0x400000)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.const inf)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.abs
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.ceil
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.copysign
|
||||
(f32.const 1.25)
|
||||
(f32.const 2.5)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.floor
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.max
|
||||
(f32.const 1.25)
|
||||
(f32.const 2.5)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.min
|
||||
(f32.const 1.25)
|
||||
(f32.const 2.5)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.nearest
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.sqrt
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/f
|
||||
(f32.trunc
|
||||
(f32.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(f32.ne
|
||||
(tee_local $2
|
||||
(f32.const 1.25)
|
||||
)
|
||||
(get_local $2)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(select
|
||||
(i32.const 0)
|
||||
(f32.ne
|
||||
(f32.abs
|
||||
(get_local $3)
|
||||
)
|
||||
(f32.const inf)
|
||||
)
|
||||
(f32.ne
|
||||
(tee_local $3
|
||||
(f32.const 1.25)
|
||||
)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
(drop
|
||||
(f64.const inf)
|
||||
)
|
||||
(drop
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
(drop
|
||||
(f64.const inf)
|
||||
)
|
||||
(drop
|
||||
(f64.abs
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.ceil
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.copysign
|
||||
(f64.const 1.25)
|
||||
(f64.const 2.5)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.floor
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.max
|
||||
(f64.const 1.25)
|
||||
(f64.const 2.5)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.min
|
||||
(f64.const 1.25)
|
||||
(f64.const 2.5)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.nearest
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.sqrt
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.trunc
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(f64.ne
|
||||
(tee_local $4
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(select
|
||||
(i32.const 0)
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(get_local $5)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(f64.ne
|
||||
(tee_local $5
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(get_local $5)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.const nan:0x8000000000000)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.const inf)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.abs
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.ceil
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.copysign
|
||||
(f64.const 1.25)
|
||||
(f64.const 2.5)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.floor
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.max
|
||||
(f64.const 1.25)
|
||||
(f64.const 2.5)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.min
|
||||
(f64.const 1.25)
|
||||
(f64.const 2.5)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.nearest
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.sqrt
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/F
|
||||
(f64.trunc
|
||||
(f64.const 1.25)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(f64.ne
|
||||
(tee_local $6
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/b
|
||||
(select
|
||||
(i32.const 0)
|
||||
(f64.ne
|
||||
(f64.abs
|
||||
(get_local $7)
|
||||
)
|
||||
(f64.const inf)
|
||||
)
|
||||
(f64.ne
|
||||
(tee_local $7
|
||||
(f64.const 1.25)
|
||||
)
|
||||
(get_local $7)
|
||||
)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(current_memory)
|
||||
)
|
||||
(drop
|
||||
(grow_memory
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_global $builtins/s
|
||||
(current_memory)
|
||||
)
|
||||
(set_global $builtins/s
|
||||
(grow_memory
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.const 0)
|
||||
(unreachable)
|
||||
)
|
||||
(if
|
||||
(i32.eqz
|
||||
(i32.const 1)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
clz
|
||||
ctz
|
||||
popcnt
|
||||
rotl
|
||||
rotr
|
||||
abs
|
||||
ceil
|
||||
copysign
|
||||
floor
|
||||
max
|
||||
min
|
||||
nearest
|
||||
sqrt
|
||||
trunc
|
||||
current_memory
|
||||
grow_memory
|
||||
unreachable
|
||||
isNaN
|
||||
isFinite
|
||||
assert
|
||||
builtins/b
|
||||
builtins/i
|
||||
builtins/I
|
||||
builtins/f
|
||||
builtins/F
|
||||
builtins/s
|
||||
[program.exports]
|
||||
|
||||
;)
|
Reference in New Issue
Block a user