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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 | 26 |
27 // === TypeError === | 27 // === TypeError === |
28 | 28 |
29 // kApplyNonFunction | 29 // kApplyNonFunction |
30 test(function() { | 30 test(function() { |
31 Function.prototype.apply.call(1, []); | 31 Function.prototype.apply.call(1, []); |
32 }, "Function.prototype.apply was called on 1, which is a number " + | 32 }, "Function.prototype.apply was called on 1, which is a number " + |
33 "and not a function", TypeError); | 33 "and not a function", TypeError); |
34 | 34 |
| 35 // kArrayFunctionsOnFrozen |
| 36 test(function() { |
| 37 var a = [1, 2]; |
| 38 Object.freeze(a); |
| 39 a.splice(1, 1, [1]); |
| 40 }, "Cannot modify frozen array elements", TypeError); |
| 41 |
| 42 // kArrayFunctionsOnSealed |
| 43 test(function() { |
| 44 var a = [1]; |
| 45 Object.seal(a); |
| 46 a.shift(); |
| 47 }, "Cannot add/remove sealed array elements", TypeError); |
| 48 |
35 // kCalledNonCallable | 49 // kCalledNonCallable |
36 test(function() { | 50 test(function() { |
37 [].forEach(1); | 51 [].forEach(1); |
38 }, "1 is not a function", TypeError); | 52 }, "1 is not a function", TypeError); |
39 | 53 |
| 54 // kCalledOnNonObject |
| 55 test(function() { |
| 56 Object.defineProperty(1, "x", {}); |
| 57 }, "Object.defineProperty called on non-object", TypeError); |
| 58 |
| 59 // kCalledOnNullOrUndefined |
| 60 test(function() { |
| 61 Array.prototype.shift.call(null); |
| 62 }, "Array.prototype.shift called on null or undefined", TypeError); |
| 63 |
40 // kCannotConvertToPrimitive | 64 // kCannotConvertToPrimitive |
41 test(function() { | 65 test(function() { |
42 [].join(Object(Symbol(1))); | 66 [].join(Object(Symbol(1))); |
43 }, "Cannot convert object to primitive value", TypeError); | 67 }, "Cannot convert object to primitive value", TypeError); |
44 | 68 |
| 69 // kDateType |
| 70 test(function() { |
| 71 Date.prototype.setYear.call({}, 1); |
| 72 }, "this is not a Date object.", TypeError); |
| 73 |
45 // kDefineDisallowed | 74 // kDefineDisallowed |
46 test(function() { | 75 test(function() { |
47 "use strict"; | 76 "use strict"; |
48 var o = {}; | 77 var o = {}; |
49 Object.preventExtensions(o); | 78 Object.preventExtensions(o); |
50 Object.defineProperty(o, "x", { value: 1 }); | 79 Object.defineProperty(o, "x", { value: 1 }); |
51 }, "Cannot define property:x, object is not extensible.", TypeError); | 80 }, "Cannot define property:x, object is not extensible.", TypeError); |
52 | 81 |
53 // kGeneratorRunning | 82 // kGeneratorRunning |
54 test(function() { | 83 test(function() { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 }, "Number.prototype.toString is not generic", TypeError); | 143 }, "Number.prototype.toString is not generic", TypeError); |
115 | 144 |
116 test(function() { | 145 test(function() { |
117 Number.prototype.valueOf.call({}); | 146 Number.prototype.valueOf.call({}); |
118 }, "Number.prototype.valueOf is not generic", TypeError); | 147 }, "Number.prototype.valueOf is not generic", TypeError); |
119 | 148 |
120 test(function() { | 149 test(function() { |
121 Function.prototype.toString.call(1); | 150 Function.prototype.toString.call(1); |
122 }, "Function.prototype.toString is not generic", TypeError); | 151 }, "Function.prototype.toString is not generic", TypeError); |
123 | 152 |
124 | |
125 // kObjectGetterExpectingFunction | 153 // kObjectGetterExpectingFunction |
126 test(function() { | 154 test(function() { |
127 ({}).__defineGetter__("x", 0); | 155 ({}).__defineGetter__("x", 0); |
128 }, "Object.prototype.__defineGetter__: Expecting function", TypeError); | 156 }, "Object.prototype.__defineGetter__: Expecting function", TypeError); |
129 | 157 |
130 // kObjectGetterCallable | 158 // kObjectGetterCallable |
131 test(function() { | 159 test(function() { |
132 Object.defineProperty({}, "x", { get: 1 }); | 160 Object.defineProperty({}, "x", { get: 1 }); |
133 }, "Getter must be a function: 1", TypeError); | 161 }, "Getter must be a function: 1", TypeError); |
134 | 162 |
(...skipping 24 matching lines...) Expand all Loading... |
159 }, "Object prototype may only be an Object or null: 1", TypeError); | 187 }, "Object prototype may only be an Object or null: 1", TypeError); |
160 | 188 |
161 // kRedefineDisallowed | 189 // kRedefineDisallowed |
162 test(function() { | 190 test(function() { |
163 "use strict"; | 191 "use strict"; |
164 var o = {}; | 192 var o = {}; |
165 Object.defineProperty(o, "x", { value: 1, configurable: false }); | 193 Object.defineProperty(o, "x", { value: 1, configurable: false }); |
166 Object.defineProperty(o, "x", { value: 2 }); | 194 Object.defineProperty(o, "x", { value: 2 }); |
167 }, "Cannot redefine property: x", TypeError); | 195 }, "Cannot redefine property: x", TypeError); |
168 | 196 |
| 197 // kReduceNoInitial |
| 198 test(function() { |
| 199 [].reduce(function() {}); |
| 200 }, "Reduce of empty array with no initial value", TypeError); |
| 201 |
169 // kSymbolToPrimitive | 202 // kSymbolToPrimitive |
170 test(function() { | 203 test(function() { |
171 1 + Object(Symbol()); | 204 1 + Object(Symbol()); |
172 }, "Cannot convert a Symbol wrapper object to a primitive value", TypeError); | 205 }, "Cannot convert a Symbol wrapper object to a primitive value", TypeError); |
173 | 206 |
174 // kSymbolToString | 207 // kSymbolToString |
175 test(function() { | 208 test(function() { |
176 "" + Symbol(); | 209 "" + Symbol(); |
177 }, "Cannot convert a Symbol value to a string", TypeError); | 210 }, "Cannot convert a Symbol value to a string", TypeError); |
178 | 211 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 252 |
220 | 253 |
221 // === RangeError === | 254 // === RangeError === |
222 | 255 |
223 // kArrayLengthOutOfRange | 256 // kArrayLengthOutOfRange |
224 test(function() { | 257 test(function() { |
225 "use strict"; | 258 "use strict"; |
226 Object.defineProperty([], "length", { value: 1E100 }); | 259 Object.defineProperty([], "length", { value: 1E100 }); |
227 }, "defineProperty() array length out of range", RangeError); | 260 }, "defineProperty() array length out of range", RangeError); |
228 | 261 |
229 //kNumberFormatRange | 262 // kNormalizationForm |
| 263 test(function() { |
| 264 "".normalize("ABC"); |
| 265 }, "The normalization form should be one of NFC, NFD, NFKC, NFKD.", RangeError); |
| 266 |
| 267 // kNumberFormatRange |
230 test(function() { | 268 test(function() { |
231 Number(1).toFixed(100); | 269 Number(1).toFixed(100); |
232 }, "toFixed() digits argument must be between 0 and 20", RangeError); | 270 }, "toFixed() digits argument must be between 0 and 20", RangeError); |
233 | 271 |
234 test(function() { | 272 test(function() { |
235 Number(1).toExponential(100); | 273 Number(1).toExponential(100); |
236 }, "toExponential() argument must be between 0 and 20", RangeError); | 274 }, "toExponential() argument must be between 0 and 20", RangeError); |
237 | 275 |
238 // kStackOverflow | 276 // kStackOverflow |
239 test(function() { | 277 test(function() { |
240 function f() { f(Array(1000)); } | 278 function f() { f(Array(1000)); } |
241 f(); | 279 f(); |
242 }, "Maximum call stack size exceeded", RangeError); | 280 }, "Maximum call stack size exceeded", RangeError); |
243 | 281 |
244 // kToPrecisionFormatRange | 282 // kToPrecisionFormatRange |
245 test(function() { | 283 test(function() { |
246 Number(1).toPrecision(100); | 284 Number(1).toPrecision(100); |
247 }, "toPrecision() argument must be between 1 and 21", RangeError); | 285 }, "toPrecision() argument must be between 1 and 21", RangeError); |
| 286 |
| 287 // kToPrecisionFormatRange |
| 288 test(function() { |
| 289 Number(1).toString(100); |
| 290 }, "toString() radix argument must be between 2 and 36", RangeError); |
| 291 |
| 292 |
| 293 // === URIError === |
| 294 |
| 295 // kURIMalformed |
| 296 test(function() { |
| 297 decodeURI("%%"); |
| 298 }, "URI malformed", URIError); |
OLD | NEW |