Skip to content

Commit

Permalink
Remove tests that were ported to test262
Browse files Browse the repository at this point in the history
test262 gained these tests as part of the recent batches of tests that
represented normative changes from the October and December TC39 plenary
meetings. We can now remove them from the Demitasse test suite.
  • Loading branch information
ptomato authored and justingrant committed Feb 12, 2022
1 parent e19f981 commit d7eabdd
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 219 deletions.
29 changes: 0 additions & 29 deletions polyfill/test/duration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -295,35 +295,6 @@ describe('Duration', () => {
equal(d2.toString(options), 'PT15H23M30.0000000S');
equal(d3.toString(options), 'PT15H23M30.5432000S');
});
it('pads correctly in edge cases', () => {
const d4 = Duration.from({ years: 3 });
equal(d4.toString(), 'P3Y');
equal(d4.toString({ fractionalSecondDigits: 0 }), 'P3YT0S');
equal(d4.toString({ smallestUnit: 'seconds' }), 'P3YT0S');
equal(d4.toString({ smallestUnit: 'milliseconds' }), 'P3YT0.000S');
equal(d4.toString({ fractionalSecondDigits: 5 }), 'P3YT0.00000S');

const d5 = Duration.from({ minutes: 30 });
equal(d5.toString(), 'PT30M');
equal(d5.toString({ fractionalSecondDigits: 0 }), 'PT30M0S');
equal(d5.toString({ smallestUnit: 'seconds' }), 'PT30M0S');
equal(d5.toString({ smallestUnit: 'milliseconds' }), 'PT30M0.000S');
equal(d5.toString({ fractionalSecondDigits: 5 }), 'PT30M0.00000S');

const d6 = Duration.from({ milliseconds: 100 });
equal(d6.toString(), 'PT0.1S');
equal(d6.toString({ fractionalSecondDigits: 0 }), 'PT0S');
equal(d6.toString({ smallestUnit: 'seconds' }), 'PT0S');
equal(d6.toString({ smallestUnit: 'milliseconds' }), 'PT0.100S');
equal(d6.toString({ fractionalSecondDigits: 5 }), 'PT0.10000S');

const zero = new Duration();
equal(zero.toString(), 'PT0S');
equal(zero.toString({ fractionalSecondDigits: 0 }), 'PT0S');
equal(zero.toString({ smallestUnit: 'seconds' }), 'PT0S');
equal(zero.toString({ smallestUnit: 'milliseconds' }), 'PT0.000S');
equal(zero.toString({ fractionalSecondDigits: 5 }), 'PT0.00000S');
});
it('auto is the default', () => {
[d1, d2, d3].forEach((d) => equal(d.toString({ fractionalSecondDigits: 'auto' }), d.toString()));
});
Expand Down
46 changes: 0 additions & 46 deletions polyfill/test/instant.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -351,35 +351,12 @@ describe('Instant', () => {
equal(nsDiff.microseconds, 0);
equal(nsDiff.nanoseconds, 86400250250250);
});
it('cannot return days, weeks, months, and years', () => {
throws(() => feb21.since(feb20, { largestUnit: 'days' }), RangeError);
throws(() => feb21.since(feb20, { largestUnit: 'weeks' }), RangeError);
throws(() => feb21.since(feb20, { largestUnit: 'months' }), RangeError);
throws(() => feb21.since(feb20, { largestUnit: 'years' }), RangeError);
});
it('options may only be an object or undefined', () => {
[null, 1, 'hello', true, Symbol('foo'), 1n].forEach((badOptions) =>
throws(() => feb21.since(feb20, badOptions), TypeError)
);
[{}, () => {}, undefined].forEach((options) => equal(`${feb21.since(feb20, options)}`, 'PT31622400S'));
});
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'year', 'month', 'week', 'day', 'years', 'months', 'weeks', 'days', 'nonsense'].forEach(
(smallestUnit) => {
throws(() => later.since(earlier, { smallestUnit }), RangeError);
}
);
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = ['hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds'];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => later.since(earlier, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('assumes a different default for largestUnit if smallestUnit is larger than seconds', () => {
equal(`${later.since(earlier, { smallestUnit: 'hours', roundingMode: 'halfExpand' })}`, 'PT376435H');
equal(`${later.since(earlier, { smallestUnit: 'minutes', roundingMode: 'halfExpand' })}`, 'PT22586123M');
Expand Down Expand Up @@ -606,35 +583,12 @@ describe('Instant', () => {
equal(nsDiff.microseconds, 0);
equal(nsDiff.nanoseconds, 86400250250250);
});
it('cannot return days, weeks, months, and years', () => {
throws(() => feb20.until(feb21, { largestUnit: 'days' }), RangeError);
throws(() => feb20.until(feb21, { largestUnit: 'weeks' }), RangeError);
throws(() => feb20.until(feb21, { largestUnit: 'months' }), RangeError);
throws(() => feb20.until(feb21, { largestUnit: 'years' }), RangeError);
});
it('options may only be an object or undefined', () => {
[null, 1, 'hello', true, Symbol('foo'), 1n].forEach((badOptions) =>
throws(() => feb20.until(feb21, badOptions), TypeError)
);
[{}, () => {}, undefined].forEach((options) => equal(`${feb20.until(feb21, options)}`, 'PT31622400S'));
});
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'year', 'month', 'week', 'day', 'years', 'months', 'weeks', 'days', 'nonsense'].forEach(
(smallestUnit) => {
throws(() => earlier.until(later, { smallestUnit }), RangeError);
}
);
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = ['hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds'];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => earlier.until(later, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('assumes a different default for largestUnit if smallestUnit is larger than seconds', () => {
equal(`${earlier.until(later, { smallestUnit: 'hours', roundingMode: 'halfExpand' })}`, 'PT440610H');
equal(`${earlier.until(later, { smallestUnit: 'minutes', roundingMode: 'halfExpand' })}`, 'PT26436596M');
Expand Down
52 changes: 0 additions & 52 deletions polyfill/test/plaindatetime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -526,32 +526,6 @@ describe('DateTime', () => {
});
const earlier = PlainDateTime.from('2019-01-08T08:22:36.123456789');
const later = PlainDateTime.from('2021-09-07T12:39:40.987654321');
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'nonsense'].forEach((smallestUnit) => {
throws(() => earlier.until(later, { smallestUnit }), RangeError);
});
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = [
'years',
'months',
'weeks',
'days',
'hours',
'minutes',
'seconds',
'milliseconds',
'microseconds',
'nanoseconds'
];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => earlier.until(later, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('assumes a different default for largestUnit if smallestUnit is larger than days', () => {
equal(`${earlier.until(later, { smallestUnit: 'years', roundingMode: 'halfExpand' })}`, 'P3Y');
equal(`${earlier.until(later, { smallestUnit: 'months', roundingMode: 'halfExpand' })}`, 'P32M');
Expand Down Expand Up @@ -847,32 +821,6 @@ describe('DateTime', () => {
});
const earlier = PlainDateTime.from('2019-01-08T08:22:36.123456789');
const later = PlainDateTime.from('2021-09-07T12:39:40.987654321');
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'nonsense'].forEach((smallestUnit) => {
throws(() => later.since(earlier, { smallestUnit }), RangeError);
});
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = [
'years',
'months',
'weeks',
'days',
'hours',
'minutes',
'seconds',
'milliseconds',
'microseconds',
'nanoseconds'
];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => later.since(earlier, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('assumes a different default for largestUnit if smallestUnit is larger than days', () => {
equal(`${later.since(earlier, { smallestUnit: 'years', roundingMode: 'halfExpand' })}`, 'P3Y');
equal(`${later.since(earlier, { smallestUnit: 'months', roundingMode: 'halfExpand' })}`, 'P32M');
Expand Down
40 changes: 0 additions & 40 deletions polyfill/test/plaintime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ describe('Time', () => {
equal(`${time1.until(time2, { largestUnit: 'auto' })}`, 'PT6H52M42S');
equal(`${time1.until(time2, { largestUnit: 'hours' })}`, 'PT6H52M42S');
});
it('higher units are not allowed', () => {
throws(() => time1.until(time2, { largestUnit: 'days' }), RangeError);
throws(() => time1.until(time2, { largestUnit: 'weeks' }), RangeError);
throws(() => time1.until(time2, { largestUnit: 'months' }), RangeError);
throws(() => time1.until(time2, { largestUnit: 'years' }), RangeError);
});
it('can return lower units', () => {
equal(`${time1.until(time2, { largestUnit: 'minutes' })}`, 'PT412M42S');
equal(`${time1.until(time2, { largestUnit: 'seconds' })}`, 'PT24762S');
Expand Down Expand Up @@ -83,23 +77,6 @@ describe('Time', () => {
});
const earlier = PlainTime.from('08:22:36.123456789');
const later = PlainTime.from('12:39:40.987654321');
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'years', 'months', 'weeks', 'days', 'year', 'month', 'week', 'day', 'nonsense'].forEach(
(smallestUnit) => {
throws(() => earlier.until(later, { smallestUnit }), RangeError);
}
);
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = ['hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds'];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => earlier.until(later, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('throws on invalid roundingMode', () => {
throws(() => earlier.until(later, { roundingMode: 'cile' }), RangeError);
});
Expand Down Expand Up @@ -351,23 +328,6 @@ describe('Time', () => {
});
const earlier = PlainTime.from('08:22:36.123456789');
const later = PlainTime.from('12:39:40.987654321');
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'years', 'months', 'weeks', 'days', 'year', 'month', 'week', 'day', 'nonsense'].forEach(
(smallestUnit) => {
throws(() => later.since(earlier, { smallestUnit }), RangeError);
}
);
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = ['hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds'];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => later.since(earlier, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('throws on invalid roundingMode', () => {
throws(() => later.since(earlier, { roundingMode: 'cile' }), RangeError);
});
Expand Down
52 changes: 0 additions & 52 deletions polyfill/test/zoneddatetime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,32 +1394,6 @@ describe('ZonedDateTime', () => {
});
const earlier = ZonedDateTime.from('2019-01-08T09:22:36.123456789+01:00[Europe/Vienna]');
const later = ZonedDateTime.from('2021-09-07T14:39:40.987654321+02:00[Europe/Vienna]');
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'nonsense'].forEach((smallestUnit) => {
throws(() => earlier.until(later, { smallestUnit }), RangeError);
});
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = [
'years',
'months',
'weeks',
'days',
'hours',
'minutes',
'seconds',
'milliseconds',
'microseconds',
'nanoseconds'
];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => earlier.until(later, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('assumes a different default for largestUnit if smallestUnit is larger than hours', () => {
equal(`${earlier.until(later, { smallestUnit: 'years', roundingMode: 'halfExpand' })}`, 'P3Y');
equal(`${earlier.until(later, { smallestUnit: 'months', roundingMode: 'halfExpand' })}`, 'P32M');
Expand Down Expand Up @@ -1738,32 +1712,6 @@ describe('ZonedDateTime', () => {
});
const earlier = ZonedDateTime.from('2019-01-08T09:22:36.123456789+01:00[Europe/Vienna]');
const later = ZonedDateTime.from('2021-09-07T14:39:40.987654321+02:00[Europe/Vienna]');
it('throws on disallowed or invalid smallestUnit', () => {
['era', 'nonsense'].forEach((smallestUnit) => {
throws(() => later.since(earlier, { smallestUnit }), RangeError);
});
});
it('throws if smallestUnit is larger than largestUnit', () => {
const units = [
'years',
'months',
'weeks',
'days',
'hours',
'minutes',
'seconds',
'milliseconds',
'microseconds',
'nanoseconds'
];
for (let largestIdx = 1; largestIdx < units.length; largestIdx++) {
for (let smallestIdx = 0; smallestIdx < largestIdx; smallestIdx++) {
const largestUnit = units[largestIdx];
const smallestUnit = units[smallestIdx];
throws(() => later.since(earlier, { largestUnit, smallestUnit }), RangeError);
}
}
});
it('assumes a different default for largestUnit if smallestUnit is larger than days', () => {
equal(`${later.since(earlier, { smallestUnit: 'years', roundingMode: 'halfExpand' })}`, 'P3Y');
equal(`${later.since(earlier, { smallestUnit: 'months', roundingMode: 'halfExpand' })}`, 'P32M');
Expand Down

0 comments on commit d7eabdd

Please sign in to comment.