From a19993e2691b2420dade202db26e022e44436a86 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Wed, 14 Feb 2018 14:02:39 -0800 Subject: [PATCH] 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) --- test/built-ins/Math/pow/int32_min-exponent.js | 17 +++++++++++++++++ .../exponentiation/int32_min-exponent.js | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/built-ins/Math/pow/int32_min-exponent.js create mode 100644 test/language/expressions/exponentiation/int32_min-exponent.js 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 0000000000..56738e8aa2 --- /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 0000000000..556c8885c6 --- /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");