~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/js1_5/Date/regress-301738-02.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* This Source Code Form is subject to the terms of the Mozilla Public
 
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
5
 
 
6
//-----------------------------------------------------------------------------
 
7
var BUGNUMBER = 301738;
 
8
var summary = 'Date parse compatibilty with MSIE';
 
9
var actual = '';
 
10
var expect = '';
 
11
 
 
12
printBugNumber(BUGNUMBER);
 
13
printStatus (summary);
 
14
 
 
15
/* 
 
16
    Case 2. The input string is of the form "f/m/l" where f, m and l are
 
17
    integers, e.g. 7/16/45.
 
18
    Adjust the mon, mday and year values to achieve 100% MSIE
 
19
    compatibility.
 
20
    a. If 0 <= f < 70, f/m/l is interpreted as month/day/year.
 
21
    i.  If year < 100, it is the number of years after 1900
 
22
    ii. If year >= 100, it is the number of years after 0.
 
23
    b. If 70 <= f < 100
 
24
    i.  If m < 70, f/m/l is interpreted as
 
25
    year/month/day where year is the number of years after
 
26
    1900.
 
27
    ii. If m >= 70, the date is invalid.
 
28
    c. If f >= 100
 
29
    i.  If m < 70, f/m/l is interpreted as
 
30
    year/month/day where year is the number of years after 0.
 
31
    ii. If m >= 70, the date is invalid.
 
32
*/
 
33
 
 
34
var f;
 
35
var m;
 
36
var l;
 
37
 
 
38
function newDate(f, m, l)
 
39
{
 
40
  return new Date(f + '/' + m + '/' + l);
 
41
}
 
42
 
 
43
function newDesc(f, m, l)
 
44
{
 
45
  return f + '/' + m + '/' + l;
 
46
}
 
47
 
 
48
// 2.a.i
 
49
f = 0;
 
50
m = 0;
 
51
l = 0;
 
52
 
 
53
expect = (new Date(l, f-1, m)).toDateString();
 
54
actual = newDate(f, m, l).toDateString();
 
55
reportCompare(expect, actual, newDesc(f, m, l));
 
56
 
 
57
f = 0;
 
58
m = 0;
 
59
l = 100;
 
60
 
 
61
expect = (new Date(l, f-1, m)).toDateString();
 
62
actual = newDate(f, m, l).toDateString();
 
63
reportCompare(expect, actual, newDesc(f, m, l));
 
64
 
 
65
// 2.a.ii
 
66
f = 0;
 
67
m = 24;
 
68
l = 100;
 
69
 
 
70
expect = (new Date(l, f-1, m)).toDateString();
 
71
actual = newDate(f, m, l).toDateString();
 
72
reportCompare(expect, actual, newDesc(f, m, l));
 
73
 
 
74
f = 0;
 
75
m = 24;
 
76
l = 2100;
 
77
 
 
78
expect = (new Date(l, f-1, m)).toDateString();
 
79
actual = newDate(f, m, l).toDateString();
 
80
reportCompare(expect, actual, newDesc(f, m, l));
 
81
 
 
82
 
 
83
// 2.b.i
 
84
f = 70;
 
85
m = 24;
 
86
l = 100;
 
87
 
 
88
expect = (new Date(f, m-1, l)).toDateString();
 
89
actual = newDate(f, m, l).toDateString();
 
90
reportCompare(expect, actual, newDesc(f, m, l));
 
91
 
 
92
f = 99;
 
93
m = 12;
 
94
l = 1;
 
95
 
 
96
expect = (new Date(f, m-1, l)).toDateString();
 
97
actual = newDate(f, m, l).toDateString();
 
98
reportCompare(expect, actual, newDesc(f, m, l));
 
99
 
 
100
// 2.b.ii.
 
101
 
 
102
f = 99;
 
103
m = 70;
 
104
l = 1;
 
105
 
 
106
expect = true;
 
107
actual = isNaN(newDate(f, m, l));
 
108
reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
 
109
 
 
110
// 2.c.i
 
111
 
 
112
f = 100;
 
113
m = 12;
 
114
l = 1;
 
115
 
 
116
expect = (new Date(f, m-1, l)).toDateString();
 
117
actual = newDate(f, m, l).toDateString();
 
118
reportCompare(expect, actual, newDesc(f, m, l));
 
119
 
 
120
// 2.c.ii
 
121
 
 
122
f = 100;
 
123
m = 70;
 
124
l = 1;
 
125
 
 
126
expect = true;
 
127
actual = isNaN(newDate(f, m, l));
 
128
reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
 
129
 
 
130