From 4f48fcdb94d52c619c4a31d70dd747a8846422c7 Mon Sep 17 00:00:00 2001 From: Barney Wilks Date: Fri, 10 Apr 2020 00:39:33 +0100 Subject: [PATCH] LibJS: Add tests for exception if assignment LHS is invalid --- .../LibJS/Tests/invalid-lhs-in-assignment.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Libraries/LibJS/Tests/invalid-lhs-in-assignment.js 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); +}