aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJeff Walden <jwalden@mit.edu>2018-02-14 14:02:39 -0800
committerLeo Balter <leonardo.balter@gmail.com>2018-02-14 17:02:39 -0500
commita19993e2691b2420dade202db26e022e44436a86 (patch)
treeb71d1a9333aa93a117da4b7d4485b92b8101cb6d /test
parent8342824894d7c11788cb454ab388fced6d4f7831 (diff)
Add tests for the behavior of INT32_MIN (-2147483648) as exponent with the exponentiation operator and with Math.pow (which shares the same core algorithm in the spec, but might be differently implemented in actual implementations). (#1445)
Diffstat (limited to 'test')
-rw-r--r--test/built-ins/Math/pow/int32_min-exponent.js17
-rw-r--r--test/language/expressions/exponentiation/int32_min-exponent.js18
2 files changed, 35 insertions, 0 deletions
diff --git a/test/built-ins/Math/pow/int32_min-exponent.js b/test/built-ins/Math/pow/int32_min-exponent.js
new file mode 100644
index 000000000..56738e8aa
--- /dev/null
+++ b/test/built-ins/Math/pow/int32_min-exponent.js
@@ -0,0 +1,17 @@
+// Copyright (C) 2018 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-applying-the-exp-operator
+description: >
+ Using -(2**31) as exponent with Math.pow should behave as expected.
+---*/
+
+const INT32_MIN = -2147483648;
+
+assert.sameValue(Math.pow(2, INT32_MIN), +0.0,
+ "Math.pow(2, -(gonzo huge exponent > 1074)) should be +0 " +
+ "because 2**-1074 is the smallest positive IEEE-754 number");
+
+assert.sameValue(Math.pow(1, INT32_MIN), 1,
+ "1**-(gonzo huge exponent > 1074) should be 1");
diff --git a/test/language/expressions/exponentiation/int32_min-exponent.js b/test/language/expressions/exponentiation/int32_min-exponent.js
new file mode 100644
index 000000000..556c8885c
--- /dev/null
+++ b/test/language/expressions/exponentiation/int32_min-exponent.js
@@ -0,0 +1,18 @@
+// Copyright (C) 2018 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-applying-the-exp-operator
+description: >
+ Using -(2**31) as exponent with the exponentiation operator should behave
+ as expected.
+---*/
+
+const INT32_MIN = -2147483648;
+
+assert.sameValue(2**INT32_MIN, +0.0,
+ "2**-(gonzo huge exponent > 1074) should be +0 because " +
+ "2**-1074 is the smallest positive IEEE-754 number");
+
+assert.sameValue(1**INT32_MIN, 1,
+ "1**-(gonzo huge exponent > 1074) should be 1");