summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/const-reassignment.js
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2020-07-05 10:47:40 -0700
committerAndreas Kling <kling@serenityos.org>2020-07-06 23:40:35 +0200
commit918f4affd51cdd285272770465d4d875f4ae5aa2 (patch)
tree5885d1c4161083454924db9abaaf127c76cf0c99 /Libraries/LibJS/Tests/const-reassignment.js
parent6d58c48c2fbe2e3ce9b9cfe1dd75a5ccc594f961 (diff)
downloadserenity-918f4affd51cdd285272770465d4d875f4ae5aa2.zip
LibJS: Convert remaining top-level tests to new system
Diffstat (limited to 'Libraries/LibJS/Tests/const-reassignment.js')
-rw-r--r--Libraries/LibJS/Tests/const-reassignment.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/const-reassignment.js b/Libraries/LibJS/Tests/const-reassignment.js
new file mode 100644
index 0000000000..6638229738
--- /dev/null
+++ b/Libraries/LibJS/Tests/const-reassignment.js
@@ -0,0 +1,16 @@
+test.skip("reassignment to const", () => {
+ const constantValue = 1;
+ expect(() => {
+ constantValue = 2;
+ }).toThrowWithMessage(TypeError, "Invalid assignment to const variable");
+ expect(constantValue).toBe(1);
+});
+
+test("const creation in inner scope", () => {
+ const constantValue = 1;
+ do {
+ const constantValue = 2;
+ expect(constantValue).toBe(2);
+ } while (false);
+ expect(constantValue).toBe(1);
+});