author | sundar |
Wed, 06 May 2015 20:04:42 +0530 | |
changeset 30394 | 72a59e4dffea |
parent 24778 | 2ff5d7041566 |
permissions | -rw-r--r-- |
17251
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
1 |
/* |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
4 |
* |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
8 |
* |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
14 |
* |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
18 |
* |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
21 |
* questions. |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
22 |
*/ |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
23 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
24 |
/** |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
17251
diff
changeset
|
25 |
* JDK-8013337: Issues with Date.prototype's get, set functions |
17251
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
26 |
* |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
27 |
* @test |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
28 |
* @option -timezone=Asia/Calcutta |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
29 |
* @run |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
30 |
*/ |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
31 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
32 |
function check(str) { |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
33 |
print(str + " = " + eval(str)); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
34 |
} |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
35 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
36 |
check('new Date(NaN).setFullYear(NaN)'); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
37 |
check('new Date(0).setYear(70)'); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
38 |
check('new Date(0).setYear(NaN)'); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
39 |
check('new Date(NaN).setYear(70)'); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
40 |
check('new Date(NaN).getTimezoneOffset()'); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
41 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
42 |
function checkGetterCalled(func) { |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
43 |
var getterCalled = false; |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
44 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
45 |
new Date(NaN)[func]( { valueOf: function() { getterCalled = true } } ); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
46 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
47 |
if (getterCalled) { |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
48 |
print("Date.prototype." + func + " calls valueOf on arg"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
49 |
} |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
50 |
} |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
51 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
52 |
checkGetterCalled("setMilliseconds"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
53 |
checkGetterCalled("setUTCMilliseconds"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
54 |
checkGetterCalled("setSeconds"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
55 |
checkGetterCalled("setUTCSeconds"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
56 |
checkGetterCalled("setMinutes"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
57 |
checkGetterCalled("setUTCMinutes"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
58 |
checkGetterCalled("setHours"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
59 |
checkGetterCalled("setUTCHours"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
60 |
checkGetterCalled("setDate"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
61 |
checkGetterCalled("setUTCDate"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
62 |
checkGetterCalled("setMonth"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
63 |
checkGetterCalled("setUTCMonth"); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
64 |
|
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
65 |
try { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
17251
diff
changeset
|
66 |
Date.prototype.setTime.call({}, { valueOf: function() { throw "err" } }) |
17251
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
67 |
} catch (e) { |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
68 |
if (! (e instanceof TypeError)) { |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
69 |
fail("TypeError expected, got " + e); |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
70 |
} |
444648345fa6
8013337: Issues with Date.prototype's get, set functions
sundar
parents:
diff
changeset
|
71 |
} |