Skip to content

Commit

Permalink
fixup! polyfill: update tests regarding from lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
ryzokuken committed Mar 6, 2021
1 parent 0f4c922 commit ba3dbd9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 290 deletions.
164 changes: 0 additions & 164 deletions polyfill/test/usercalendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -139,88 +139,6 @@ describe('Userland calendar', () => {
const nowDate = Temporal.now.plainDate(obj, 'UTC');
equal(nowDate.calendar.id, obj.id);
});
// describe('Making available globally', () => {
// const originalTemporalCalendarFrom = Temporal.Calendar.from;
// before(() => {
// Temporal.Calendar.from = function (item) {
// let id;
// if (item instanceof Temporal.Calendar) {
// id = item.id;
// } else {
// id = `${item}`;
// // TODO: Use Temporal.parse here to extract the ID from an ISO string
// }
// if (id === 'two-based') return new TwoBasedCalendar();
// return originalTemporalCalendarFrom.call(this, id);
// };
// });
// it('works for Calendar.from(id)', () => {
// const tz = Temporal.Calendar.from('two-based');
// assert(tz instanceof TwoBasedCalendar);
// });
// const iso = '1970-01-01T00:00+00:00[u-ca-two-based]';
// it.skip('works for Calendar.from(ISO string)', () => {
// const tz = Temporal.Calendar.from(iso);
// assert(tz instanceof TwoBasedCalendar);
// });
// it('works for Date.from(iso)', () => {
// const d = Temporal.PlainDate.from(iso);
// equal(`${d}`, '1970-01-01[u-ca-two-based]');
// });
// it('works for Date.from(props)', () => {
// const d = Temporal.PlainDate.from({ year: 1970, month: 2, day: 1, calendar: 'two-based' });
// equal(`${d}`, '1970-01-01[u-ca-two-based]');
// });
// it('works for Date.withCalendar', () => {
// const d = Temporal.PlainDate.from('1970-01-01');
// assert(d.withCalendar('two-based').equals(Temporal.PlainDate.from(iso)));
// });
// it('works for DateTime.from(iso)', () => {
// const dt = Temporal.PlainDateTime.from(iso);
// equal(`${dt}`, '1970-01-01T00:00:00[u-ca-two-based]');
// });
// it('works for DateTime.from(props)', () => {
// const dt = Temporal.PlainDateTime.from({ year: 1970, month: 2, day: 1, hour: 12, calendar: 'two-based' });
// equal(`${dt}`, '1970-01-01T12:00:00[u-ca-two-based]');
// });
// it('works for DateTime.withCalendar', () => {
// const dt = Temporal.PlainDateTime.from('1970-01-01T00:00');
// assert(dt.withCalendar('two-based').equals(Temporal.PlainDateTime.from(iso)));
// });
// it('works for YearMonth.from(iso)', () => {
// const ym = Temporal.PlainYearMonth.from(iso);
// equal(`${ym}`, '1970-01-01[u-ca-two-based]');
// });
// it('works for YearMonth.from(props)', () => {
// const ym = Temporal.PlainYearMonth.from({ year: 1970, month: 2, calendar: 'two-based' });
// equal(`${ym}`, '1970-01-01[u-ca-two-based]');
// });
// it('works for MonthDay.from(iso)', () => {
// const md = Temporal.PlainMonthDay.from(iso);
// equal(`${md}`, '1972-01-01[u-ca-two-based]');
// });
// it('works for MonthDay.from(props)', () => {
// const md = Temporal.PlainMonthDay.from({ monthCode: 'M02', day: 1, calendar: 'two-based' });
// equal(`${md}`, '1972-01-01[u-ca-two-based]');
// });
// it('works for TimeZone.getPlainDateTimeFor', () => {
// const tz = Temporal.TimeZone.from('UTC');
// const inst = Temporal.Instant.fromEpochSeconds(0);
// const dt = tz.getPlainDateTimeFor(inst, 'two-based');
// equal(dt.calendar.id, 'two-based');
// });
// it('works for Temporal.now.plainDateTime', () => {
// const nowDateTime = Temporal.now.plainDateTime('two-based', 'UTC');
// equal(nowDateTime.calendar.id, 'two-based');
// });
// it('works for Temporal.now.plainDate', () => {
// const nowDate = Temporal.now.plainDate('two-based', 'UTC');
// equal(nowDate.calendar.id, 'two-based');
// });
// after(() => {
// Temporal.Calendar.from = originalTemporalCalendarFrom;
// });
// });
});
describe('Trivial protocol implementation', () => {
// For the purposes of testing, a nonsensical calendar that has 10-month
Expand Down Expand Up @@ -367,88 +285,6 @@ describe('Userland calendar', () => {
const nowDate = Temporal.now.plainDate(obj, 'UTC');
equal(nowDate.calendar.id, obj.id);
});
// describe('Making available globally', () => {
// const originalTemporalCalendarFrom = Temporal.Calendar.from;
// before(() => {
// Temporal.Calendar.from = function (item) {
// let id;
// if (typeof item === 'object' && item) {
// id = item.id;
// } else {
// id = `${item}`;
// // TODO: Use Temporal.parse here to extract the ID from an ISO string
// }
// if (id === 'decimal') return obj;
// return originalTemporalCalendarFrom.call(this, id);
// };
// });
// it('works for Calendar.from(id)', () => {
// const cal = Temporal.Calendar.from('decimal');
// assert(Object.is(cal, obj));
// });
// const iso = '1970-01-01T00:00+00:00[u-ca-decimal]';
// it.skip('works for Calendar.from(ISO string)', () => {
// const cal = Temporal.Calendar.from(iso);
// assert(Object.is(cal, obj));
// });
// it('works for Date.from(iso)', () => {
// const d = Temporal.PlainDate.from(iso);
// equal(`${d}`, '1970-01-01[u-ca-decimal]');
// });
// it('works for Date.from(props)', () => {
// const d = Temporal.PlainDate.from({ year: 0, month: 1, day: 1, calendar: 'decimal' });
// equal(`${d}`, '1970-01-01[u-ca-decimal]');
// });
// it('works for Date.withCalendar', () => {
// const d = Temporal.PlainDate.from('1970-01-01');
// assert(d.withCalendar('decimal').equals(Temporal.PlainDate.from(iso)));
// });
// it('works for DateTime.from(iso)', () => {
// const dt = Temporal.PlainDateTime.from(iso);
// equal(`${dt}`, '1970-01-01T00:00:00[u-ca-decimal]');
// });
// it('works for DateTime.from(props)', () => {
// const dt = Temporal.PlainDateTime.from({ year: 0, month: 1, day: 1, hour: 12, calendar: 'decimal' });
// equal(`${dt}`, '1970-01-01T12:00:00[u-ca-decimal]');
// });
// it('works for DateTime.withCalendar', () => {
// const dt = Temporal.PlainDateTime.from('1970-01-01T00:00');
// assert(dt.withCalendar('decimal').equals(Temporal.PlainDateTime.from(iso)));
// });
// it('works for YearMonth.from(iso)', () => {
// const ym = Temporal.PlainYearMonth.from(iso);
// equal(`${ym}`, '1970-01-01[u-ca-decimal]');
// });
// it('works for YearMonth.from(props)', () => {
// const ym = Temporal.PlainYearMonth.from({ year: 0, month: 1, calendar: 'decimal' });
// equal(`${ym}`, '1970-01-01[u-ca-decimal]');
// });
// it('works for MonthDay.from(iso)', () => {
// const md = Temporal.PlainMonthDay.from(iso);
// equal(`${md}`, '1970-01-01[u-ca-decimal]');
// });
// it('works for MonthDay.from(props)', () => {
// const md = Temporal.PlainMonthDay.from({ monthCode: 'M01', day: 1, calendar: 'decimal' });
// equal(`${md}`, '1970-01-01[u-ca-decimal]');
// });
// it('works for TimeZone.getPlainDateTimeFor', () => {
// const tz = Temporal.TimeZone.from('UTC');
// const inst = Temporal.Instant.fromEpochSeconds(0);
// const dt = tz.getPlainDateTimeFor(inst, 'decimal');
// equal(`${dt.calendar}`, 'decimal');
// });
// it('works for Temporal.now.plainDateTime', () => {
// const nowDateTime = Temporal.now.plainDateTime('decimal', 'UTC');
// equal(`${nowDateTime.calendar}`, 'decimal');
// });
// it('works for Temporal.now.plainDate', () => {
// const nowDate = Temporal.now.plainDate('decimal', 'UTC');
// equal(`${nowDate.calendar}`, 'decimal');
// });
// after(() => {
// Temporal.Calendar.from = originalTemporalCalendarFrom;
// });
// });
});
describe('calendar with extra fields', () => {
// Contrived example of a calendar identical to the ISO calendar except that
Expand Down
126 changes: 0 additions & 126 deletions polyfill/test/usertimezone.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,48 +75,6 @@ describe('Userland time zone', () => {
assert(Temporal.now.plainDate('gregory', obj) instanceof Temporal.PlainDate);
assert(Temporal.now.plainTimeISO(obj) instanceof Temporal.PlainTime);
});
// describe('Making available globally', () => {
// const originalTemporalTimeZoneFrom = Temporal.TimeZone.from;
// before(() => {
// Temporal.TimeZone.from = function (item) {
// let id;
// if (item instanceof Temporal.TimeZone) {
// id = item.id;
// } else {
// id = `${item}`;
// // TODO: Use Temporal.parse here to extract the ID from an ISO string
// }
// if (id === 'Etc/Custom/UTC_Subclass') return new CustomUTCSubclass();
// return originalTemporalTimeZoneFrom.call(this, id);
// };
// });
// it('works for TimeZone.from(id)', () => {
// const tz = Temporal.TimeZone.from('Etc/Custom/UTC_Subclass');
// assert(tz instanceof CustomUTCSubclass);
// });
// it.skip('works for TimeZone.from(ISO string)', () => {
// const tz = Temporal.TimeZone.from('1970-01-01T00:00+00:00[Etc/Custom/UTC_Subclass]');
// assert(tz instanceof CustomUTCSubclass);
// });
// it('works for Instant.from', () => {
// const instant = Temporal.Instant.from('1970-01-01T00:00+00:00[Etc/Custom/UTC_Subclass]');
// equal(`${instant}`, '1970-01-01T00:00:00Z');
// });
// it('works for Instant.toString', () => {
// const inst = Temporal.Instant.fromEpochSeconds(0);
// equal(inst.toString({ timeZone: 'Etc/Custom/UTC_Subclass' }), '1970-01-01T00:00:00+00:00');
// });
// it('works for Temporal.now', () => {
// assert(Temporal.now.plainDateTimeISO('Etc/Custom/UTC_Subclass') instanceof Temporal.PlainDateTime);
// assert(Temporal.now.plainDateTime('gregory', 'Etc/Custom/UTC_Subclass') instanceof Temporal.PlainDateTime);
// assert(Temporal.now.plainDateISO('Etc/Custom/UTC_Subclass') instanceof Temporal.PlainDate);
// assert(Temporal.now.plainDate('gregory', 'Etc/Custom/UTC_Subclass') instanceof Temporal.PlainDate);
// assert(Temporal.now.plainTimeISO('Etc/Custom/UTC_Subclass') instanceof Temporal.PlainTime);
// });
// after(() => {
// Temporal.TimeZone.from = originalTemporalTimeZoneFrom;
// });
// });
});
describe('Trivial protocol implementation', () => {
const obj = {
Expand Down Expand Up @@ -162,48 +120,6 @@ describe('Userland time zone', () => {
assert(Temporal.now.plainDate('gregory', obj) instanceof Temporal.PlainDate);
assert(Temporal.now.plainTimeISO(obj) instanceof Temporal.PlainTime);
});
// describe('Making available globally', () => {
// const originalTemporalTimeZoneFrom = Temporal.TimeZone.from;
// before(() => {
// Temporal.TimeZone.from = function (item) {
// let id;
// if (item instanceof Temporal.TimeZone) {
// id = item.id;
// } else {
// id = `${item}`;
// // TODO: Use Temporal.parse here to extract the ID from an ISO string
// }
// if (id === 'Etc/Custom/UTC_Protocol') return obj;
// return originalTemporalTimeZoneFrom.call(this, id);
// };
// });
// it('works for TimeZone.from(id)', () => {
// const tz = Temporal.TimeZone.from('Etc/Custom/UTC_Protocol');
// assert(Object.is(tz, obj));
// });
// it.skip('works for TimeZone.from(ISO string)', () => {
// const tz = Temporal.TimeZone.from('1970-01-01T00:00+00:00[Etc/Custom/UTC_Protocol]');
// assert(Object.is(tz, obj));
// });
// it('works for Instant.from', () => {
// const inst = Temporal.Instant.from('1970-01-01T00:00:00+00:00[Etc/Custom/UTC_Protocol]');
// equal(`${inst}`, '1970-01-01T00:00:00Z');
// });
// it('works for Instant.toString', () => {
// const inst = Temporal.Instant.fromEpochSeconds(0);
// equal(inst.toString({ timeZone: 'Etc/Custom/UTC_Protocol' }), '1970-01-01T00:00:00+00:00');
// });
// it('works for Temporal.now', () => {
// assert(Temporal.now.plainDateTimeISO('Etc/Custom/UTC_Protocol') instanceof Temporal.PlainDateTime);
// assert(Temporal.now.plainDateTime('gregory', 'Etc/Custom/UTC_Protocol') instanceof Temporal.PlainDateTime);
// assert(Temporal.now.plainDateISO('Etc/Custom/UTC_Protocol') instanceof Temporal.PlainDate);
// assert(Temporal.now.plainDate('gregory', 'Etc/Custom/UTC_Protocol') instanceof Temporal.PlainDate);
// assert(Temporal.now.plainTimeISO('Etc/Custom/UTC_Protocol') instanceof Temporal.PlainTime);
// });
// after(() => {
// Temporal.TimeZone.from = originalTemporalTimeZoneFrom;
// });
// });
});
describe('sub-minute offset', () => {
class SubminuteTimeZone extends Temporal.TimeZone {
Expand Down Expand Up @@ -266,48 +182,6 @@ describe('Userland time zone', () => {
assert(Temporal.now.plainDate('gregory', obj) instanceof Temporal.PlainDate);
assert(Temporal.now.plainTimeISO(obj) instanceof Temporal.PlainTime);
});
// describe('Making available globally', () => {
// const originalTemporalTimeZoneFrom = Temporal.TimeZone.from;
// before(() => {
// Temporal.TimeZone.from = function (item) {
// let id;
// if (item instanceof Temporal.TimeZone) {
// id = item.id;
// } else {
// id = `${item}`;
// // TODO: Use Temporal.parse here to extract the ID from an ISO string
// }
// if (id === 'Custom/Subminute') return new SubminuteTimeZone();
// return originalTemporalTimeZoneFrom.call(this, id);
// };
// });
// it('works for TimeZone.from(id)', () => {
// const tz = Temporal.TimeZone.from('Custom/Subminute');
// assert(tz instanceof SubminuteTimeZone);
// });
// it.skip('works for TimeZone.from(ISO string)', () => {
// const tz = Temporal.TimeZone.from('1970-01-01T00:00-00:00:01.111111111[Custom/Subminute]');
// assert(tz instanceof SubminuteTimeZone);
// });
// it('works for Instant.from', () => {
// const instant = Temporal.Instant.from('1970-01-01T11:59:58.888888889-00:00:01.111111111[Custom/Subminute]');
// equal(`${instant}`, '1970-01-01T12:00:00Z');
// });
// it('works for Instant.toString', () => {
// const inst = Temporal.Instant.fromEpochSeconds(0);
// equal(inst.toString({ timeZone: 'Custom/Subminute' }), '1969-12-31T23:59:58.888888889-00:00:01.111111111');
// });
// it('works for Temporal.now', () => {
// assert(Temporal.now.plainDateTimeISO('Custom/Subminute') instanceof Temporal.PlainDateTime);
// assert(Temporal.now.plainDateTime('gregory', 'Custom/Subminute') instanceof Temporal.PlainDateTime);
// assert(Temporal.now.plainDateISO('Custom/Subminute') instanceof Temporal.PlainDate);
// assert(Temporal.now.plainDate('gregory', 'Custom/Subminute') instanceof Temporal.PlainDate);
// assert(Temporal.now.plainTimeISO('Custom/Subminute') instanceof Temporal.PlainTime);
// });
// after(() => {
// Temporal.TimeZone.from = originalTemporalTimeZoneFrom;
// });
// });
});
});

Expand Down

0 comments on commit ba3dbd9

Please sign in to comment.