diff --git a/harness/sm/non262.js b/harness/sm/non262.js index 5148960a2b..89df923246 100644 --- a/harness/sm/non262.js +++ b/harness/sm/non262.js @@ -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; diff --git a/test/staging/sm/Function/function-toString-builtin.js b/test/staging/sm/Function/function-toString-builtin.js index eff9465de7..1a4a549c53 100644 --- a/test/staging/sm/Function/function-toString-builtin.js +++ b/test/staging/sm/Function/function-toString-builtin.js @@ -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);