From 1de4a3a8f6e536175bf7a14125ca2bf214bd28ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 21:48:12 +0000 Subject: [PATCH] Add Javascript test for missing new in constructor call Testcase for issue #969 and issue #626 --- .../test-suite/javascript/class_scope_weird_runme.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Examples/test-suite/javascript/class_scope_weird_runme.js b/Examples/test-suite/javascript/class_scope_weird_runme.js index 73c118d61..ca18c1b4d 100644 --- a/Examples/test-suite/javascript/class_scope_weird_runme.js +++ b/Examples/test-suite/javascript/class_scope_weird_runme.js @@ -4,3 +4,14 @@ f = new class_scope_weird.Foo(); g = new class_scope_weird.Foo(3); if (f.bar(3) != 3) throw RuntimeError; + +// Test missing new keyword during constructor call +var caughtException = false; +try { + g = class_scope_weird.Foo(4); +} catch (err) { + caughtException = true; +} +if (!caughtException) { + throw new Error("Instantiation exception not thrown"); +}