Follow-up 2 to bug 1041631, part 1 - Make one last test work when Symbol is not defined. Backported from rev 74637aa07226. a=testonly.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 03 Sep 2014 11:54:47 -0500
changeset 216689 337d96ca1194
parent 216688 e0b583b1210e
child 216690 eee93220473c
push id3878
push userjorendorff@mozilla.com
push date2014-09-09 17:26 +0000
treeherdermozilla-beta@eee93220473c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1041631
milestone33.0
Follow-up 2 to bug 1041631, part 1 - Make one last test work when Symbol is not defined. Backported from rev 74637aa07226. a=testonly.
js/src/jit-test/tests/symbol/typed-arrays.js
--- a/js/src/jit-test/tests/symbol/typed-arrays.js
+++ b/js/src/jit-test/tests/symbol/typed-arrays.js
@@ -2,29 +2,30 @@ var tests = [
     {T: Uint8Array, result: 0},
     {T: Uint8ClampedArray, result: 0},
     {T: Int16Array, result: 0},
     {T: Float32Array, result: NaN}
 ];
 
 var LENGTH = 1024, SYMBOL_INDEX = 999;
 
-var sym = this.Symbol ? () => Symbol.for("comet") : () => NaN;
-var big = [];
-for (var i = 0; i < LENGTH; i++)
-    big[i] = (i === SYMBOL_INDEX ? sym() : i);
+if (typeof Symbol === "function") {
+    var big = [];
+    for (var i = 0; i < LENGTH; i++)
+        big[i] = (i === SYMBOL_INDEX ? Symbol.for("comet") : i);
 
-function copy(arr, big) {
-    for (var i = 0; i < LENGTH; i++)
-        arr[i] = big[i];
-}
+    var copy = function copy(arr, big) {
+        for (var i = 0; i < LENGTH; i++)
+            arr[i] = big[i];
+    };
 
-for (var {T, result} of tests) {
-    // Typed array constructors convert symbols to NaN or 0.
-    arr = new T(big);
-    assertEq(arr[SYMBOL_INDEX], result);
+    for (var {T, result} of tests) {
+        // Typed array constructors convert symbols to NaN or 0.
+        arr = new T(big);
+        assertEq(arr[SYMBOL_INDEX], result);
 
-    // Element assignment does the same.
-    for (var k = 0; k < 3; k++) {
-        copy(arr, big);
-        assertEq(arr[SYMBOL_INDEX], result);
+        // Element assignment does the same.
+        for (var k = 0; k < 3; k++) {
+            copy(arr, big);
+            assertEq(arr[SYMBOL_INDEX], result);
+        }
     }
 }