Remove reportMatch

This commit is contained in:
André Bargull 2025-04-30 14:15:31 +02:00 committed by Ms2ger
parent a06e66989b
commit e778def1d1
2 changed files with 13 additions and 43 deletions

View File

@ -1,5 +1,5 @@
/*---
defines: [assertThrownErrorContains, assertThrowsInstanceOfWithMessageCheck, newGlobal, print, assertEq, reportCompare, reportMatch, createIsHTMLDDA, createExternalArrayBuffer]
defines: [assertThrownErrorContains, assertThrowsInstanceOfWithMessageCheck, newGlobal, print, assertEq, reportCompare, createIsHTMLDDA, createExternalArrayBuffer]
---*/
function assertThrownErrorContains(f, substr) {
@ -43,13 +43,6 @@ function reportCompare(...args) {
assert.sameValue(...args)
}
function reportMatch(expectedRegExp, actual, description = "") {
assert.sameValue(typeof actual, "string",
`Type mismatch, expected string, actual type ${typeof actual}`);
assert.notSameValue(expectedRegExp.exec(actual), null,
`Expected match to '${expectedRegExp}', Actual value '${actual}'`);
}
if (globalThis.createIsHTMLDDA === undefined) {
globalThis.createIsHTMLDDA = function createIsHTMLDDA() {
return $262.IsHTMLDDA;

View File

@ -2,52 +2,29 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
includes: [sm/non262.js, sm/non262-shell.js]
flags:
- noStrict
includes: [nativeFunctionMatcher.js]
description: |
pending
esid: pending
---*/
// Greatly (!) simplified patterns for the PropertyName production.
var propertyName = [
// PropertyName :: LiteralPropertyName :: IdentifierName
"\\w+",
// PropertyName :: LiteralPropertyName :: StringLiteral
"(?:'[^']*')",
"(?:\"[^\"]*\")",
// PropertyName :: LiteralPropertyName :: NumericLiteral
"\\d+",
// PropertyName :: ComputedPropertyName
"(?:\\[[^\\]]+\\])",
].join("|")
var nativeCode = RegExp([
"^", "function", "(get|set)?", ("(" + propertyName + ")?"), "\\(", "\\)", "\\{", "\\[native code\\]", "\\}", "$"
].join("\\s*"));
// Bound functions are considered built-ins.
reportMatch(nativeCode, function(){}.bind().toString());
reportMatch(nativeCode, function fn(){}.bind().toString());
assertNativeFunction(function(){}.bind());
assertNativeFunction(function fn(){}.bind());
// Built-ins which are well-known intrinsic objects.
reportMatch(nativeCode, Array.toString());
reportMatch(nativeCode, Object.prototype.toString.toString());
reportMatch(nativeCode, decodeURI.toString());
assertNativeFunction(Array);
assertNativeFunction(Object.prototype.toString);
assertNativeFunction(decodeURI);
// Other built-in functions.
reportMatch(nativeCode, Math.asin.toString());
reportMatch(nativeCode, String.prototype.blink.toString());
reportMatch(nativeCode, RegExp.prototype[Symbol.split].toString());
assertNativeFunction(Math.asin);
assertNativeFunction(String.prototype.blink);
assertNativeFunction(RegExp.prototype[Symbol.split]);
// Built-in getter functions.
reportMatch(nativeCode, Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get.toString());
reportMatch(nativeCode, Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").get.toString());
assertNativeFunction(Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get);
assertNativeFunction(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").get);
// Built-in setter functions.
reportMatch(nativeCode, Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").set.toString());
assertNativeFunction(Object.getOwnPropertyDescriptor(Object.prototype, "__proto__").set);