| 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 |
es5id: 15.9.3.1_A4_T5 |
| 17 |
description: 6 arguments, (year, month, date, hours, minutes, seconds) |
| 18 |
---*/ |
| 19 |
|
| 20 |
var myObj = function(val) { |
| 21 |
this.value = val; |
| 22 |
this.valueOf = function() { |
| 23 |
throw "valueOf-" + this.value; |
| 24 |
}; |
| 25 |
this.toString = function() { |
| 26 |
throw "toString-" + this.value; |
| 27 |
}; |
| 28 |
}; |
| 29 |
|
| 30 |
//CHECK#1 |
| 31 |
try { |
| 32 |
var x1 = new Date(new myObj(1), new myObj(2), new myObj(3), new myObj(4), new myObj(5), new myObj(6)); |
| 33 |
$ERROR("#1: The 1st step is calling ToNumber(year)"); |
| 34 |
} |
| 35 |
catch (e) { |
| 36 |
if (e !== "valueOf-1") { |
| 37 |
$ERROR("#1: The 1st step is calling ToNumber(year)"); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
//CHECK#2 |
| 42 |
try { |
| 43 |
var x2 = new Date(1, new myObj(2), new myObj(3), new myObj(4), new myObj(5), new myObj(6)); |
| 44 |
$ERROR("#2: The 2nd step is calling ToNumber(month)"); |
| 45 |
} |
| 46 |
catch (e) { |
| 47 |
if (e !== "valueOf-2") { |
| 48 |
$ERROR("#2: The 2nd step is calling ToNumber(month)"); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
//CHECK#3 |
| 53 |
try { |
| 54 |
var x3 = new Date(1, 2, new myObj(3), new myObj(4), new myObj(5), new myObj(6)); |
| 55 |
$ERROR("#3: The 3rd step is calling ToNumber(date)"); |
| 56 |
} |
| 57 |
catch (e) { |
| 58 |
if (e !== "valueOf-3") { |
| 59 |
$ERROR("#3: The 3rd step is calling ToNumber(date)"); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
//CHECK#4 |
| 64 |
try { |
| 65 |
var x4 = new Date(1, 2, 3, new myObj(4), new myObj(5), new myObj(6)); |
| 66 |
$ERROR("#4: The 4th step is calling ToNumber(hours)"); |
| 67 |
} |
| 68 |
catch (e) { |
| 69 |
if (e !== "valueOf-4") { |
| 70 |
$ERROR("#4: The 4th step is calling ToNumber(hours)"); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
//CHECK#5 |
| 75 |
try { |
| 76 |
var x5 = new Date(1, 2, 3, 4, new myObj(5), new myObj(6)); |
| 77 |
$ERROR("#5: The 5th step is calling ToNumber(minutes)"); |
| 78 |
} |
| 79 |
catch (e) { |
| 80 |
if (e !== "valueOf-5") { |
| 81 |
$ERROR("#5: The 5th step is calling ToNumber(minutes)"); |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
//CHECK#6 |
| 86 |
try { |
| 87 |
var x6 = new Date(1, 2, 3, 4, 5, new myObj(6)); |
| 88 |
$ERROR("#6: The 6th step is calling ToNumber(seconds)"); |
| 89 |
} |
| 90 |
catch (e) { |
| 91 |
if (e !== "valueOf-6") { |
| 92 |
$ERROR("#6: The 6th step is calling ToNumber(seconds)"); |
| 93 |
} |
| 94 |
} |