From 3b258ba0d5e4c1d799060e48fc8a8f3f1d6d90ec Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 26 Apr 2014 16:35:50 +0200 Subject: [PATCH] Bug 885798 - Add Number.{MAX,MIN}_SAFE_INTEGER. r=evilpie --HG-- extra : rebase_source : 74a78f96d5b5951cc0ba4038ec35be0a5d0d2989 --- js/src/jsnum.cpp | 4 +++ .../Number/20.1.2.10-MIN_SAFE_INTEGER.js | 26 +++++++++++++++++++ .../Number/20.1.2.6-MAX_SAFE_INTEGER.js | 26 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 js/src/tests/ecma_6/Number/20.1.2.10-MIN_SAFE_INTEGER.js create mode 100644 js/src/tests/ecma_6/Number/20.1.2.6-MAX_SAFE_INTEGER.js diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 3f8b1b433177..274a5826e92a 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -1095,6 +1095,10 @@ static JSConstDoubleSpec number_constants[] = { {0, "NEGATIVE_INFINITY", 0,{0,0,0}}, {1.7976931348623157E+308, "MAX_VALUE", 0,{0,0,0}}, {0, "MIN_VALUE", 0,{0,0,0}}, + /* ES6 (April 2014 draft) 20.1.2.6 */ + {9007199254740991, "MAX_SAFE_INTEGER", 0,{0,0,0}}, + /* ES6 (April 2014 draft) 20.1.2.10 */ + {-9007199254740991, "MIN_SAFE_INTEGER", 0,{0,0,0}}, /* ES6 (May 2013 draft) 15.7.3.7 */ {2.2204460492503130808472633361816e-16, "EPSILON", 0,{0,0,0}}, {0,0,0,{0,0,0}} diff --git a/js/src/tests/ecma_6/Number/20.1.2.10-MIN_SAFE_INTEGER.js b/js/src/tests/ecma_6/Number/20.1.2.10-MIN_SAFE_INTEGER.js new file mode 100644 index 000000000000..8b96651ff261 --- /dev/null +++ b/js/src/tests/ecma_6/Number/20.1.2.10-MIN_SAFE_INTEGER.js @@ -0,0 +1,26 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- + +var BUGNUMBER = 885798; +var summary = "ES6 (draft April 2014) 20.1.2.10 Number.MIN_SAFE_INTEGER"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// Test value +assertEq(Number.MIN_SAFE_INTEGER, -(Math.pow(2, 53) - 1)); + +//Test property attributes +var descriptor = Object.getOwnPropertyDescriptor(Number, 'MIN_SAFE_INTEGER'); + +assertEq(descriptor.writable, false); +assertEq(descriptor.configurable, false); +assertEq(descriptor.enumerable, false); + +if (typeof reportCompare === "function") + reportCompare(true, true); diff --git a/js/src/tests/ecma_6/Number/20.1.2.6-MAX_SAFE_INTEGER.js b/js/src/tests/ecma_6/Number/20.1.2.6-MAX_SAFE_INTEGER.js new file mode 100644 index 000000000000..e3a2ddff1fa1 --- /dev/null +++ b/js/src/tests/ecma_6/Number/20.1.2.6-MAX_SAFE_INTEGER.js @@ -0,0 +1,26 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +//----------------------------------------------------------------------------- + +var BUGNUMBER = 885798; +var summary = "ES6 (draft April 2014) 20.1.2.6 Number.MAX_SAFE_INTEGER"; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +// Test value +assertEq(Number.MAX_SAFE_INTEGER, Math.pow(2, 53) - 1); + +//Test property attributes +var descriptor = Object.getOwnPropertyDescriptor(Number, 'MAX_SAFE_INTEGER'); + +assertEq(descriptor.writable, false); +assertEq(descriptor.configurable, false); +assertEq(descriptor.enumerable, false); + +if (typeof reportCompare === "function") + reportCompare(true, true);