// ECMA 262 - 15.9.5.43
function DateToISOString() {
var t = UTC_DATE_VALUE(this);
- if (NUMBER_IS_NAN(t)) throw MakeRangeError("invalid_time_value", []);
+ if (NUMBER_IS_NAN(t)) throw MakeRangeError(kInvalidTimeValue);
var year = this.getUTCFullYear();
var year_string;
if (year >= 0 && year <= 9999) {
T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \
T(DateType, "this is not a Date object.") \
T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \
- T(GeneratorRunning, "Generator is already running") \
+ T(FirstArgumentNotRegExp, \
+ "First argument to % must not be a regular expression") \
T(FunctionBind, "Bind must be called on a function") \
+ T(GeneratorRunning, "Generator is already running") \
T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \
T(InstanceofFunctionExpected, \
"Expecting a function in instanceof check, but got %") \
T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \
T(DateRange, "Provided date is not in valid range.") \
T(ExpectedLocation, "Expected Area/Location for time zone, got %") \
+ T(InvalidCodePoint, "Invalid code point %") \
+ T(InvalidCountValue, "Invalid count value") \
T(InvalidCurrencyCode, "Invalid currency code: %") \
T(InvalidLanguageTag, "Invalid language tag: %") \
+ T(InvalidTimeValue, "Invalid time value") \
T(LocaleMatcher, "Illegal value for localeMatcher:%") \
T(NormalizationForm, "The normalization form should be one of %.") \
T(NumberFormatRange, "% argument must be between 0 and 20") \
not_a_promise: ["%0", " is not a promise"],
resolver_not_a_function: ["Promise resolver ", "%0", " is not a function"],
promise_cyclic: ["Chaining cycle detected for promise ", "%0"],
- first_argument_not_regexp: ["First argument to ", "%0", " must not be a regular expression"],
iterator_result_not_an_object: ["Iterator result ", "%0", " is not an object"],
iterator_value_not_an_object: ["Iterator value ", "%0", " is not an entry object"],
// RangeError
invalid_data_view_length: ["Invalid data view length"],
invalid_data_view_accessor_offset:
["Offset is outside the bounds of the DataView"],
-
- invalid_time_value: ["Invalid time value"],
- invalid_count_value: ["Invalid count value"],
- invalid_code_point: ["Invalid code point ", "%0"],
// ReferenceError
invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"],
invalid_lhs_in_for: ["Invalid left-hand side in for-loop"],
var n = ToInteger(count);
// The maximum string length is stored in a smi, so a longer repeat
// must result in a range error.
- if (n < 0 || n > %_MaxSmi()) {
- throw MakeRangeError("invalid_count_value", []);
- }
+ if (n < 0 || n > %_MaxSmi()) throw MakeRangeError(kInvalidCountValue);
var r = "";
while (true) {
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
- throw MakeTypeError("first_argument_not_regexp",
- ["String.prototype.startsWith"]);
+ throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.startsWith");
}
var ss = TO_STRING_INLINE(searchString);
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
- throw MakeTypeError("first_argument_not_regexp",
- ["String.prototype.endsWith"]);
+ throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.endsWith");
}
var ss = TO_STRING_INLINE(searchString);
var s = TO_STRING_INLINE(this);
if (IS_REGEXP(searchString)) {
- throw MakeTypeError("first_argument_not_regexp",
- ["String.prototype.includes"]);
+ throw MakeTypeError(kFirstArgumentNotRegExp, "String.prototype.includes");
}
var ss = TO_STRING_INLINE(searchString);
code = ToNumber(code);
}
if (code < 0 || code > 0x10FFFF || code !== TO_INTEGER(code)) {
- throw MakeRangeError("invalid_code_point", [code]);
+ throw MakeRangeError(kInvalidCodePoint, code);
}
if (code <= 0xFFFF) {
result += %_StringCharFromCode(code);
Object.defineProperty(o, "x", { value: 1 });
}, "Cannot define property:x, object is not extensible.", TypeError);
+// kFirstArgumentNotRegExp
+test(function() {
+ "a".startsWith(/a/);
+}, "First argument to String.prototype.startsWith " +
+ "must not be a regular expression", TypeError);
+
+// kFunctionBind
+test(function() {
+ Function.prototype.bind.call(1);
+}, "Bind must be called on a function", TypeError);
+
// kGeneratorRunning
test(function() {
var iter;
iter.next();
}, "Generator is already running", TypeError);
-// kFunctionBind
-test(function() {
- Function.prototype.bind.call(1);
-}, "Bind must be called on a function", TypeError);
-
// kIncompatibleMethodReceiver
test(function() {
RegExp.prototype.compile.call(RegExp.prototype);
Object.defineProperty([], "length", { value: 1E100 });
}, "defineProperty() array length out of range", RangeError);
+// kInvalidCodePoint
+test(function() {
+ String.fromCodePoint(-1);
+}, "Invalid code point -1", RangeError);
+
+// kInvalidCountValue
+test(function() {
+ "a".repeat(-1);
+}, "Invalid count value", RangeError);
+
// kNormalizationForm
test(function() {
"".normalize("ABC");
// kNumberFormatRange
test(function() {
-Number(1).toFixed(100);
+ Number(1).toFixed(100);
}, "toFixed() digits argument must be between 0 and 20", RangeError);
test(function() {
-Number(1).toExponential(100);
+ Number(1).toExponential(100);
}, "toExponential() argument must be between 0 and 20", RangeError);
// kStackOverflow