summaryrefslogtreecommitdiff
path: root/harness
diff options
context:
space:
mode:
authorMichael Ficarra <mficarra@shapesecurity.com>2018-03-06 18:18:00 -0800
committerRick Waldron <waldron.rick@gmail.com>2018-03-07 14:09:45 -0500
commit83ffb4bbf2a7a2f68075c8e611525b55ea5cfecc (patch)
treeb5592940e641b3b0e2b1c38dfe53eee2b9fcdacc /harness
parentce9419779fc61d5cdfa37a5cda7b6828c67221da (diff)
downloadqtdeclarative-testsuites-83ffb4bbf2a7a2f68075c8e611525b55ea5cfecc.tar.gz
allow any function to report its toString as a NativeFunction
related: https://github.com/tc39/Function-prototype-toString-revision/pull/26
Diffstat (limited to 'harness')
-rw-r--r--harness/nativeFunctionMatcher.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/harness/nativeFunctionMatcher.js b/harness/nativeFunctionMatcher.js
index 0a2d248a3..52120ea48 100644
--- a/harness/nativeFunctionMatcher.js
+++ b/harness/nativeFunctionMatcher.js
@@ -6,3 +6,17 @@ description: |
the NativeFunction grammar production without requiring a correct tokeniser.
---*/
const NATIVE_FUNCTION_RE = /\bfunction\b[\s\S]*\([\s\S]*\)[\s\S]*\{[\s\S]*\[[\s\S]*\bnative\b[\s\S]+\bcode\b[\s\S]*\][\s\S]*\}/;
+
+const assertToStringOrNativeFunction = function(fn, expected) {
+ const actual = "" + fn;
+ try {
+ assert.sameValue(actual, expected);
+ } catch (unused) {
+ assertNativeFunction(fn);
+ }
+};
+
+const assertNativeFunction = function(fn) {
+ const actual = "" + fn;
+ assert(NATIVE_FUNCTION_RE.test(actual), "looks pretty much like a NativeFunction");
+};