Index: test/cctest/wasm/test-run-wasm.cc |
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc |
index 7db7cb740e6483f4a446fb81c23331df7c24886b..7f456a7f025c8822be66b821e967921c23e616d1 100644 |
--- a/test/cctest/wasm/test-run-wasm.cc |
+++ b/test/cctest/wasm/test-run-wasm.cc |
@@ -1148,6 +1148,30 @@ TEST(Run_WasmFloat64Unops) { |
} |
+TEST(Run_WasmFloat32Neg) { |
+ WasmRunner<float> r(MachineType::Float32()); |
+ BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0))); |
+ |
+ FOR_FLOAT32_INPUTS(i) { CheckFloatEq(-(*i), r.Call(*i)); } |
+ |
+ // The difference between +0 and -0 matters here. |
+ CHECK_EQ(bit_cast<uint32_t>(-0.0f), bit_cast<uint32_t>(r.Call(0.0f))); |
+ CHECK_EQ(bit_cast<uint32_t>(0.0f), bit_cast<uint32_t>(r.Call(-0.0f))); |
+} |
+ |
+ |
+TEST(Run_WasmFloat64Neg) { |
+ WasmRunner<double> r(MachineType::Float64()); |
+ BUILD(r, WASM_F64_NEG(WASM_GET_LOCAL(0))); |
+ |
+ FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(-(*i), r.Call(*i)); } |
+ |
+ // The difference between +0 and -0 matters here. |
+ CHECK_EQ(bit_cast<uint64_t>(-0.0), bit_cast<uint64_t>(r.Call(0.0))); |
+ CHECK_EQ(bit_cast<uint64_t>(0.0), bit_cast<uint64_t>(r.Call(-0.0))); |
+} |
+ |
+ |
TEST(Run_Wasm_IfElse_P) { |
WasmRunner<int32_t> r(MachineType::Int32()); |
// if (p0) return 11; else return 22; |