diff options
Diffstat (limited to 'tests/specs')
12 files changed, 312 insertions, 0 deletions
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); |