2022-01-31 23:16:37 +01:00
|
|
|
// Flags: --experimental-loader ./test/fixtures/es-module-loaders/assertionless-json-import.mjs
|
2021-08-28 01:47:49 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
const { strictEqual } = require('assert');
|
|
|
|
|
|
|
|
async function test() {
|
|
|
|
{
|
|
|
|
const [secret0, secret1] = await Promise.all([
|
|
|
|
import('../fixtures/experimental.json'),
|
|
|
|
import(
|
|
|
|
'../fixtures/experimental.json',
|
2023-10-14 05:52:38 +02:00
|
|
|
{ with: { type: 'json' } }
|
2021-08-28 01:47:49 +02:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
|
|
|
|
strictEqual(secret0.default.ofLife, 42);
|
|
|
|
strictEqual(secret1.default.ofLife, 42);
|
|
|
|
strictEqual(secret0.default, secret1.default);
|
|
|
|
strictEqual(secret0, secret1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const [secret0, secret1] = await Promise.all([
|
|
|
|
import('../fixtures/experimental.json?test'),
|
|
|
|
import(
|
|
|
|
'../fixtures/experimental.json?test',
|
2023-10-14 05:52:38 +02:00
|
|
|
{ with: { type: 'json' } }
|
2021-08-28 01:47:49 +02:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
|
|
|
|
strictEqual(secret0.default.ofLife, 42);
|
|
|
|
strictEqual(secret1.default.ofLife, 42);
|
|
|
|
strictEqual(secret0.default, secret1.default);
|
|
|
|
strictEqual(secret0, secret1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const [secret0, secret1] = await Promise.all([
|
|
|
|
import('../fixtures/experimental.json#test'),
|
|
|
|
import(
|
|
|
|
'../fixtures/experimental.json#test',
|
2023-10-14 05:52:38 +02:00
|
|
|
{ with: { type: 'json' } }
|
2021-08-28 01:47:49 +02:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
|
|
|
|
strictEqual(secret0.default.ofLife, 42);
|
|
|
|
strictEqual(secret1.default.ofLife, 42);
|
|
|
|
strictEqual(secret0.default, secret1.default);
|
|
|
|
strictEqual(secret0, secret1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const [secret0, secret1] = await Promise.all([
|
|
|
|
import('../fixtures/experimental.json?test2#test'),
|
|
|
|
import(
|
|
|
|
'../fixtures/experimental.json?test2#test',
|
2023-10-14 05:52:38 +02:00
|
|
|
{ with: { type: 'json' } }
|
2021-08-28 01:47:49 +02:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
|
|
|
|
strictEqual(secret0.default.ofLife, 42);
|
|
|
|
strictEqual(secret1.default.ofLife, 42);
|
|
|
|
strictEqual(secret0.default, secret1.default);
|
|
|
|
strictEqual(secret0, secret1);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const [secret0, secret1] = await Promise.all([
|
|
|
|
import('data:application/json,{"ofLife":42}'),
|
|
|
|
import(
|
|
|
|
'data:application/json,{"ofLife":42}',
|
2023-10-14 05:52:38 +02:00
|
|
|
{ with: { type: 'json' } }
|
2021-08-28 01:47:49 +02:00
|
|
|
),
|
|
|
|
]);
|
|
|
|
|
|
|
|
strictEqual(secret0.default.ofLife, 42);
|
|
|
|
strictEqual(secret1.default.ofLife, 42);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test().then(common.mustCall());
|