| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --stack-size=100 --harmony --harmony-reflect | 5 // Flags: --stack-size=100 --harmony --harmony-reflect |
| 6 | 6 |
| 7 function test(f, expected, type) { | 7 function test(f, expected, type) { |
| 8 try { | 8 try { |
| 9 f(); | 9 f(); |
| 10 } catch (e) { | 10 } catch (e) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 }, "this is not a Date object.", TypeError); | 72 }, "this is not a Date object.", TypeError); |
| 73 | 73 |
| 74 // kDefineDisallowed | 74 // kDefineDisallowed |
| 75 test(function() { | 75 test(function() { |
| 76 "use strict"; | 76 "use strict"; |
| 77 var o = {}; | 77 var o = {}; |
| 78 Object.preventExtensions(o); | 78 Object.preventExtensions(o); |
| 79 Object.defineProperty(o, "x", { value: 1 }); | 79 Object.defineProperty(o, "x", { value: 1 }); |
| 80 }, "Cannot define property:x, object is not extensible.", TypeError); | 80 }, "Cannot define property:x, object is not extensible.", TypeError); |
| 81 | 81 |
| 82 // kFirstArgumentNotRegExp |
| 83 test(function() { |
| 84 "a".startsWith(/a/); |
| 85 }, "First argument to String.prototype.startsWith " + |
| 86 "must not be a regular expression", TypeError); |
| 87 |
| 88 // kFunctionBind |
| 89 test(function() { |
| 90 Function.prototype.bind.call(1); |
| 91 }, "Bind must be called on a function", TypeError); |
| 92 |
| 82 // kGeneratorRunning | 93 // kGeneratorRunning |
| 83 test(function() { | 94 test(function() { |
| 84 var iter; | 95 var iter; |
| 85 function* generator() { yield iter.next(); } | 96 function* generator() { yield iter.next(); } |
| 86 var iter = generator(); | 97 var iter = generator(); |
| 87 iter.next(); | 98 iter.next(); |
| 88 }, "Generator is already running", TypeError); | 99 }, "Generator is already running", TypeError); |
| 89 | 100 |
| 90 // kFunctionBind | |
| 91 test(function() { | |
| 92 Function.prototype.bind.call(1); | |
| 93 }, "Bind must be called on a function", TypeError); | |
| 94 | |
| 95 // kIncompatibleMethodReceiver | 101 // kIncompatibleMethodReceiver |
| 96 test(function() { | 102 test(function() { |
| 97 RegExp.prototype.compile.call(RegExp.prototype); | 103 RegExp.prototype.compile.call(RegExp.prototype); |
| 98 }, "Method RegExp.prototype.compile called on incompatible receiver " + | 104 }, "Method RegExp.prototype.compile called on incompatible receiver " + |
| 99 "[object RegExp]", TypeError); | 105 "[object RegExp]", TypeError); |
| 100 | 106 |
| 101 // kInstanceofFunctionExpected | 107 // kInstanceofFunctionExpected |
| 102 test(function() { | 108 test(function() { |
| 103 1 instanceof 1; | 109 1 instanceof 1; |
| 104 }, "Expecting a function in instanceof check, but got 1", TypeError); | 110 }, "Expecting a function in instanceof check, but got 1", TypeError); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 258 |
| 253 | 259 |
| 254 // === RangeError === | 260 // === RangeError === |
| 255 | 261 |
| 256 // kArrayLengthOutOfRange | 262 // kArrayLengthOutOfRange |
| 257 test(function() { | 263 test(function() { |
| 258 "use strict"; | 264 "use strict"; |
| 259 Object.defineProperty([], "length", { value: 1E100 }); | 265 Object.defineProperty([], "length", { value: 1E100 }); |
| 260 }, "defineProperty() array length out of range", RangeError); | 266 }, "defineProperty() array length out of range", RangeError); |
| 261 | 267 |
| 268 // kInvalidCodePoint |
| 269 test(function() { |
| 270 String.fromCodePoint(-1); |
| 271 }, "Invalid code point -1", RangeError); |
| 272 |
| 273 // kInvalidCountValue |
| 274 test(function() { |
| 275 "a".repeat(-1); |
| 276 }, "Invalid count value", RangeError); |
| 277 |
| 262 // kNormalizationForm | 278 // kNormalizationForm |
| 263 test(function() { | 279 test(function() { |
| 264 "".normalize("ABC"); | 280 "".normalize("ABC"); |
| 265 }, "The normalization form should be one of NFC, NFD, NFKC, NFKD.", RangeError); | 281 }, "The normalization form should be one of NFC, NFD, NFKC, NFKD.", RangeError); |
| 266 | 282 |
| 267 // kNumberFormatRange | 283 // kNumberFormatRange |
| 268 test(function() { | 284 test(function() { |
| 269 Number(1).toFixed(100); | 285 Number(1).toFixed(100); |
| 270 }, "toFixed() digits argument must be between 0 and 20", RangeError); | 286 }, "toFixed() digits argument must be between 0 and 20", RangeError); |
| 271 | 287 |
| 272 test(function() { | 288 test(function() { |
| 273 Number(1).toExponential(100); | 289 Number(1).toExponential(100); |
| 274 }, "toExponential() argument must be between 0 and 20", RangeError); | 290 }, "toExponential() argument must be between 0 and 20", RangeError); |
| 275 | 291 |
| 276 // kStackOverflow | 292 // kStackOverflow |
| 277 test(function() { | 293 test(function() { |
| 278 function f() { f(Array(1000)); } | 294 function f() { f(Array(1000)); } |
| 279 f(); | 295 f(); |
| 280 }, "Maximum call stack size exceeded", RangeError); | 296 }, "Maximum call stack size exceeded", RangeError); |
| 281 | 297 |
| 282 // kToPrecisionFormatRange | 298 // kToPrecisionFormatRange |
| 283 test(function() { | 299 test(function() { |
| 284 Number(1).toPrecision(100); | 300 Number(1).toPrecision(100); |
| 285 }, "toPrecision() argument must be between 1 and 21", RangeError); | 301 }, "toPrecision() argument must be between 1 and 21", RangeError); |
| 286 | 302 |
| 287 // kToPrecisionFormatRange | 303 // kToPrecisionFormatRange |
| 288 test(function() { | 304 test(function() { |
| 289 Number(1).toString(100); | 305 Number(1).toString(100); |
| 290 }, "toString() radix argument must be between 2 and 36", RangeError); | 306 }, "toString() radix argument must be between 2 and 36", RangeError); |
| 291 | 307 |
| 292 | 308 |
| 293 // === URIError === | 309 // === URIError === |
| 294 | 310 |
| 295 // kURIMalformed | 311 // kURIMalformed |
| 296 test(function() { | 312 test(function() { |
| 297 decodeURI("%%"); | 313 decodeURI("%%"); |
| 298 }, "URI malformed", URIError); | 314 }, "URI malformed", URIError); |
| OLD | NEW |