2015-04-17 08:35:59 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2016-03-25 23:01:07 +00:00
|
|
|
// Flags: --stack-size=100 --harmony
|
2015-04-17 13:27:41 +00:00
|
|
|
|
2015-04-17 08:35:59 +00:00
|
|
|
function test(f, expected, type) {
|
|
|
|
try {
|
|
|
|
f();
|
|
|
|
} catch (e) {
|
|
|
|
assertInstanceof(e, type);
|
|
|
|
assertEquals(expected, e.message);
|
2015-04-17 13:27:41 +00:00
|
|
|
return;
|
2015-04-17 08:35:59 +00:00
|
|
|
}
|
2015-04-21 09:03:24 +00:00
|
|
|
assertUnreachable("Exception expected");
|
2015-04-17 08:35:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// === Error ===
|
|
|
|
|
|
|
|
// kCyclicProto
|
|
|
|
test(function() {
|
|
|
|
var o = {};
|
|
|
|
o.__proto__ = o;
|
|
|
|
}, "Cyclic __proto__ value", Error);
|
|
|
|
|
|
|
|
|
|
|
|
// === TypeError ===
|
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
// kApplyNonFunction
|
|
|
|
test(function() {
|
2017-06-20 12:36:43 +00:00
|
|
|
Reflect.apply(1, []);
|
2015-04-17 13:27:41 +00:00
|
|
|
}, "Function.prototype.apply was called on 1, which is a number " +
|
|
|
|
"and not a function", TypeError);
|
|
|
|
|
2015-04-24 10:22:00 +00:00
|
|
|
// kArrayFunctionsOnFrozen
|
|
|
|
test(function() {
|
|
|
|
var a = [1, 2];
|
|
|
|
Object.freeze(a);
|
|
|
|
a.splice(1, 1, [1]);
|
|
|
|
}, "Cannot modify frozen array elements", TypeError);
|
|
|
|
|
|
|
|
// kArrayFunctionsOnSealed
|
|
|
|
test(function() {
|
|
|
|
var a = [1];
|
|
|
|
Object.seal(a);
|
|
|
|
a.shift();
|
|
|
|
}, "Cannot add/remove sealed array elements", TypeError);
|
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kCalledNonCallable
|
|
|
|
test(function() {
|
|
|
|
[].forEach(1);
|
|
|
|
}, "1 is not a function", TypeError);
|
|
|
|
|
2015-04-24 10:22:00 +00:00
|
|
|
// kCalledOnNonObject
|
|
|
|
test(function() {
|
|
|
|
Object.defineProperty(1, "x", {});
|
|
|
|
}, "Object.defineProperty called on non-object", TypeError);
|
|
|
|
|
2015-12-17 08:40:49 +00:00
|
|
|
test(function() {
|
|
|
|
(function() {}).apply({}, 1);
|
|
|
|
}, "CreateListFromArrayLike called on non-object", TypeError);
|
|
|
|
|
|
|
|
test(function() {
|
|
|
|
Reflect.apply(function() {}, {}, 1);
|
|
|
|
}, "CreateListFromArrayLike called on non-object", TypeError);
|
|
|
|
|
|
|
|
test(function() {
|
|
|
|
Reflect.construct(function() {}, 1);
|
|
|
|
}, "CreateListFromArrayLike called on non-object", TypeError);
|
|
|
|
|
2015-04-24 10:22:00 +00:00
|
|
|
// kCalledOnNullOrUndefined
|
|
|
|
test(function() {
|
|
|
|
Array.prototype.shift.call(null);
|
|
|
|
}, "Array.prototype.shift called on null or undefined", TypeError);
|
|
|
|
|
2017-08-22 23:39:31 +00:00
|
|
|
test(function() {
|
|
|
|
String.prototype.includes.call(null);
|
|
|
|
}, "String.prototype.includes called on null or undefined", TypeError);
|
|
|
|
|
2015-10-26 11:07:48 +00:00
|
|
|
// kCannotFreezeArrayBufferView
|
2015-05-12 13:52:26 +00:00
|
|
|
test(function() {
|
2015-10-26 11:07:48 +00:00
|
|
|
Object.freeze(new Uint16Array(1));
|
|
|
|
}, "Cannot freeze array buffer views with elements", TypeError);
|
2015-05-12 13:52:26 +00:00
|
|
|
|
|
|
|
// kConstAssign
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
const a = 1;
|
|
|
|
a = 2;
|
|
|
|
}, "Assignment to constant variable.", TypeError);
|
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
// kCannotConvertToPrimitive
|
|
|
|
test(function() {
|
2015-09-23 21:46:37 +00:00
|
|
|
var o = { toString: function() { return this } };
|
|
|
|
[].join(o);
|
2015-04-17 13:27:41 +00:00
|
|
|
}, "Cannot convert object to primitive value", TypeError);
|
|
|
|
|
2015-05-12 13:52:26 +00:00
|
|
|
// kCircularStructure
|
|
|
|
test(function() {
|
|
|
|
var o = {};
|
|
|
|
o.o = o;
|
|
|
|
JSON.stringify(o);
|
|
|
|
}, "Converting circular structure to JSON", TypeError);
|
|
|
|
|
2015-05-05 07:57:37 +00:00
|
|
|
// kConstructorNotFunction
|
|
|
|
test(function() {
|
|
|
|
Uint16Array(1);
|
|
|
|
}, "Constructor Uint16Array requires 'new'", TypeError);
|
|
|
|
|
2015-05-06 07:51:56 +00:00
|
|
|
// kDataViewNotArrayBuffer
|
|
|
|
test(function() {
|
|
|
|
new DataView(1);
|
|
|
|
}, "First argument to DataView constructor must be an ArrayBuffer", TypeError);
|
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kDefineDisallowed
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
var o = {};
|
|
|
|
Object.preventExtensions(o);
|
|
|
|
Object.defineProperty(o, "x", { value: 1 });
|
2017-02-13 10:27:03 +00:00
|
|
|
}, "Cannot define property x, object is not extensible", TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2015-04-30 16:22:00 +00:00
|
|
|
// kFirstArgumentNotRegExp
|
|
|
|
test(function() {
|
|
|
|
"a".startsWith(/a/);
|
|
|
|
}, "First argument to String.prototype.startsWith " +
|
|
|
|
"must not be a regular expression", TypeError);
|
|
|
|
|
2017-08-22 23:39:31 +00:00
|
|
|
test(function() {
|
|
|
|
"a".includes(/a/);
|
|
|
|
}, "First argument to String.prototype.includes " +
|
|
|
|
"must not be a regular expression", TypeError);
|
|
|
|
|
2016-09-05 13:48:23 +00:00
|
|
|
// kFlagsGetterNonObject
|
|
|
|
test(function() {
|
|
|
|
Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get.call(1);
|
|
|
|
}, "RegExp.prototype.flags getter called on non-object 1", TypeError);
|
|
|
|
|
2015-04-30 16:22:00 +00:00
|
|
|
// kFunctionBind
|
|
|
|
test(function() {
|
|
|
|
Function.prototype.bind.call(1);
|
|
|
|
}, "Bind must be called on a function", TypeError);
|
|
|
|
|
2015-04-17 08:35:59 +00:00
|
|
|
// kGeneratorRunning
|
|
|
|
test(function() {
|
|
|
|
var iter;
|
|
|
|
function* generator() { yield iter.next(); }
|
|
|
|
var iter = generator();
|
|
|
|
iter.next();
|
|
|
|
}, "Generator is already running", TypeError);
|
|
|
|
|
|
|
|
// kIncompatibleMethodReceiver
|
|
|
|
test(function() {
|
2015-11-03 06:18:17 +00:00
|
|
|
Set.prototype.add.call([]);
|
|
|
|
}, "Method Set.prototype.add called on incompatible receiver [object Array]",
|
|
|
|
TypeError);
|
2015-04-17 08:35:59 +00:00
|
|
|
|
2016-05-17 11:23:59 +00:00
|
|
|
// kNonCallableInInstanceOfCheck
|
|
|
|
test(function() {
|
|
|
|
1 instanceof {};
|
|
|
|
}, "Right-hand side of 'instanceof' is not callable", TypeError);
|
|
|
|
|
|
|
|
// kNonObjectInInstanceOfCheck
|
2015-04-17 13:27:41 +00:00
|
|
|
test(function() {
|
|
|
|
1 instanceof 1;
|
2016-03-21 14:00:42 +00:00
|
|
|
}, "Right-hand side of 'instanceof' is not an object", TypeError);
|
2015-04-17 13:27:41 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2015-05-05 07:57:37 +00:00
|
|
|
// kIteratorResultNotAnObject
|
|
|
|
test(function() {
|
|
|
|
var obj = {};
|
|
|
|
obj[Symbol.iterator] = function() { return { next: function() { return 1 }}};
|
|
|
|
Array.from(obj);
|
|
|
|
}, "Iterator result 1 is not an object", TypeError);
|
|
|
|
|
|
|
|
// kIteratorValueNotAnObject
|
|
|
|
test(function() {
|
|
|
|
new Map([1]);
|
|
|
|
}, "Iterator value 1 is not an entry object", TypeError);
|
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
// kNotConstructor
|
|
|
|
test(function() {
|
|
|
|
new Symbol();
|
|
|
|
}, "Symbol is not a constructor", TypeError);
|
|
|
|
|
2015-05-12 13:52:26 +00:00
|
|
|
// kNotDateObject
|
|
|
|
test(function() {
|
2016-01-12 10:47:27 +00:00
|
|
|
Date.prototype.getHours.call(1);
|
2015-05-12 13:52:26 +00:00
|
|
|
}, "this is not a Date object.", TypeError);
|
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kNotGeneric
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => String.prototype.toString.call(1),
|
|
|
|
"String.prototype.toString requires that 'this' be a String",
|
|
|
|
TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => String.prototype.valueOf.call(1),
|
|
|
|
"String.prototype.valueOf requires that 'this' be a String",
|
|
|
|
TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => Boolean.prototype.toString.call(1),
|
|
|
|
"Boolean.prototype.toString requires that 'this' be a Boolean",
|
|
|
|
TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => Boolean.prototype.valueOf.call(1),
|
|
|
|
"Boolean.prototype.valueOf requires that 'this' be a Boolean",
|
|
|
|
TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => Number.prototype.toString.call({}),
|
|
|
|
"Number.prototype.toString requires that 'this' be a Number",
|
|
|
|
TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => Number.prototype.valueOf.call({}),
|
|
|
|
"Number.prototype.valueOf requires that 'this' be a Number",
|
|
|
|
TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2017-04-19 08:34:24 +00:00
|
|
|
test(() => Function.prototype.toString.call(1),
|
|
|
|
"Function.prototype.toString requires that 'this' be a Function",
|
|
|
|
TypeError);
|
2015-05-05 07:57:37 +00:00
|
|
|
|
|
|
|
// kNotTypedArray
|
|
|
|
test(function() {
|
|
|
|
Uint16Array.prototype.forEach.call(1);
|
|
|
|
}, "this is not a typed array.", TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
|
|
|
// kObjectGetterExpectingFunction
|
|
|
|
test(function() {
|
|
|
|
({}).__defineGetter__("x", 0);
|
|
|
|
}, "Object.prototype.__defineGetter__: Expecting function", TypeError);
|
|
|
|
|
|
|
|
// kObjectGetterCallable
|
|
|
|
test(function() {
|
|
|
|
Object.defineProperty({}, "x", { get: 1 });
|
|
|
|
}, "Getter must be a function: 1", TypeError);
|
|
|
|
|
2015-05-12 13:52:26 +00:00
|
|
|
// kObjectNotExtensible
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
var o = {};
|
|
|
|
Object.freeze(o);
|
|
|
|
o.a = 1;
|
2017-02-13 10:27:03 +00:00
|
|
|
}, "Cannot add property a, object is not extensible", TypeError);
|
2015-05-12 13:52:26 +00:00
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kObjectSetterExpectingFunction
|
|
|
|
test(function() {
|
|
|
|
({}).__defineSetter__("x", 0);
|
|
|
|
}, "Object.prototype.__defineSetter__: Expecting function", TypeError);
|
|
|
|
|
|
|
|
// kObjectSetterCallable
|
|
|
|
test(function() {
|
|
|
|
Object.defineProperty({}, "x", { set: 1 });
|
|
|
|
}, "Setter must be a function: 1", TypeError);
|
|
|
|
|
|
|
|
// kPropertyDescObject
|
|
|
|
test(function() {
|
|
|
|
Object.defineProperty({}, "x", 1);
|
|
|
|
}, "Property description must be an object: 1", TypeError);
|
|
|
|
|
2015-04-17 08:35:59 +00:00
|
|
|
// kPropertyNotFunction
|
|
|
|
test(function() {
|
|
|
|
Set.prototype.add = 0;
|
|
|
|
new Set(1);
|
2015-12-02 12:25:02 +00:00
|
|
|
}, "'0' returned for property 'add' of object '#<Set>' is not a function", TypeError);
|
2015-04-17 08:35:59 +00:00
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kProtoObjectOrNull
|
|
|
|
test(function() {
|
|
|
|
Object.setPrototypeOf({}, 1);
|
|
|
|
}, "Object prototype may only be an Object or null: 1", TypeError);
|
|
|
|
|
|
|
|
// kRedefineDisallowed
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
var o = {};
|
|
|
|
Object.defineProperty(o, "x", { value: 1, configurable: false });
|
|
|
|
Object.defineProperty(o, "x", { value: 2 });
|
|
|
|
}, "Cannot redefine property: x", TypeError);
|
|
|
|
|
2015-04-24 10:22:00 +00:00
|
|
|
// kReduceNoInitial
|
|
|
|
test(function() {
|
|
|
|
[].reduce(function() {});
|
|
|
|
}, "Reduce of empty array with no initial value", TypeError);
|
|
|
|
|
2015-05-06 07:51:56 +00:00
|
|
|
// kResolverNotAFunction
|
|
|
|
test(function() {
|
|
|
|
new Promise(1);
|
|
|
|
}, "Promise resolver 1 is not a function", TypeError);
|
|
|
|
|
2015-05-12 13:52:26 +00:00
|
|
|
// kStrictDeleteProperty
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
var o = {};
|
|
|
|
Object.defineProperty(o, "p", { value: 1, writable: false });
|
|
|
|
delete o.p;
|
|
|
|
}, "Cannot delete property 'p' of #<Object>", TypeError);
|
|
|
|
|
|
|
|
// kStrictPoisonPill
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
arguments.callee;
|
|
|
|
}, "'caller', 'callee', and 'arguments' properties may not be accessed on " +
|
|
|
|
"strict mode functions or the arguments objects for calls to them",
|
|
|
|
TypeError);
|
|
|
|
|
|
|
|
// kStrictReadOnlyProperty
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
(1).a = 1;
|
2015-10-09 09:12:28 +00:00
|
|
|
}, "Cannot create property 'a' on number '1'", TypeError);
|
2015-05-12 13:52:26 +00:00
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
// 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);
|
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kValueAndAccessor
|
|
|
|
test(function() {
|
|
|
|
Object.defineProperty({}, "x", { get: function(){}, value: 1});
|
2015-10-14 19:22:17 +00:00
|
|
|
}, "Invalid property descriptor. Cannot both specify accessors " +
|
|
|
|
"and a value or writable attribute, #<Object>", TypeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
|
2015-05-15 13:32:32 +00:00
|
|
|
// === SyntaxError ===
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2015-05-15 13:32:32 +00:00
|
|
|
// kInvalidRegExpFlags
|
|
|
|
test(function() {
|
2015-11-25 13:46:09 +00:00
|
|
|
eval("/a/x.test(\"a\");");
|
|
|
|
}, "Invalid regular expression flags", SyntaxError);
|
2015-05-15 13:32:32 +00:00
|
|
|
|
2016-03-02 14:20:21 +00:00
|
|
|
// kInvalidOrUnexpectedToken
|
|
|
|
test(function() {
|
|
|
|
eval("'\n'");
|
|
|
|
}, "Invalid or unexpected token", SyntaxError);
|
|
|
|
|
2016-02-10 11:28:13 +00:00
|
|
|
//kJsonParseUnexpectedEOS
|
2015-05-15 13:32:32 +00:00
|
|
|
test(function() {
|
|
|
|
JSON.parse("{")
|
2016-02-10 11:28:13 +00:00
|
|
|
}, "Unexpected end of JSON input", SyntaxError);
|
2015-05-15 13:32:32 +00:00
|
|
|
|
2016-02-10 11:28:13 +00:00
|
|
|
// kJsonParseUnexpectedTokenAt
|
2015-05-15 13:32:32 +00:00
|
|
|
test(function() {
|
|
|
|
JSON.parse("/")
|
2016-02-10 11:28:13 +00:00
|
|
|
}, "Unexpected token / in JSON at position 0", SyntaxError);
|
2015-05-15 13:32:32 +00:00
|
|
|
|
2016-02-10 11:28:13 +00:00
|
|
|
// kJsonParseUnexpectedTokenNumberAt
|
2015-05-15 13:32:32 +00:00
|
|
|
test(function() {
|
|
|
|
JSON.parse("{ 1")
|
2016-02-10 11:28:13 +00:00
|
|
|
}, "Unexpected number in JSON at position 2", SyntaxError);
|
2015-05-15 13:32:32 +00:00
|
|
|
|
2016-02-10 11:28:13 +00:00
|
|
|
// kJsonParseUnexpectedTokenStringAt
|
2015-05-15 13:32:32 +00:00
|
|
|
test(function() {
|
|
|
|
JSON.parse('"""')
|
2016-02-10 11:28:13 +00:00
|
|
|
}, "Unexpected string in JSON at position 2", SyntaxError);
|
2015-05-15 13:32:32 +00:00
|
|
|
|
2016-02-10 11:28:13 +00:00
|
|
|
// kMalformedRegExp
|
|
|
|
test(function() {
|
|
|
|
/(/.test("a");
|
|
|
|
}, "Invalid regular expression: /(/: Unterminated group", SyntaxError);
|
|
|
|
|
|
|
|
// kParenthesisInArgString
|
|
|
|
test(function() {
|
|
|
|
new Function(")", "");
|
2017-04-03 14:56:15 +00:00
|
|
|
}, "Arg string terminates parameters early", SyntaxError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2015-05-07 10:00:21 +00:00
|
|
|
// === ReferenceError ===
|
|
|
|
|
2015-05-15 13:32:32 +00:00
|
|
|
// kNotDefined
|
2015-05-07 10:00:21 +00:00
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
o;
|
|
|
|
}, "o is not defined", ReferenceError);
|
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
// === RangeError ===
|
|
|
|
|
2017-02-13 10:28:34 +00:00
|
|
|
// kInvalidOffset
|
|
|
|
test(function() {
|
|
|
|
new Uint8Array(new ArrayBuffer(1),2);
|
|
|
|
}, "Start offset 2 is outside the bounds of the buffer", RangeError);
|
|
|
|
|
2015-04-21 09:03:24 +00:00
|
|
|
// kArrayLengthOutOfRange
|
|
|
|
test(function() {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty([], "length", { value: 1E100 });
|
2015-07-02 15:27:19 +00:00
|
|
|
}, "Invalid array length", RangeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2015-05-06 07:51:56 +00:00
|
|
|
// kInvalidArrayBufferLength
|
|
|
|
test(function() {
|
|
|
|
new ArrayBuffer(-1);
|
|
|
|
}, "Invalid array buffer length", RangeError);
|
|
|
|
|
|
|
|
// kInvalidArrayLength
|
|
|
|
test(function() {
|
|
|
|
[].length = -1;
|
|
|
|
}, "Invalid array length", RangeError);
|
|
|
|
|
2015-04-30 16:22:00 +00:00
|
|
|
// kInvalidCodePoint
|
|
|
|
test(function() {
|
|
|
|
String.fromCodePoint(-1);
|
|
|
|
}, "Invalid code point -1", RangeError);
|
|
|
|
|
|
|
|
// kInvalidCountValue
|
|
|
|
test(function() {
|
|
|
|
"a".repeat(-1);
|
|
|
|
}, "Invalid count value", RangeError);
|
|
|
|
|
2015-05-06 07:51:56 +00:00
|
|
|
// kInvalidArrayBufferLength
|
|
|
|
test(function() {
|
|
|
|
new Uint16Array(-1);
|
2017-04-06 14:27:23 +00:00
|
|
|
}, "Invalid typed array length: -1", RangeError);
|
2015-05-06 07:51:56 +00:00
|
|
|
|
2015-04-24 10:22:00 +00:00
|
|
|
// kNormalizationForm
|
|
|
|
test(function() {
|
|
|
|
"".normalize("ABC");
|
|
|
|
}, "The normalization form should be one of NFC, NFD, NFKC, NFKD.", RangeError);
|
|
|
|
|
|
|
|
// kNumberFormatRange
|
2015-04-21 09:03:24 +00:00
|
|
|
test(function() {
|
2017-07-20 12:24:38 +00:00
|
|
|
Number(1).toFixed(101);
|
|
|
|
}, "toFixed() digits argument must be between 0 and 100", RangeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
|
|
|
test(function() {
|
2017-07-20 12:24:38 +00:00
|
|
|
Number(1).toExponential(101);
|
|
|
|
}, "toExponential() argument must be between 0 and 100", RangeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
2015-04-17 13:27:41 +00:00
|
|
|
// kStackOverflow
|
|
|
|
test(function() {
|
|
|
|
function f() { f(Array(1000)); }
|
|
|
|
f();
|
|
|
|
}, "Maximum call stack size exceeded", RangeError);
|
2015-04-21 09:03:24 +00:00
|
|
|
|
|
|
|
// kToPrecisionFormatRange
|
|
|
|
test(function() {
|
2017-07-20 12:24:38 +00:00
|
|
|
Number(1).toPrecision(101);
|
|
|
|
}, "toPrecision() argument must be between 1 and 100", RangeError);
|
2015-04-24 10:22:00 +00:00
|
|
|
|
|
|
|
// kToPrecisionFormatRange
|
|
|
|
test(function() {
|
|
|
|
Number(1).toString(100);
|
|
|
|
}, "toString() radix argument must be between 2 and 36", RangeError);
|
|
|
|
|
|
|
|
|
|
|
|
// === URIError ===
|
|
|
|
|
|
|
|
// kURIMalformed
|
|
|
|
test(function() {
|
|
|
|
decodeURI("%%");
|
|
|
|
}, "URI malformed", URIError);
|