Explorar o código

LibJS: Add tests for exception if assignment LHS is invalid

Barney Wilks %!s(int64=5) %!d(string=hai) anos
pai
achega
4f48fcdb94
Modificáronse 1 ficheiros con 26 adicións e 0 borrados
  1. 26 0
      Libraries/LibJS/Tests/invalid-lhs-in-assignment.js

+ 26 - 0
Libraries/LibJS/Tests/invalid-lhs-in-assignment.js

@@ -0,0 +1,26 @@
+try {
+    try {
+        Math.abs(-20) = 40;
+    } catch (e) {
+        assert(e.name === "ReferenceError");
+        assert(e.message === "Invalid left-hand side in assignment");
+    }
+
+    try {
+        512 = 256;
+    } catch (e) {
+        assert(e.name === "ReferenceError");
+        assert(e.message === "Invalid left-hand side in assignment");
+    }
+
+    try {
+        "hello world" = "another thing?";
+    } catch (e) {
+        assert(e.name === "ReferenceError");
+        assert(e.message === "Invalid left-hand side in assignment");
+    }
+
+    console.log("PASS");
+} catch (e) {
+    console.log("FAIL: " + e);
+}