Skip to content

Commit

Permalink
test: add unit tests for f32/f64 comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
axic authored and chfast committed Aug 7, 2020
1 parent 0b82a7a commit 0cf4a4e
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/unittests/execute_floating_point_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,30 @@ TEST(execute_floating_point, f64_add)

auto instance = instantiate(parse(wasm));
EXPECT_THAT(execute(*instance, 0, {1.0011, 6.0066}), Result(7.0077));
}
}

TEST(execute_floating_point, f32_gt)
{
/* wat2wasm
(func (param f32 f32) (result i32)
local.get 0
local.get 1
f32.gt
)
*/
const auto wasm = from_hex("0061736d0100000001070160027d7d017f030201000a09010700200020015e0b");

auto instance = instantiate(parse(wasm));
const auto result1 = execute(*instance, 0, {1.001f, 6.006f});
EXPECT_EQ(result1.value.i64, 0);
const auto result2 = execute(*instance, 0, {6.006f, 1.001f});
EXPECT_EQ(result2.value.i64, 1);
const auto result3 = execute(*instance, 0, {6.006f, 6.006f});
EXPECT_EQ(result3.value.i64, 0);
const auto result4 = execute(*instance, 0, {-6.006f, 6.006f});
EXPECT_EQ(result4.value.i64, 0);
const auto result5 = execute(*instance, 0, {6.006f, -6.006f});
EXPECT_EQ(result5.value.i64, 1);
const auto result6 = execute(*instance, 0, {-6.006f, 0});
EXPECT_EQ(result6.value.i64, 0);
}

0 comments on commit 0cf4a4e

Please sign in to comment.