diff options
author | Kenta Moriuchi <moriken@kimamass.com> | 2024-09-11 06:36:43 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-10 21:36:43 +0000 |
commit | e522f4b65a3439030506733b104498f21422ede0 (patch) | |
tree | fdc344f8c28aefe387d5c8048e01d0a2240bc8e5 /tests | |
parent | a69b1e699ef76568a4a3da47939134abda545ec7 (diff) |
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
Diffstat (limited to 'tests')
14 files changed, 240 insertions, 208 deletions
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 @@ -11112,24 +11112,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, "location": { @@ -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/testdata/run/unstable_temporal_api/deno.json b/tests/specs/run/unstable_temporal_api/deno.json index fea0791c5..fea0791c5 100644 --- a/tests/testdata/run/unstable_temporal_api/deno.json +++ b/tests/specs/run/unstable_temporal_api/deno.json diff --git a/tests/testdata/run/unstable_temporal_api/main.out b/tests/specs/run/unstable_temporal_api/main.out index 46d25c3ea..d916a4cc2 100644 --- a/tests/testdata/run/unstable_temporal_api/main.out +++ b/tests/specs/run/unstable_temporal_api/main.out @@ -8,5 +8,3 @@ 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/specs/run/unstable_temporal_api/main.ts index 1641b90bf..351b30e7d 100644 --- a/tests/testdata/run/unstable_temporal_api/main.ts +++ b/tests/specs/run/unstable_temporal_api/main.ts @@ -57,15 +57,3 @@ console.log( 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, - }, {}), -); 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); |