Skip to content

Commit 0f525d9

Browse files
jessealama12wrigja
authored andcommitted
Drop from tests ported to Test262
UPSTREAM_COMMIT=f6f920b3fdaa5bd795f8a9b777b75d060740196d
1 parent 6bcd95b commit 0f525d9

File tree

2 files changed

+2
-124
lines changed

2 files changed

+2
-124
lines changed

test/plaindatetime.mjs

Lines changed: 1 addition & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -12,134 +12,12 @@ import Pretty from '@pipobscure/demitasse-pretty';
1212
const { reporter } = Pretty;
1313

1414
import { strict as assert } from 'assert';
15-
const { equal, notEqual, throws } = assert;
15+
const { equal, throws } = assert;
1616

1717
import * as Temporal from '@js-temporal/polyfill';
1818
const { PlainDateTime } = Temporal;
1919

2020
describe('DateTime', () => {
21-
describe('DateTime.from() works', () => {
22-
it('DateTime.from("1976-11-18 15:23:30")', () =>
23-
equal(`${PlainDateTime.from('1976-11-18 15:23:30')}`, '1976-11-18T15:23:30'));
24-
it('DateTime.from("1976-11-18 15:23:30.001")', () =>
25-
equal(`${PlainDateTime.from('1976-11-18 15:23:30.001')}`, '1976-11-18T15:23:30.001'));
26-
it('DateTime.from("1976-11-18 15:23:30.001123")', () =>
27-
equal(`${PlainDateTime.from('1976-11-18 15:23:30.001123')}`, '1976-11-18T15:23:30.001123'));
28-
it('DateTime.from("1976-11-18 15:23:30.001123456")', () =>
29-
equal(`${PlainDateTime.from('1976-11-18 15:23:30.001123456')}`, '1976-11-18T15:23:30.001123456'));
30-
it('DateTime.from(1976-11-18) is not the same object', () => {
31-
const orig = new PlainDateTime(1976, 11, 18, 15, 23, 20, 123, 456, 789);
32-
const actual = PlainDateTime.from(orig);
33-
notEqual(actual, orig);
34-
});
35-
it('DateTime.from({ year: 1976, month: 11, day: 18 }) == 1976-11-18T00:00:00', () =>
36-
equal(`${PlainDateTime.from({ year: 1976, month: 11, monthCode: 'M11', day: 18 })}`, '1976-11-18T00:00:00'));
37-
it('can be constructed with month and without monthCode', () =>
38-
equal(`${PlainDateTime.from({ year: 1976, month: 11, day: 18 })}`, '1976-11-18T00:00:00'));
39-
it('can be constructed with monthCode and without month', () =>
40-
equal(`${PlainDateTime.from({ year: 1976, monthCode: 'M11', day: 18 })}`, '1976-11-18T00:00:00'));
41-
it('month and monthCode must agree', () =>
42-
throws(() => PlainDateTime.from({ year: 1976, month: 11, monthCode: 'M12', day: 18 }), RangeError));
43-
it('DateTime.from({ year: 1976, month: 11, day: 18, millisecond: 123 }) == 1976-11-18T00:00:00.123', () =>
44-
equal(`${PlainDateTime.from({ year: 1976, month: 11, day: 18, millisecond: 123 })}`, '1976-11-18T00:00:00.123'));
45-
it('DateTime.from({ year: 1976, day: 18, hour: 15, minute: 23, second: 30, millisecond: 123 }) throws', () =>
46-
throws(
47-
() => PlainDateTime.from({ year: 1976, day: 18, hour: 15, minute: 23, second: 30, millisecond: 123 }),
48-
TypeError
49-
));
50-
it('DateTime.from({}) throws', () => throws(() => PlainDateTime.from({}), TypeError));
51-
it('DateTime.from(required prop undefined) throws', () =>
52-
throws(() => PlainDateTime.from({ year: 1976, month: undefined, monthCode: undefined, day: 18 }), TypeError));
53-
it('DateTime.from(ISO string leap second) is constrained', () => {
54-
equal(`${PlainDateTime.from('2016-12-31T23:59:60')}`, '2016-12-31T23:59:59');
55-
});
56-
it('DateTime.from(number) is converted to string', () =>
57-
assert(PlainDateTime.from(19761118).equals(PlainDateTime.from('19761118'))));
58-
describe('Overflow', () => {
59-
const bad = { year: 2019, month: 1, day: 32 };
60-
it('reject', () => throws(() => PlainDateTime.from(bad, { overflow: 'reject' }), RangeError));
61-
it('constrain', () => {
62-
equal(`${PlainDateTime.from(bad)}`, '2019-01-31T00:00:00');
63-
equal(`${PlainDateTime.from(bad, { overflow: 'constrain' })}`, '2019-01-31T00:00:00');
64-
});
65-
it('throw when bad overflow', () => {
66-
[new PlainDateTime(1976, 11, 18, 15, 23), { year: 2019, month: 1, day: 1 }, '2019-01-31T00:00'].forEach(
67-
(input) => {
68-
['', 'CONSTRAIN', 'balance', 3, null].forEach((overflow) =>
69-
throws(() => PlainDateTime.from(input, { overflow }), RangeError)
70-
);
71-
}
72-
);
73-
});
74-
const leap = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 };
75-
it('reject leap second', () => throws(() => PlainDateTime.from(leap, { overflow: 'reject' }), RangeError));
76-
it('constrain leap second', () => equal(`${PlainDateTime.from(leap)}`, '2016-12-31T23:59:59'));
77-
it('constrain has no effect on invalid ISO string', () => {
78-
throws(() => PlainDateTime.from('2020-13-34T24:60', { overflow: 'constrain' }), RangeError);
79-
});
80-
});
81-
it('Z not supported', () => {
82-
throws(() => PlainDateTime.from('2019-10-01T09:00:00Z'), RangeError);
83-
throws(() => PlainDateTime.from('2019-10-01T09:00:00Z[Europe/Berlin]'), RangeError);
84-
});
85-
it('variant time separators', () => {
86-
equal(`${PlainDateTime.from('1976-11-18t15:23')}`, '1976-11-18T15:23:00');
87-
equal(`${PlainDateTime.from('1976-11-18 15:23')}`, '1976-11-18T15:23:00');
88-
});
89-
it('any number of decimal places', () => {
90-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.1')}`, '1976-11-18T15:23:30.1');
91-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.12')}`, '1976-11-18T15:23:30.12');
92-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.123')}`, '1976-11-18T15:23:30.123');
93-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.1234')}`, '1976-11-18T15:23:30.1234');
94-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.12345')}`, '1976-11-18T15:23:30.12345');
95-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.123456')}`, '1976-11-18T15:23:30.123456');
96-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.1234567')}`, '1976-11-18T15:23:30.1234567');
97-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.12345678')}`, '1976-11-18T15:23:30.12345678');
98-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.123456789')}`, '1976-11-18T15:23:30.123456789');
99-
});
100-
it('variant decimal separator', () => {
101-
equal(`${PlainDateTime.from('1976-11-18T15:23:30,12')}`, '1976-11-18T15:23:30.12');
102-
});
103-
it('variant minus sign', () => {
104-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.12\u221202:00')}`, '1976-11-18T15:23:30.12');
105-
equal(`${PlainDateTime.from('\u2212009999-11-18T15:23:30.12')}`, '-009999-11-18T15:23:30.12');
106-
});
107-
it('mixture of basic and extended format', () => {
108-
equal(`${PlainDateTime.from('1976-11-18T152330.1+00:00')}`, '1976-11-18T15:23:30.1');
109-
equal(`${PlainDateTime.from('19761118T15:23:30.1+00:00')}`, '1976-11-18T15:23:30.1');
110-
equal(`${PlainDateTime.from('1976-11-18T15:23:30.1+0000')}`, '1976-11-18T15:23:30.1');
111-
equal(`${PlainDateTime.from('1976-11-18T152330.1+0000')}`, '1976-11-18T15:23:30.1');
112-
equal(`${PlainDateTime.from('19761118T15:23:30.1+0000')}`, '1976-11-18T15:23:30.1');
113-
equal(`${PlainDateTime.from('19761118T152330.1+00:00')}`, '1976-11-18T15:23:30.1');
114-
equal(`${PlainDateTime.from('19761118T152330.1+0000')}`, '1976-11-18T15:23:30.1');
115-
equal(`${PlainDateTime.from('+001976-11-18T152330.1+00:00')}`, '1976-11-18T15:23:30.1');
116-
equal(`${PlainDateTime.from('+0019761118T15:23:30.1+00:00')}`, '1976-11-18T15:23:30.1');
117-
equal(`${PlainDateTime.from('+001976-11-18T15:23:30.1+0000')}`, '1976-11-18T15:23:30.1');
118-
equal(`${PlainDateTime.from('+001976-11-18T152330.1+0000')}`, '1976-11-18T15:23:30.1');
119-
equal(`${PlainDateTime.from('+0019761118T15:23:30.1+0000')}`, '1976-11-18T15:23:30.1');
120-
equal(`${PlainDateTime.from('+0019761118T152330.1+00:00')}`, '1976-11-18T15:23:30.1');
121-
equal(`${PlainDateTime.from('+0019761118T152330.1+0000')}`, '1976-11-18T15:23:30.1');
122-
});
123-
it('optional parts', () => {
124-
equal(`${PlainDateTime.from('1976-11-18T15:23:30+00')}`, '1976-11-18T15:23:30');
125-
equal(`${PlainDateTime.from('1976-11-18T15')}`, '1976-11-18T15:00:00');
126-
equal(`${PlainDateTime.from('1976-11-18')}`, '1976-11-18T00:00:00');
127-
});
128-
it('no junk at end of string', () =>
129-
throws(() => PlainDateTime.from('1976-11-18T15:23:30.123456789junk'), RangeError));
130-
it('ignores if a timezone is specified', () =>
131-
equal(`${PlainDateTime.from('2020-01-01T01:23:45[Asia/Kolkata]')}`, '2020-01-01T01:23:45'));
132-
it('options may be a function object', () => {
133-
equal(`${PlainDateTime.from({ year: 1976, month: 11, day: 18 }, () => {})}`, '1976-11-18T00:00:00');
134-
});
135-
it('object must contain at least the required correctly-spelled properties', () => {
136-
throws(() => PlainDateTime.from({}), TypeError);
137-
throws(() => PlainDateTime.from({ year: 1976, months: 11, day: 18 }), TypeError);
138-
});
139-
it('incorrectly-spelled properties are ignored', () => {
140-
equal(`${PlainDateTime.from({ year: 1976, month: 11, day: 18, hours: 12 })}`, '1976-11-18T00:00:00');
141-
});
142-
});
14321
describe('DateTime.toZonedDateTime()', () => {
14422
it('works', () => {
14523
const dt = Temporal.PlainDateTime.from('2020-01-01T00:00');

0 commit comments

Comments
 (0)