| 1 |
// Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
info: | |
| 6 |
The [[Value]] property of the newly constructed object |
| 7 |
is set by following steps: |
| 8 |
1. Call ToNumber(year) |
| 9 |
2. Call ToNumber(month) |
| 10 |
3. If date is supplied use ToNumber(date) |
| 11 |
4. If hours is supplied use ToNumber(hours) |
| 12 |
5. If minutes is supplied use ToNumber(minutes) |
| 13 |
6. If seconds is supplied use ToNumber(seconds) |
| 14 |
7. If ms is supplied use ToNumber(ms) |
| 15 |
esid: sec-date-year-month-date-hours-minutes-seconds-ms |
| 16 |
description: 4 arguments, (year, month, date, hours) |
| 17 |
---*/ |
| 18 |
|
| 19 |
function PoisonedValueOf(val) { |
| 20 |
this.value = val; |
| 21 |
this.valueOf = function() { |
| 22 |
throw new Test262Error(); |
| 23 |
}; |
| 24 |
this.toString = function() {}; |
| 25 |
} |
| 26 |
|
| 27 |
assert.throws(Test262Error, () => { |
| 28 |
new Date(new PoisonedValueOf(1), new PoisonedValueOf(2), new PoisonedValueOf(3), new PoisonedValueOf(4)); |
| 29 |
}, '`new Date(new PoisonedValueOf(1), new PoisonedValueOf(2), new PoisonedValueOf(3), new PoisonedValueOf(4))` throws a Test262Error exception'); |
| 30 |
|
| 31 |
assert.throws(Test262Error, () => { |
| 32 |
new Date(1, new PoisonedValueOf(2), new PoisonedValueOf(3), new PoisonedValueOf(4)); |
| 33 |
}, '`new Date(1, new PoisonedValueOf(2), new PoisonedValueOf(3), new PoisonedValueOf(4))` throws a Test262Error exception'); |
| 34 |
|
| 35 |
assert.throws(Test262Error, () => { |
| 36 |
new Date(1, 2, new PoisonedValueOf(3), new PoisonedValueOf(4)); |
| 37 |
}, '`new Date(1, 2, new PoisonedValueOf(3), new PoisonedValueOf(4))` throws a Test262Error exception'); |
| 38 |
|
| 39 |
assert.throws(Test262Error, () => { |
| 40 |
new Date(1, 2, 3, new PoisonedValueOf(4)); |
| 41 |
}, '`new Date(1, 2, 3, new PoisonedValueOf(4))` throws a Test262Error exception'); |
| 42 |
|
| 43 |
reportCompare(0, 0); |