diff --git a/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js b/Libraries/LibJS/Tests/invalid-lhs-in-assignment.js new file mode 100644 index 0000000000..7257c87e29 --- /dev/null +++ b/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); +}