From 48b5abdc6f183f59899f03b9fd705a9e07c2fa1f Mon Sep 17 00:00:00 2001 From: Brendo Costa Date: Tue, 1 Oct 2024 12:09:14 -0300 Subject: [PATCH] Added remaining const instructions testing --- test/gwr/execution/machine_test.gleam | 46 +++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/test/gwr/execution/machine_test.gleam b/test/gwr/execution/machine_test.gleam index 8bf73c2..563cd30 100644 --- a/test/gwr/execution/machine_test.gleam +++ b/test/gwr/execution/machine_test.gleam @@ -9,6 +9,7 @@ import gwr/execution/store import gleeunit import gleeunit/should +import ieee_float pub fn main() { @@ -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() { [ @@ -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()