From e522f4b65a3439030506733b104498f21422ede0 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Wed, 11 Sep 2024 06:36:43 +0900 Subject: BREAKING(temporal/unstable): Remove obsoleted Temporal APIs part 2 (#25505) Mainly I removed `Temporal.Calendar` and `Temporal.TimeZone` and replaced them to APIs that handle calendar and timezone as strings. https://github.com/tc39/proposal-temporal/pull/2925 Related #24836 --- tests/integration/lsp_tests.rs | 180 --------------------- tests/integration/run_tests.rs | 14 -- .../specs/run/unstable_temporal_api/__test__.jsonc | 19 +++ tests/specs/run/unstable_temporal_api/deno.json | 3 + tests/specs/run/unstable_temporal_api/main.out | 10 ++ tests/specs/run/unstable_temporal_api/main.ts | 59 +++++++ .../run/unstable_temporal_api/missing_flag.js | 1 + .../run/unstable_temporal_api/missing_flag.out | 7 + .../run/unstable_temporal_api_list/__test__.jsonc | 5 + .../specs/run/unstable_temporal_api_list/main.out | 148 +++++++++++++++++ tests/specs/run/unstable_temporal_api_list/main.ts | 37 +++++ .../run/unstable_temporal_api_patch/__test__.jsonc | 5 + .../specs/run/unstable_temporal_api_patch/main.out | 7 + .../specs/run/unstable_temporal_api_patch/main.ts | 11 ++ tests/testdata/run/unstable_temporal_api/deno.json | 3 - tests/testdata/run/unstable_temporal_api/main.out | 12 -- tests/testdata/run/unstable_temporal_api/main.ts | 71 -------- 17 files changed, 312 insertions(+), 280 deletions(-) create mode 100644 tests/specs/run/unstable_temporal_api/__test__.jsonc create mode 100644 tests/specs/run/unstable_temporal_api/deno.json create mode 100644 tests/specs/run/unstable_temporal_api/main.out create mode 100644 tests/specs/run/unstable_temporal_api/main.ts create mode 100644 tests/specs/run/unstable_temporal_api/missing_flag.js create mode 100644 tests/specs/run/unstable_temporal_api/missing_flag.out create mode 100644 tests/specs/run/unstable_temporal_api_list/__test__.jsonc create mode 100644 tests/specs/run/unstable_temporal_api_list/main.out create mode 100644 tests/specs/run/unstable_temporal_api_list/main.ts create mode 100644 tests/specs/run/unstable_temporal_api_patch/__test__.jsonc create mode 100644 tests/specs/run/unstable_temporal_api_patch/main.out create mode 100644 tests/specs/run/unstable_temporal_api_patch/main.ts delete mode 100644 tests/testdata/run/unstable_temporal_api/deno.json delete mode 100644 tests/testdata/run/unstable_temporal_api/main.out delete mode 100644 tests/testdata/run/unstable_temporal_api/main.ts (limited to 'tests') diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 8fb64defd..f0d0a2d8d 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -11111,24 +11111,6 @@ fn lsp_workspace_symbol() { }, "containerName": "B" }, - { - "name": "fields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "fields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, { "name": "ClassFieldDecoratorContext", "kind": 11, @@ -11138,168 +11120,6 @@ fn lsp_workspace_symbol() { }, "containerName": "" }, - { - "name": "dateFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "dateFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainDate" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainDateTime" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainMonthDay" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainTime" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "PlainYearMonth" - }, - { - "name": "getISOFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "ZonedDateTime" - }, - { - "name": "mergeFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "mergeFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "monthDayFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "monthDayFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "PlainDateISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - }, - { - "name": "PlainDateTimeISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - }, - { - "name": "PlainTimeISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - }, - { - "name": "yearMonthFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "CalendarProtocol" - }, - { - "name": "yearMonthFromFields", - "kind": 6, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Calendar" - }, - { - "name": "ZonedDateTimeISOFields", - "kind": 5, - "location": { - "uri": "deno:/asset/lib.deno.unstable.d.ts", - "range": null, - }, - "containerName": "Temporal" - } ]) ); client.shutdown(); diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index 9a680b944..6f85aaf0b 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -4731,20 +4731,6 @@ itest!(unsafe_proto_flag { exit_code: 0, }); -itest!(unstable_temporal_api { - args: "run --no-config --unstable-temporal --check run/unstable_temporal_api/main.ts", - output: "run/unstable_temporal_api/main.out", - http_server: false, - exit_code: 0, -}); - -itest!(unstable_temporal_api_config_file { - args: "run --check run/unstable_temporal_api/main.ts", - output: "run/unstable_temporal_api/main.out", - http_server: false, - exit_code: 0, -}); - // TODO(bartlomieju): temporary disabled // itest!(warn_on_deprecated_api { // args: "run -A run/warn_on_deprecated_api/main.js", diff --git a/tests/specs/run/unstable_temporal_api/__test__.jsonc b/tests/specs/run/unstable_temporal_api/__test__.jsonc new file mode 100644 index 000000000..226e0ce04 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/__test__.jsonc @@ -0,0 +1,19 @@ +{ + "tests": { + "basic": { + "args": "run --no-config --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 + }, + "config": { + "args": "run --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 + }, + "missing_flag": { + "args": "run --no-config missing_flag.js", + "output": "missing_flag.out", + "exitCode": 1 + } + } +} diff --git a/tests/specs/run/unstable_temporal_api/deno.json b/tests/specs/run/unstable_temporal_api/deno.json new file mode 100644 index 000000000..fea0791c5 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/deno.json @@ -0,0 +1,3 @@ +{ + "unstable": ["temporal"] +} diff --git a/tests/specs/run/unstable_temporal_api/main.out b/tests/specs/run/unstable_temporal_api/main.out new file mode 100644 index 000000000..d916a4cc2 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/main.out @@ -0,0 +1,10 @@ +Check [WILDCARD] +Temporal.Now [WILDCARD] +Temporal.Instant 1969-07-20T20:17:00Z +Temporal.ZonedDateTime 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] +Temporal.PlainDate 2006-08-24 +Temporal.PlainTime 19:39:09.068346205 +Temporal.PlainDateTime 1995-12-07T15:00:00 +Temporal.PlainYearMonth 2020-10 +Temporal.PlainMonthDay 07-14 +Temporal.Duration PT130H20M diff --git a/tests/specs/run/unstable_temporal_api/main.ts b/tests/specs/run/unstable_temporal_api/main.ts new file mode 100644 index 000000000..351b30e7d --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/main.ts @@ -0,0 +1,59 @@ +console.log("Temporal.Now", Temporal.Now.instant()); +console.log( + "Temporal.Instant", + Temporal.Instant.from("1969-07-20T20:17Z"), +); +console.log( + "Temporal.ZonedDateTime", + Temporal.ZonedDateTime.from({ + timeZone: "America/Los_Angeles", + year: 1995, + month: 12, + day: 7, + hour: 3, + minute: 24, + second: 30, + millisecond: 0, + microsecond: 3, + nanosecond: 500, + }), +); +console.log( + "Temporal.PlainDate", + Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }), +); +console.log( + "Temporal.PlainTime", + Temporal.PlainTime.from({ + hour: 19, + minute: 39, + second: 9, + millisecond: 68, + microsecond: 346, + nanosecond: 205, + }), +); +console.log( + "Temporal.PlainDateTime", + Temporal.PlainDateTime.from({ + year: 1995, + month: 12, + day: 7, + hour: 15, + }), +); +console.log( + "Temporal.PlainYearMonth", + Temporal.PlainYearMonth.from({ year: 2020, month: 10 }), +); +console.log( + "Temporal.PlainMonthDay", + Temporal.PlainMonthDay.from({ month: 7, day: 14 }), +); +console.log( + "Temporal.Duration", + Temporal.Duration.from({ + hours: 130, + minutes: 20, + }), +); diff --git a/tests/specs/run/unstable_temporal_api/missing_flag.js b/tests/specs/run/unstable_temporal_api/missing_flag.js new file mode 100644 index 000000000..92aed7931 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/missing_flag.js @@ -0,0 +1 @@ +Temporal.Now.instant(); diff --git a/tests/specs/run/unstable_temporal_api/missing_flag.out b/tests/specs/run/unstable_temporal_api/missing_flag.out new file mode 100644 index 000000000..03ed5abb9 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api/missing_flag.out @@ -0,0 +1,7 @@ +error: Uncaught (in promise) ReferenceError: Temporal is not defined +Temporal.Now.instant(); +^ + at [WILDCARD]missing_flag.js:1:1 + + info: Temporal is an unstable API. + hint: Run again with `--unstable-temporal` flag to enable this API. diff --git a/tests/specs/run/unstable_temporal_api_list/__test__.jsonc b/tests/specs/run/unstable_temporal_api_list/__test__.jsonc new file mode 100644 index 000000000..b5b12ed26 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_list/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-config --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/specs/run/unstable_temporal_api_list/main.out b/tests/specs/run/unstable_temporal_api_list/main.out new file mode 100644 index 000000000..bdfeab5ac --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_list/main.out @@ -0,0 +1,148 @@ +Check [WILDCARD] +Temporal +[ + "Duration", + "Instant", + "Now", + "PlainDate", + "PlainDateTime", + "PlainMonthDay", + "PlainTime", + "PlainYearMonth", + "ZonedDateTime" +] +Temporal.Now +[ + "instant", + "plainDateISO", + "plainDateTimeISO", + "plainTimeISO", + "timeZoneId", + "zonedDateTimeISO" +] +Temporal.Instant.prototype +[ + "add", + "constructor", + "epochMilliseconds", + "epochNanoseconds", + "equals", + "round", + "since", + "subtract", + "toJSON", + "toLocaleString", + "toString", + "toZonedDateTimeISO", + "until", + "valueOf" +] +Temporal.ZonedDateTime.prototype +[ + "add", "calendarId", "constructor", + "day", "dayOfWeek", "dayOfYear", + "daysInMonth", "daysInWeek", "daysInYear", + "epochMilliseconds", "epochNanoseconds", "equals", + "era", "eraYear", "hour", + "hoursInDay", "inLeapYear", "microsecond", + "millisecond", "minute", "month", + "monthCode", "monthsInYear", "nanosecond", + "offset", "offsetNanoseconds", "round", + "second", "since", "startOfDay", + "subtract", "timeZoneId", "toInstant", + "toJSON", "toLocaleString", "toPlainDate", + "toPlainDateTime", "toPlainTime", "toString", + "until", "valueOf", "weekOfYear", + "with", "withCalendar", "withPlainTime", + "withTimeZone", "year" +] +Temporal.PlainDate.prototype +[ + "add", "calendarId", + "constructor", "day", + "dayOfWeek", "dayOfYear", + "daysInMonth", "daysInWeek", + "daysInYear", "equals", + "era", "eraYear", + "inLeapYear", "month", + "monthCode", "monthsInYear", + "since", "subtract", + "toJSON", "toLocaleString", + "toPlainDateTime", "toPlainMonthDay", + "toPlainYearMonth", "toString", + "toZonedDateTime", "until", + "valueOf", "weekOfYear", + "with", "withCalendar", + "year" +] +Temporal.PlainTime.prototype +[ + "add", "constructor", + "equals", "hour", + "microsecond", "millisecond", + "minute", "nanosecond", + "round", "second", + "since", "subtract", + "toJSON", "toLocaleString", + "toString", "until", + "valueOf", "with" +] +Temporal.PlainDateTime.prototype +[ + "add", "calendarId", "constructor", + "day", "dayOfWeek", "dayOfYear", + "daysInMonth", "daysInWeek", "daysInYear", + "equals", "era", "eraYear", + "hour", "inLeapYear", "microsecond", + "millisecond", "minute", "month", + "monthCode", "monthsInYear", "nanosecond", + "round", "second", "since", + "subtract", "toJSON", "toLocaleString", + "toPlainDate", "toPlainTime", "toString", + "toZonedDateTime", "until", "valueOf", + "weekOfYear", "with", "withCalendar", + "withPlainTime", "year" +] +Temporal.PlainYearMonth.prototype +[ + "add", "calendarId", + "constructor", "daysInMonth", + "daysInYear", "equals", + "era", "eraYear", + "inLeapYear", "month", + "monthCode", "monthsInYear", + "since", "subtract", + "toJSON", "toLocaleString", + "toPlainDate", "toString", + "until", "valueOf", + "with", "year" +] +Temporal.PlainMonthDay.prototype +[ + "calendarId", + "constructor", + "day", + "equals", + "monthCode", + "toJSON", + "toLocaleString", + "toPlainDate", + "toString", + "valueOf", + "with" +] +Temporal.Duration.prototype +[ + "abs", "add", + "blank", "constructor", + "days", "hours", + "microseconds", "milliseconds", + "minutes", "months", + "nanoseconds", "negated", + "round", "seconds", + "sign", "subtract", + "toJSON", "toLocaleString", + "toString", "total", + "valueOf", "weeks", + "with", "years" +] diff --git a/tests/specs/run/unstable_temporal_api_list/main.ts b/tests/specs/run/unstable_temporal_api_list/main.ts new file mode 100644 index 000000000..548bb320a --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_list/main.ts @@ -0,0 +1,37 @@ +console.log("Temporal"); +console.log(Object.getOwnPropertyNames(Temporal).sort()); + +console.log("Temporal.Now"); +console.log(Object.getOwnPropertyNames(Temporal.Now).sort()); + +console.log("Temporal.Instant.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.Instant.prototype).sort()); + +console.log("Temporal.ZonedDateTime.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.ZonedDateTime.prototype).sort(), +); + +console.log("Temporal.PlainDate.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.PlainDate.prototype).sort()); + +console.log("Temporal.PlainTime.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.PlainTime.prototype).sort()); + +console.log("Temporal.PlainDateTime.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.PlainDateTime.prototype).sort(), +); + +console.log("Temporal.PlainYearMonth.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.PlainYearMonth.prototype).sort(), +); + +console.log("Temporal.PlainMonthDay.prototype"); +console.log( + Object.getOwnPropertyNames(Temporal.PlainMonthDay.prototype).sort(), +); + +console.log("Temporal.Duration.prototype"); +console.log(Object.getOwnPropertyNames(Temporal.Duration.prototype).sort()); diff --git a/tests/specs/run/unstable_temporal_api_patch/__test__.jsonc b/tests/specs/run/unstable_temporal_api_patch/__test__.jsonc new file mode 100644 index 000000000..b5b12ed26 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_patch/__test__.jsonc @@ -0,0 +1,5 @@ +{ + "args": "run --no-config --unstable-temporal --check main.ts", + "output": "main.out", + "exitCode": 0 +} diff --git a/tests/specs/run/unstable_temporal_api_patch/main.out b/tests/specs/run/unstable_temporal_api_patch/main.out new file mode 100644 index 000000000..a17d3a9e2 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_patch/main.out @@ -0,0 +1,7 @@ +Check [WILDCARD] +[WILDCARD] +undefined +iso8601 +UTC +undefined +undefined diff --git a/tests/specs/run/unstable_temporal_api_patch/main.ts b/tests/specs/run/unstable_temporal_api_patch/main.ts new file mode 100644 index 000000000..6a4078053 --- /dev/null +++ b/tests/specs/run/unstable_temporal_api_patch/main.ts @@ -0,0 +1,11 @@ +console.log(Temporal.Now.timeZoneId()); +// @ts-expect-error: undefined check +console.log(Temporal.Now.timeZone); + +const zoned = new Temporal.ZonedDateTime(0n, "UTC"); +console.log(zoned.calendarId); +console.log(zoned.timeZoneId); +// @ts-expect-error: undefined check +console.log(zoned.calendar); +// @ts-expect-error: undefined check +console.log(zoned.timeZone); diff --git a/tests/testdata/run/unstable_temporal_api/deno.json b/tests/testdata/run/unstable_temporal_api/deno.json deleted file mode 100644 index fea0791c5..000000000 --- a/tests/testdata/run/unstable_temporal_api/deno.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unstable": ["temporal"] -} diff --git a/tests/testdata/run/unstable_temporal_api/main.out b/tests/testdata/run/unstable_temporal_api/main.out deleted file mode 100644 index 46d25c3ea..000000000 --- a/tests/testdata/run/unstable_temporal_api/main.out +++ /dev/null @@ -1,12 +0,0 @@ -Check [WILDCARD] -Temporal.Now [WILDCARD] -Temporal.Instant 1969-07-20T20:17:00Z -Temporal.ZonedDateTime 1995-12-07T03:24:30.0000035-08:00[America/Los_Angeles] -Temporal.PlainDate 2006-08-24 -Temporal.PlainTime 19:39:09.068346205 -Temporal.PlainDateTime 1995-12-07T15:00:00 -Temporal.PlainYearMonth 2020-10 -Temporal.PlainMonthDay 07-14 -Temporal.Duration PT130H20M -Temporal.TimeZone Africa/Cairo -Temporal.Calendar 1999-12-31 diff --git a/tests/testdata/run/unstable_temporal_api/main.ts b/tests/testdata/run/unstable_temporal_api/main.ts deleted file mode 100644 index 1641b90bf..000000000 --- a/tests/testdata/run/unstable_temporal_api/main.ts +++ /dev/null @@ -1,71 +0,0 @@ -console.log("Temporal.Now", Temporal.Now.instant()); -console.log( - "Temporal.Instant", - Temporal.Instant.from("1969-07-20T20:17Z"), -); -console.log( - "Temporal.ZonedDateTime", - Temporal.ZonedDateTime.from({ - timeZone: "America/Los_Angeles", - year: 1995, - month: 12, - day: 7, - hour: 3, - minute: 24, - second: 30, - millisecond: 0, - microsecond: 3, - nanosecond: 500, - }), -); -console.log( - "Temporal.PlainDate", - Temporal.PlainDate.from({ year: 2006, month: 8, day: 24 }), -); -console.log( - "Temporal.PlainTime", - Temporal.PlainTime.from({ - hour: 19, - minute: 39, - second: 9, - millisecond: 68, - microsecond: 346, - nanosecond: 205, - }), -); -console.log( - "Temporal.PlainDateTime", - Temporal.PlainDateTime.from({ - year: 1995, - month: 12, - day: 7, - hour: 15, - }), -); -console.log( - "Temporal.PlainYearMonth", - Temporal.PlainYearMonth.from({ year: 2020, month: 10 }), -); -console.log( - "Temporal.PlainMonthDay", - Temporal.PlainMonthDay.from({ month: 7, day: 14 }), -); -console.log( - "Temporal.Duration", - Temporal.Duration.from({ - hours: 130, - minutes: 20, - }), -); -console.log( - "Temporal.TimeZone", - Temporal.TimeZone.from("Africa/Cairo"), -); -console.log( - "Temporal.Calendar", - Temporal.Calendar.from("iso8601").dateFromFields({ - year: 1999, - month: 12, - day: 31, - }, {}), -); -- cgit v1.2.3