mirror of
https://github.com/tc39/test262.git
synced 2025-05-06 16:00:33 +02:00
In order to satisfy the project's formatting rules, license information was inserted into a number of files where it had been mistakenly omitted by the original contributors [1]. In many cases, the license information did not accurately describe the contributor or the time of contribution. Update the information according to the information provided by the contributors at the time each file was authored: - atomicsHelper.js - a72ee6d91275aa6524e84a9b7070103411ef2689 - detachArrayBuffer.js - 70c7375be83137015da2c5d6d29a3c40ad3cb5b1 - nans.js - b17ffc029850e3c32d51c68e0281ab7b1a4c193b - nativeFunctionMatcher.js - 6b7cbb50350e478a543da40d02492aa8f45a792d - proxyTrapsHelper.js d530c87b41584d47d95bb78dccf592c9c5c8f7b1 - regexpUtils.js - 44b40e083ec851cd8448d5fe4755bdfc9f0dc14c - tcoHelper.js - 4dc81d37886f49512eb60dafe13b794af5ffeb29 [1] 4ea2931f169d4a4b5a9a4a7c731cc92bf7b3e13c
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
// Copyright (C) 2016 Michael Ficarra. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
description: Assert _NativeFunction_ Syntax
|
|
info: |
|
|
This regex makes a best-effort determination that the tested string matches
|
|
the NativeFunction grammar production without requiring a correct tokeniser.
|
|
|
|
NativeFunction :
|
|
function _IdentifierName_ opt ( _FormalParameters_ ) { [ native code ] }
|
|
|
|
---*/
|
|
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, expected);
|
|
}
|
|
};
|
|
|
|
const assertNativeFunction = function(fn, special) {
|
|
const actual = "" + fn;
|
|
assert(
|
|
NATIVE_FUNCTION_RE.test(actual),
|
|
"Conforms to NativeFunction Syntax: '" + actual + "'." + (special ? "(" + special + ")" : "")
|
|
);
|
|
};
|