Bug 1170716 - Part 3: Use getLastWarning in test for warning with JSEXN_NONE. r=jandem
authorTooru Fujisawa <arai_a@mac.com>
Thu, 11 Jun 2015 13:14:14 +0900
changeset 248233 53a469d716069514b3b42852dff262cba89e66d4
parent 248232 dcb1893ec57928420ad86e5302c48b468ff6c778
child 248234 317521c8184846d12b87581d20f3ca593abd50f7
push id28893
push userkwierso@gmail.com
push dateFri, 12 Jun 2015 00:02:58 +0000
treeherderautoland@8cf9d3e497f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1170716
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1170716 - Part 3: Use getLastWarning in test for warning with JSEXN_NONE. r=jandem
js/src/jit-test/tests/collections/Map-constructor-1.js
js/src/jit-test/tests/collections/Set-constructor-1.js
js/src/jit-test/tests/collections/WeakMap-constructor-1.js
js/src/tests/ecma_6/shell.js
js/src/tests/js1_5/String/replace-flags.js
--- a/js/src/jit-test/tests/collections/Map-constructor-1.js
+++ b/js/src/jit-test/tests/collections/Map-constructor-1.js
@@ -5,13 +5,12 @@ load(libdir + "asserts.js");
 var m = new Map();
 assertEq(m.size, 0);
 m = new Map(undefined);
 assertEq(m.size, 0);
 m = new Map(null);
 assertEq(m.size, 0);
 
 // FIXME: bug 1083752
-options("werror");
-assertEq(evaluate("Map()", {catchTermination: true}), "terminated");
+assertWarning(() => Map(), "None");
 // assertThrowsInstanceOf(() => Map(), TypeError);
 // assertThrowsInstanceOf(() => Map(undefined), TypeError);
 // assertThrowsInstanceOf(() => Map(null), TypeError);
--- a/js/src/jit-test/tests/collections/Set-constructor-1.js
+++ b/js/src/jit-test/tests/collections/Set-constructor-1.js
@@ -5,13 +5,12 @@ load(libdir + "asserts.js");
 var s = new Set();
 assertEq(s.size, 0);
 s = new Set(undefined);
 assertEq(s.size, 0);
 s = new Set(null);
 assertEq(s.size, 0);
 
 // FIXME: bug 1083752
-options("werror");
-assertEq(evaluate("Set()", {catchTermination: true}), "terminated");
+assertWarning(() => Set(), "None");
 // assertThrowsInstanceOf(() => Set(), TypeError);
 // assertThrowsInstanceOf(() => Set(undefined), TypeError);
 // assertThrowsInstanceOf(() => Set(null), TypeError);
--- a/js/src/jit-test/tests/collections/WeakMap-constructor-1.js
+++ b/js/src/jit-test/tests/collections/WeakMap-constructor-1.js
@@ -2,13 +2,12 @@
 
 load(libdir + "asserts.js");
 
 new WeakMap();
 new WeakMap(undefined);
 new WeakMap(null);
 
 // FIXME: bug 1083752
-options("werror");
-assertEq(evaluate("WeakMap()", {catchTermination: true}), "terminated");
+assertWarning(() => WeakMap(), "None");
 // assertThrowsInstanceOf(() => WeakMap(), TypeError);
 // assertThrowsInstanceOf(() => WeakMap(undefined), TypeError);
 // assertThrowsInstanceOf(() => WeakMap(null), TypeError);
--- a/js/src/tests/ecma_6/shell.js
+++ b/js/src/tests/ecma_6/shell.js
@@ -199,8 +199,19 @@ if (typeof assertDeepEq === 'undefined')
                     }
                 }
             }
 
             check(a, b, "");
         };
     })();
 }
+
+if (typeof assertWarning === 'undefined') {
+    function assertWarning(func, name) {
+        enableLastWarning();
+        func();
+        var warning = getLastWarning();
+        assertEq(warning !== null, true);
+        assertEq(warning.name, name);
+        disableLastWarning();
+    }
+}
--- a/js/src/tests/js1_5/String/replace-flags.js
+++ b/js/src/tests/js1_5/String/replace-flags.js
@@ -1,15 +1,24 @@
 // |reftest| skip-if(!xulRuntime.shell)
 
 var BUGNUMBER = 1142351;
 var summary = 'Add console warnings for non-standard flag argument of String.prototype.{search,match,replace}.';
 
 printBugNumber(BUGNUMBER);
 printStatus (summary);
 
-options("werror");
-assertEq(evaluate("'aaaA'.match('a', 'i')", {catchTermination: true}), "terminated");
-assertEq(evaluate("'aaaA'.search('a', 'i')", {catchTermination: true}), "terminated");
-assertEq(evaluate("'aaaA'.replace('a', 'b', 'g')", {catchTermination: true}), "terminated");
+function assertWarningForComponent(code, name) {
+  enableLastWarning();
+  var g = newGlobal();
+  g.eval(code);
+  var warning = getLastWarning();
+  assertEq(warning !== null, true);
+  assertEq(warning.name, name);
+  disableLastWarning();
+}
+
+assertWarningForComponent(`'aaaA'.match('a', 'i');`, "None");
+assertWarningForComponent(`'aaaA'.search('a', 'i');`, "None");
+assertWarningForComponent(`'aaaA'.replace('a', 'b', 'g');`, "None");
 
 if (typeof reportCompare === "function")
   reportCompare(true, true);