summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/modules
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-11-15 01:39:07 +0100
committerLinus Groh <mail@linusgroh.de>2022-11-15 12:00:36 +0000
commit67865306d3ad1f23098c7d4658c470a788f6786e (patch)
tree821074485760fe78665384544f7c621237e766c6 /Userland/Libraries/LibJS/Tests/modules
parent385c2f2eb8491c43a4051962aadcc8865ff7f76b (diff)
downloadserenity-67865306d3ad1f23098c7d4658c470a788f6786e.zip
LibJS: Fix that functions in module did not look for var declarations
Diffstat (limited to 'Userland/Libraries/LibJS/Tests/modules')
-rw-r--r--Userland/Libraries/LibJS/Tests/modules/basic-modules.js6
-rw-r--r--Userland/Libraries/LibJS/Tests/modules/function-in-function.mjs11
2 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Tests/modules/basic-modules.js b/Userland/Libraries/LibJS/Tests/modules/basic-modules.js
index ad91955e11..769356aabe 100644
--- a/Userland/Libraries/LibJS/Tests/modules/basic-modules.js
+++ b/Userland/Libraries/LibJS/Tests/modules/basic-modules.js
@@ -239,3 +239,9 @@ describe("failing modules cascade", () => {
);
});
});
+
+describe("scoping in modules", () => {
+ test("functions within functions", () => {
+ expectModulePassed("./function-in-function.mjs");
+ });
+});
diff --git a/Userland/Libraries/LibJS/Tests/modules/function-in-function.mjs b/Userland/Libraries/LibJS/Tests/modules/function-in-function.mjs
new file mode 100644
index 0000000000..4b6c80f981
--- /dev/null
+++ b/Userland/Libraries/LibJS/Tests/modules/function-in-function.mjs
@@ -0,0 +1,11 @@
+function foo() {
+ function bar() {}
+ bar.baz = "value on bar";
+
+ return bar;
+}
+
+foo.bippity = "boppity";
+const fooResult = foo();
+
+export const passed = fooResult.baz === "value on bar" && foo.bippity === "boppity";