From 1fad95fec5deed959e0e5de7ff66702acd34cc2c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 28 Nov 2020 16:19:28 +0100 Subject: [PATCH] LibJS: Add a basic unit test for the "with" statement --- Libraries/LibJS/Tests/with-basic.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Libraries/LibJS/Tests/with-basic.js diff --git a/Libraries/LibJS/Tests/with-basic.js b/Libraries/LibJS/Tests/with-basic.js new file mode 100644 index 00000000000..a5bdbf4e41f --- /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); +});