Bug 885798 - Add Number.{MAX,MIN}_SAFE_INTEGER. r=evilpie
authorStephen Kelly <steveire@gmail.com>
Sat, 26 Apr 2014 16:35:50 +0200
changeset 180770 90515fc1d2cd262c100d0ee7dda5e328898e238d
parent 180769 2629257557ffe8aa193cd7139394ee0a2780cc1f
child 180771 483210d830f00f73825a4e6e2916999ff83805e5
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersevilpie
bugs885798
milestone31.0a1
Bug 885798 - Add Number.{MAX,MIN}_SAFE_INTEGER. r=evilpie
js/src/jsnum.cpp
js/src/tests/ecma_6/Number/20.1.2.10-MIN_SAFE_INTEGER.js
js/src/tests/ecma_6/Number/20.1.2.6-MAX_SAFE_INTEGER.js
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -1090,16 +1090,20 @@ enum nc_slot {
  * using union jsdpun.
  */
 static JSConstDoubleSpec number_constants[] = {
     {0,                         "NaN",               0,{0,0,0}},
     {0,                         "POSITIVE_INFINITY", 0,{0,0,0}},
     {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}}
 };
 
 #if (defined __GNUC__ && defined __i386__) || \
     (defined __SUNPRO_CC && defined __i386)
 
new file mode 100644
--- /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);
new file mode 100644
--- /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);