summaryrefslogtreecommitdiff
path: root/Libraries/LibJS
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-11-28 16:19:28 +0100
committerAndreas Kling <kling@serenityos.org>2020-11-28 17:16:48 +0100
commit1fad95fec5deed959e0e5de7ff66702acd34cc2c (patch)
tree2ffe3c6fa2a1b6e57402c50a1aaf3a51b352ea09 /Libraries/LibJS
parent9de6443ab7f3cb5ccf79d33d071cb57c9919b113 (diff)
downloadserenity-1fad95fec5deed959e0e5de7ff66702acd34cc2c.zip
LibJS: Add a basic unit test for the "with" statement
Diffstat (limited to 'Libraries/LibJS')
-rw-r--r--Libraries/LibJS/Tests/with-basic.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/with-basic.js b/Libraries/LibJS/Tests/with-basic.js
new file mode 100644
index 0000000000..a5bdbf4e41
--- /dev/null
+++ b/Libraries/LibJS/Tests/with-basic.js
@@ -0,0 +1,20 @@
+test("basic with statement functionality", () => {
+ var object = { "foo": 5, "bar": 6, "baz": 7 };
+ var qux = 1;
+
+ var bar = 99;
+
+ with (object) {
+ expect(foo).toBe(5);
+ expect(bar).toBe(6);
+ expect(baz).toBe(7);
+ expect(qux).toBe(1);
+ expect(typeof quz).toBe("undefined");
+
+ bar = 2;
+ }
+
+ expect(object.bar).toBe(2);
+
+ expect(bar).toBe(99);
+});