OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Calling Intl methods with a bad receiver throws a TypeError |
| 6 |
| 7 // An uninitialized object of the same type |
| 8 assertThrows(() => Object.create(Intl.DateTimeFormat.prototype).format(), |
| 9 TypeError); |
| 10 assertThrows(() => Object.create(Intl.NumberFormat.prototype).format(), |
| 11 TypeError); |
| 12 assertThrows(() => Object.create(Intl.Collator.prototype).compare(), |
| 13 TypeError); |
| 14 assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).adoptText(), |
| 15 TypeError); |
| 16 assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).first(), |
| 17 TypeError); |
| 18 assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).next(), |
| 19 TypeError); |
| 20 assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).current(), |
| 21 TypeError); |
| 22 assertThrows(() => Object.create(Intl.v8BreakIterator.prototype).breakType(), |
| 23 TypeError); |
| 24 |
| 25 // Or similarly, just accessing the method getter on the prototype |
| 26 assertThrows(() => Intl.DateTimeFormat.prototype.format, TypeError); |
| 27 assertThrows(() => Intl.NumberFormat.prototype.format, TypeError); |
| 28 assertThrows(() => Intl.Collator.prototype.compare, TypeError); |
| 29 assertThrows(() => Intl.v8BreakIterator.prototype.adoptText, TypeError); |
| 30 assertThrows(() => Intl.v8BreakIterator.prototype.first, TypeError); |
| 31 assertThrows(() => Intl.v8BreakIterator.prototype.next, TypeError); |
| 32 assertThrows(() => Intl.v8BreakIterator.prototype.current, TypeError); |
| 33 assertThrows(() => Intl.v8BreakIterator.prototype.breakType, TypeError); |
| 34 |
| 35 // The method .call'd on a different instance will have that |
| 36 // other instance benignly ignored, since it's a bound function |
| 37 let nf = Intl.NumberFormat(); |
| 38 let df = Intl.DateTimeFormat(); |
| 39 assertEquals("0", nf.format.call(df, 0)); |
OLD | NEW |