Skip to content

Commit b35af0c

Browse files
committed
test: add basic temporal presence check
1 parent 7f70f3c commit b35af0c

File tree

4 files changed

+46
-11
lines changed

4 files changed

+46
-11
lines changed

test/common/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ const bits = ['arm64', 'loong64', 'mips', 'mipsel', 'ppc64', 'riscv64', 's390x',
3636
.includes(process.arch) ? 64 : 32;
3737
const hasIntl = !!process.config.variables.v8_enable_i18n_support;
3838

39+
// small-icu doesn't support non-English locales
40+
const hasFullICU = (() => {
41+
try {
42+
const january = new Date(9e8);
43+
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
44+
return spanish.format(january) === 'enero';
45+
} catch {
46+
return false;
47+
}
48+
})();
49+
3950
const {
4051
atob,
4152
btoa,
@@ -952,6 +963,7 @@ const common = {
952963
getBufferSources,
953964
getTTYfd,
954965
hasIntl,
966+
hasFullICU,
955967
hasCrypto,
956968
hasQuic,
957969
hasInspector,

test/parallel/test-icu-env.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ try {
3535
}
3636

3737

38-
// small-icu doesn't support non-English locales
39-
const hasFullICU = (() => {
40-
try {
41-
const january = new Date(9e8);
42-
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
43-
return spanish.format(january) === 'enero';
44-
} catch {
45-
return false;
46-
}
47-
})();
48-
if (!hasFullICU)
38+
if (!common.hasFullICU)
4939
common.skip('small ICU');
5040

5141
const icuVersionMajor = Number(process.config.variables.icu_ver_major ?? 0);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Flags: --harmony-temporal
2+
3+
'use strict';
4+
const common = require('../common');
5+
const assert = require('assert');
6+
7+
if (!process.config.variables.v8_enable_temporal_support) {
8+
common.skip('Temporal is not enabled');
9+
}
10+
11+
// TODO(legendecas): bundle zoneinfo data for small ICU and without ICU builds.
12+
if (!common.hasFullICU) {
13+
common.skip('Built with small ICU');
14+
}
15+
16+
// Use globalThis.Temporal to workaround linter complaints.
17+
assert.strictEqual(typeof globalThis.Temporal, 'object');
18+
const pdt = globalThis.Temporal.Instant.from('1969-07-20T20:17:00Z');
19+
assert.strictEqual(pdt.toString(), '1969-07-20T20:17:00Z');

test/parallel/test-temporal.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Flags: --harmony-temporal
2+
3+
'use strict';
4+
const common = require('../common');
5+
const assert = require('assert');
6+
7+
if (!process.config.variables.v8_enable_temporal_support) {
8+
common.skip('Temporal is not enabled');
9+
}
10+
11+
// Use globalThis.Temporal to workaround linter complaints.
12+
assert.strictEqual(typeof globalThis.Temporal, 'object');
13+
const pdt = globalThis.Temporal.PlainDateTime.from('1969-07-20T20:17:00');
14+
assert.strictEqual(pdt.toString(), '1969-07-20T20:17:00');

0 commit comments

Comments
 (0)