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..90897fe60e4e90cd9b79a24f9f7f3bf0b0c7d9af 100644 |
--- a/test/cctest/wasm/test-run-wasm.cc |
+++ b/test/cctest/wasm/test-run-wasm.cc |
@@ -3168,7 +3168,18 @@ TEST(Run_Wasm_F32Min) { |
FOR_FLOAT32_INPUTS(i) { |
FOR_FLOAT32_INPUTS(j) { |
- float expected = *i < *j ? *i : *j; |
+ float expected; |
+ if (*i < *j) { |
+ expected = *i; |
+ } else if (*j < *i) { |
+ expected = *j; |
+ } else if (*i != *i) { |
+ // If *i or *j is NaN, then the result is NaN. |
+ expected = *i; |
+ } else { |
+ expected = *j; |
+ } |
+ |
CheckFloatEq(expected, r.Call(*i, *j)); |
} |
} |
@@ -3181,7 +3192,18 @@ TEST(Run_Wasm_F64Min) { |
FOR_FLOAT64_INPUTS(i) { |
FOR_FLOAT64_INPUTS(j) { |
- double expected = *i < *j ? *i : *j; |
+ double expected; |
+ if (*i < *j) { |
+ expected = *i; |
+ } else if (*j < *i) { |
+ expected = *j; |
+ } else if (*i != *i) { |
+ // If *i or *j is NaN, then the result is NaN. |
+ expected = *i; |
+ } else { |
+ expected = *j; |
+ } |
+ |
CheckDoubleEq(expected, r.Call(*i, *j)); |
} |
} |
@@ -3194,7 +3216,18 @@ TEST(Run_Wasm_F32Max) { |
FOR_FLOAT32_INPUTS(i) { |
FOR_FLOAT32_INPUTS(j) { |
- float expected = *i > *j ? *i : *j; |
+ float expected; |
+ if (*i > *j) { |
+ expected = *i; |
+ } else if (*j > *i) { |
+ expected = *j; |
+ } else if (*i != *i) { |
+ // If *i or *j is NaN, then the result is NaN. |
+ expected = *i; |
+ } else { |
+ expected = *j; |
+ } |
+ |
CheckFloatEq(expected, r.Call(*i, *j)); |
} |
} |
@@ -3207,7 +3240,18 @@ TEST(Run_Wasm_F64Max) { |
FOR_FLOAT64_INPUTS(i) { |
FOR_FLOAT64_INPUTS(j) { |
- double expected = *i > *j ? *i : *j; |
+ double expected; |
+ if (*i > *j) { |
+ expected = *i; |
+ } else if (*j > *i) { |
+ expected = *j; |
+ } else if (*i != *i) { |
+ // If *i or *j is NaN, then the result is NaN. |
+ expected = *i; |
+ } else { |
+ expected = *j; |
+ } |
+ |
CheckDoubleEq(expected, r.Call(*i, *j)); |
} |
} |