diff --git a/test/common/index.js b/test/common/index.js index 3f612afbff..5feb945635 100755 --- a/test/common/index.js +++ b/test/common/index.js @@ -36,6 +36,17 @@ const bits = ['arm64', 'loong64', 'mips', 'mipsel', 'ppc64', 'riscv64', 's390x', .includes(process.arch) ? 64 : 32; const hasIntl = !!process.config.variables.v8_enable_i18n_support; +// small-icu doesn't support non-English locales +const hasFullICU = (() => { + try { + const january = new Date(9e8); + const spanish = new Intl.DateTimeFormat('es', { month: 'long' }); + return spanish.format(january) === 'enero'; + } catch { + return false; + } +})(); + const { atob, btoa, @@ -952,6 +963,7 @@ const common = { getBufferSources, getTTYfd, hasIntl, + hasFullICU, hasCrypto, hasQuic, hasInspector, diff --git a/test/parallel/test-icu-env.js b/test/parallel/test-icu-env.js index 26075a3d0a..1c87743672 100644 --- a/test/parallel/test-icu-env.js +++ b/test/parallel/test-icu-env.js @@ -35,17 +35,7 @@ try { } -// small-icu doesn't support non-English locales -const hasFullICU = (() => { - try { - const january = new Date(9e8); - const spanish = new Intl.DateTimeFormat('es', { month: 'long' }); - return spanish.format(january) === 'enero'; - } catch { - return false; - } -})(); -if (!hasFullICU) +if (!common.hasFullICU) common.skip('small ICU'); const icuVersionMajor = Number(process.config.variables.icu_ver_major ?? 0); diff --git a/test/parallel/test-temporal-with-zoneinfo.js b/test/parallel/test-temporal-with-zoneinfo.js new file mode 100644 index 0000000000..095652bcfc --- /dev/null +++ b/test/parallel/test-temporal-with-zoneinfo.js @@ -0,0 +1,19 @@ +// Flags: --harmony-temporal + +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +if (!process.config.variables.v8_enable_temporal_support) { + common.skip('Temporal is not enabled'); +} + +// TODO(legendecas): bundle zoneinfo data for small ICU and without ICU builds. +if (!common.hasFullICU) { + common.skip('Time zone support unavailable when not built with full ICU'); +} + +// Use globalThis.Temporal to workaround linter complaints. +assert.strictEqual(typeof globalThis.Temporal, 'object'); +const pdt = globalThis.Temporal.Instant.from('1969-07-20T20:17:00Z'); +assert.strictEqual(pdt.toString(), '1969-07-20T20:17:00Z'); diff --git a/test/parallel/test-temporal.js b/test/parallel/test-temporal.js new file mode 100644 index 0000000000..5921a83762 --- /dev/null +++ b/test/parallel/test-temporal.js @@ -0,0 +1,14 @@ +// Flags: --harmony-temporal + +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +if (!process.config.variables.v8_enable_temporal_support) { + common.skip('Temporal is not enabled'); +} + +// Use globalThis.Temporal to workaround linter complaints. +assert.strictEqual(typeof globalThis.Temporal, 'object'); +const pdt = globalThis.Temporal.PlainDateTime.from('1969-07-20T20:17:00'); +assert.strictEqual(pdt.toString(), '1969-07-20T20:17:00');