summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/Date/prototype/setYear/year-number-absolute.js
blob: 61cc1d91a33701ca2276e80c6740724848ce0cca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-date.prototype.setyear
es6id: B.2.4.2
es5id: B.2.5
description: >
    Behavior when the integer representation of the specified `year` is not
    relative to 1900
info: |
    [...]
    5. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yyyy be ToInteger(y) +
       1900.
    6. Else, let yyyy be y.
    [...]
---*/

var date;

date = new Date(1970, 0);
date.setYear(-1);
assert.sameValue(date.getFullYear(), -1);

date = new Date(1970, 0);
date.setYear(100);
assert.sameValue(date.getFullYear(), 100);

date = new Date(1970, 0);
date.setYear(1899);
assert.sameValue(date.getFullYear(), 1899);

date = new Date(1970, 0);
date.setYear(1900);
assert.sameValue(date.getFullYear(), 1900);

date = new Date(1970, 0);
date.setYear(1999);
assert.sameValue(date.getFullYear(), 1999);

date = new Date(1970, 0);
date.setYear(2000);
assert.sameValue(date.getFullYear(), 2000);

reportCompare(0, 0);