Debian Codegraph @

js/src/tests/test262/built-ins/Date/shell.js

raw
1 // GENERATED, DO NOT EDIT
2 // file: assertRelativeDateMs.js
3 // Copyright (C) 2015 the V8 project authors. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 description: |
7 Verify that the given date object's Number representation describes the
8 correct number of milliseconds since the Unix epoch relative to the local
9 time zone (as interpreted at the specified date).
10 defines: [assertRelativeDateMs]
11 ---*/
12
13 /**
14 * @param {Date} date
15 * @param {Number} expectedMs
16 */
17 function assertRelativeDateMs(date, expectedMs) {
18 var actualMs = date.valueOf();
19 var localOffset = date.getTimezoneOffset() * 60000;
20
21 if (actualMs - localOffset !== expectedMs) {
22 throw new Test262Error(
23 'Expected ' + date + ' to be ' + expectedMs +
24 ' milliseconds from the Unix epoch'
25 );
26 }
27 }
28
29 // file: dateConstants.js
30 // Copyright (C) 2009 the Sputnik authors. All rights reserved.
31 // This code is governed by the BSD license found in the LICENSE file.
32 /*---
33 description: |
34 Collection of date-centric values
35 defines:
36 - date_1899_end
37 - date_1900_start
38 - date_1969_end
39 - date_1970_start
40 - date_1999_end
41 - date_2000_start
42 - date_2099_end
43 - date_2100_start
44 - start_of_time
45 - end_of_time
46 ---*/
47
48 var date_1899_end = -2208988800001;
49 var date_1900_start = -2208988800000;
50 var date_1969_end = -1;
51 var date_1970_start = 0;
52 var date_1999_end = 946684799999;
53 var date_2000_start = 946684800000;
54 var date_2099_end = 4102444799999;
55 var date_2100_start = 4102444800000;
56
57 var start_of_time = -8.64e15;
58 var end_of_time = 8.64e15;
59
60 // file: isConstructor.js
61 // Copyright (C) 2017 André Bargull. All rights reserved.
62 // This code is governed by the BSD license found in the LICENSE file.
63
64 /*---
65 description: |
66 Test if a given function is a constructor function.
67 defines: [isConstructor]
68 features: [Reflect.construct]
69 ---*/
70
71 function isConstructor(f) {
72 if (typeof f !== "function") {
73 throw new Test262Error("isConstructor invoked with a non-function value");
74 }
75
76 try {
77 Reflect.construct(function(){}, [], f);
78 } catch (e) {
79 return false;
80 }
81 return true;
82 }