Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Unified Diff: test/mjsunit/messages.js

Issue 1089303003: Migrate error messages, part 3 (runtime.js). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/symbol.js ('k') | tools/js2c.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/messages.js
diff --git a/test/mjsunit/messages.js b/test/mjsunit/messages.js
index c2ba73600a51d9e62554f646dcb458981119b82c..41622554abbd3ac248b77c6368e46d63f917bf53 100644
--- a/test/mjsunit/messages.js
+++ b/test/mjsunit/messages.js
@@ -2,14 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// Flags: --stack-size=100 --harmony --harmony-reflect
+
function test(f, expected, type) {
try {
f();
- assertUnreachable();
} catch (e) {
assertInstanceof(e, type);
assertEquals(expected, e.message);
+ return;
}
+ assertUnreachable();
}
// === Error ===
@@ -23,6 +26,17 @@ test(function() {
// === TypeError ===
+// kApplyNonFunction
+test(function() {
+ Function.prototype.apply.call(1, []);
+}, "Function.prototype.apply was called on 1, which is a number " +
+ "and not a function", TypeError);
+
+// kCannotConvertToPrimitive
+test(function() {
+ [].join(Object(Symbol(1)));
+}, "Cannot convert object to primitive value", TypeError);
+
// kGeneratorRunning
test(function() {
var iter;
@@ -42,13 +56,78 @@ test(function() {
}, "Method RegExp.prototype.compile called on incompatible receiver " +
"[object RegExp]", TypeError);
+// kInstanceofFunctionExpected
+test(function() {
+ 1 instanceof 1;
+}, "Expecting a function in instanceof check, but got 1", TypeError);
+
+// kInstanceofNonobjectProto
+test(function() {
+ function f() {}
+ var o = new f();
+ f.prototype = 1;
+ o instanceof f;
+}, "Function has non-object prototype '1' in instanceof check", TypeError);
+
+// kInvalidInOperatorUse
+test(function() {
+ 1 in 1;
+}, "Cannot use 'in' operator to search for '1' in 1", TypeError);
+
+// kNotConstructor
+test(function() {
+ new Symbol();
+}, "Symbol is not a constructor", TypeError);
+
// kPropertyNotFunction
test(function() {
Set.prototype.add = 0;
new Set(1);
}, "Property 'add' of object #<Set> is not a function", TypeError);
+// kSymbolToPrimitive
+test(function() {
+ 1 + Object(Symbol());
+}, "Cannot convert a Symbol wrapper object to a primitive value", TypeError);
+
+// kSymbolToString
+test(function() {
+ "" + Symbol();
+}, "Cannot convert a Symbol value to a string", TypeError);
+
+// kSymbolToNumber
+test(function() {
+ 1 + Symbol();
+}, "Cannot convert a Symbol value to a number", TypeError);
+
+// kUndefinedOrNullToObject
+test(function() {
+ Array.prototype.toString.call(null);
+}, "Cannot convert undefined or null to object", TypeError);
+
// kWithExpression
test(function() {
with (null) {}
}, "null has no properties", TypeError);
+
+// kWrongArgs
+test(function() {
+ (function() {}).apply({}, 1);
+}, "Function.prototype.apply: Arguments list has wrong type", TypeError);
+
+test(function() {
+ Reflect.apply(function() {}, {}, 1);
+}, "Reflect.apply: Arguments list has wrong type", TypeError);
+
+test(function() {
+ Reflect.construct(function() {}, 1);
+}, "Reflect.construct: Arguments list has wrong type", TypeError);
+
+
+// === RangeError ===
+
+// kStackOverflow
+test(function() {
+ function f() { f(Array(1000)); }
+ f();
+}, "Maximum call stack size exceeded", RangeError);
« no previous file with comments | « src/symbol.js ('k') | tools/js2c.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698