Skip to content

Commit

Permalink
Added remaining const instructions testing
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendoCosta committed Oct 1, 2024
1 parent d1b7528 commit 48b5abd
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions test/gwr/execution/machine_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import gwr/execution/store

import gleeunit
import gleeunit/should
import ieee_float

pub fn main()
{
Expand Down Expand Up @@ -54,6 +55,42 @@ fn create_empty_state() -> machine.MachineState
)
}

pub fn i32_const_test()
{
let state = machine.i32_const(create_empty_state(), 65536) |> should.be_ok

stack.peek(state.stack)
|> should.be_some
|> should.equal(stack.ValueEntry(runtime.Integer32(65536)))
}

pub fn i64_const_test()
{
let state = machine.i64_const(create_empty_state(), 65536) |> should.be_ok

stack.peek(state.stack)
|> should.be_some
|> should.equal(stack.ValueEntry(runtime.Integer64(65536)))
}

pub fn f32_const_test()
{
let state = machine.f32_const(create_empty_state(), ieee_float.finite(65536.0)) |> should.be_ok

stack.peek(state.stack)
|> should.be_some
|> should.equal(stack.ValueEntry(runtime.Float32(runtime.Finite(65536.0))))
}

pub fn f64_const_test()
{
let state = machine.f64_const(create_empty_state(), ieee_float.finite(65536.0)) |> should.be_ok

stack.peek(state.stack)
|> should.be_some
|> should.equal(stack.ValueEntry(runtime.Float64(runtime.Finite(65536.0))))
}

pub fn i32_eqz_test()
{
[
Expand Down Expand Up @@ -781,15 +818,6 @@ pub fn i32_add_test()
|> should.equal(stack.ValueEntry(runtime.Integer32(10)))
}

pub fn i32_const_test()
{
let state = machine.i32_const(create_empty_state(), 65536) |> should.be_ok

stack.peek(state.stack)
|> should.be_some
|> should.equal(stack.ValueEntry(runtime.Integer32(65536)))
}

pub fn local_get_test()
{
let state = create_empty_state()
Expand Down

0 comments on commit 48b5abd

Please sign in to comment.