Skip to content

Commit 5081045

Browse files
committed
Test of the replacement of a core module that is required using 'node:' prefix.
1 parent 4d7259d commit 5081045

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

graal-js/src/com.oracle.truffle.js.test/src/com/oracle/truffle/js/test/builtins/CommonJSRequireTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -476,6 +476,19 @@ public void testCustomNodeBuiltin() {
476476
}
477477
}
478478

479+
@Test
480+
public void testCustomNodeBuiltinNodePrefix() {
481+
Path root = getTestRootFolder();
482+
Map<String, String> options = new HashMap<>();
483+
options.put(COMMONJS_REQUIRE_NAME, "true");
484+
options.put(COMMONJS_REQUIRE_CWD_NAME, root.toAbsolutePath().toString());
485+
options.put(COMMONJS_CORE_MODULES_REPLACEMENTS_NAME, "util:./module");
486+
try (Context cx = testContext(options)) {
487+
Value js = cx.eval(ID, "require('node:util').foo");
488+
Assert.assertEquals(42, js.asInt());
489+
}
490+
}
491+
479492
@Test
480493
public void testNotNodeBuiltin() {
481494
Path root = getTestRootFolder();

0 commit comments

Comments
 (0)