summaryrefslogtreecommitdiff
path: root/test/harness
diff options
context:
space:
mode:
authorLeo Balter <leonardo.balter@gmail.com>2017-05-01 12:29:52 -0400
committerLeo Balter <leonardo.balter@gmail.com>2017-05-01 12:29:52 -0400
commit666f0e920afcf2ba48971818569afa59e5ce83bf (patch)
treebaa1bf2e33f54874b74ecbf8c62c426389d55ee0 /test/harness
parent0ad3d51fd908dbb132595e3b41752fe31b30003e (diff)
downloadqtdeclarative-testsuites-666f0e920afcf2ba48971818569afa59e5ce83bf.tar.gz
Add assert.throws.early
Diffstat (limited to 'test/harness')
-rw-r--r--test/harness/assert-throws-early-incorrect-ctor.js20
-rw-r--r--test/harness/assert-throws-early-not-early.js16
-rw-r--r--test/harness/assert-throws-early-referenceerror.js9
-rw-r--r--test/harness/assert-throws-early-syntaxerror.js9
4 files changed, 54 insertions, 0 deletions
diff --git a/test/harness/assert-throws-early-incorrect-ctor.js b/test/harness/assert-throws-early-incorrect-ctor.js
new file mode 100644
index 000000000..c291c930a
--- /dev/null
+++ b/test/harness/assert-throws-early-incorrect-ctor.js
@@ -0,0 +1,20 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ Functions that throw values whose constructor does not match the specified
+ constructor do not satisfy the assertion.
+---*/
+
+// monkeypatch the API
+$ERROR = function $ERROR(message) {
+ throw new Test262Error(message);
+};
+
+assert.throws(Test262Error, () => {
+ assert.throws.early(SyntaxError, "1 = 1;");
+}, "'1=1' is a ReferenceError");
+assert.throws(Test262Error, () => {
+ assert.throws.early(ReferenceError, "var;");
+}, "'var;' is a SyntaxError");
diff --git a/test/harness/assert-throws-early-not-early.js b/test/harness/assert-throws-early-not-early.js
new file mode 100644
index 000000000..b9774492d
--- /dev/null
+++ b/test/harness/assert-throws-early-not-early.js
@@ -0,0 +1,16 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The assertion fails when the code does not parse with an early error
+---*/
+
+// monkeypatch the API
+$ERROR = function $ERROR(message) {
+ throw new Test262Error(message);
+};
+
+assert.throws(Test262Error, () => {
+ assert.throws.early(ReferenceError, 'x = 1');
+});
diff --git a/test/harness/assert-throws-early-referenceerror.js b/test/harness/assert-throws-early-referenceerror.js
new file mode 100644
index 000000000..fbb667f1c
--- /dev/null
+++ b/test/harness/assert-throws-early-referenceerror.js
@@ -0,0 +1,9 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The assertion pass when the code parses with an early ReferenceError
+---*/
+
+assert.throws.early(ReferenceError, '1 = 1;');
diff --git a/test/harness/assert-throws-early-syntaxerror.js b/test/harness/assert-throws-early-syntaxerror.js
new file mode 100644
index 000000000..0e047d0f0
--- /dev/null
+++ b/test/harness/assert-throws-early-syntaxerror.js
@@ -0,0 +1,9 @@
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ The assertion pass when the code parses with an early SyntaxError
+---*/
+
+assert.throws.early(SyntaxError, 'let let');