mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: add basic temporal presence check
PR-URL: https://github.com/nodejs/node/pull/60703 Refs: https://github.com/nodejs/node/issues/58730 Refs: https://github.com/nodejs/node/pull/60693 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
committed by
Node.js GitHub Bot
parent
342e87f746
commit
e8a5a82ca4
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
19
test/parallel/test-temporal-with-zoneinfo.js
Normal file
19
test/parallel/test-temporal-with-zoneinfo.js
Normal file
@@ -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');
|
||||
14
test/parallel/test-temporal.js
Normal file
14
test/parallel/test-temporal.js
Normal file
@@ -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');
|
||||
Reference in New Issue
Block a user