Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1537393003: [wasm] Fixed float-to-int32 conversion to match the spec. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a0438854fa86e5c1bd19e20392f8f69d3172f372..b15e2a399632a72b38027bad9c250d5fc87f7632 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -3441,6 +3441,64 @@ TEST(Run_Wasm_I64UConvertF64) {
#endif
+TEST(Run_Wasm_I32SConvertF32) {
+ WasmRunner<int32_t> r(MachineType::Float32());
+ BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT32_INPUTS(i) {
+ if (*i < static_cast<float>(INT32_MAX) &&
+ *i >= static_cast<float>(INT32_MIN)) {
+ CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP32(r.Call(*i));
+ }
+ }
+}
+
+
+TEST(Run_Wasm_I32SConvertF64) {
+ WasmRunner<int32_t> r(MachineType::Float64());
+ BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT64_INPUTS(i) {
+ if (*i < static_cast<double>(INT32_MAX) &&
+ *i >= static_cast<double>(INT32_MIN)) {
+ CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP32(r.Call(*i));
+ }
+ }
+}
+
+
+TEST(Run_Wasm_I32UConvertF32) {
+ WasmRunner<uint32_t> r(MachineType::Float32());
+ BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT32_INPUTS(i) {
+ if (*i < static_cast<float>(UINT32_MAX) && *i > -1) {
+ CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP32(r.Call(*i));
+ }
+ }
+}
+
+
+TEST(Run_Wasm_I32UConvertF64) {
+ WasmRunner<uint32_t> r(MachineType::Float64());
+ BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0)));
+
+ FOR_FLOAT64_INPUTS(i) {
+ if (*i < static_cast<float>(UINT32_MAX) && *i > -1) {
+ CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
+ } else {
+ CHECK_TRAP32(r.Call(*i));
+ }
+ }
+}
+
+
TEST(Run_Wasm_F64CopySign) {
WasmRunner<double> r(MachineType::Float64(), MachineType::Float64());
BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698