mirror of
https://github.com/tc39/test262.git
synced 2025-10-18 14:23:54 +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
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
// Copyright (C) 2017 Mathias Bynens. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
description: |
|
|
Collection of functions used to assert the correctness of RegExp objects.
|
|
---*/
|
|
|
|
function buildString({ loneCodePoints, ranges }) {
|
|
const CHUNK_SIZE = 10000;
|
|
let result = String.fromCodePoint(...loneCodePoints);
|
|
for (const [start, end] of ranges) {
|
|
const codePoints = [];
|
|
for (let length = 0, codePoint = start; codePoint <= end; codePoint++) {
|
|
codePoints[length++] = codePoint;
|
|
if (length === CHUNK_SIZE) {
|
|
result += String.fromCodePoint(...codePoints);
|
|
codePoints.length = length = 0;
|
|
}
|
|
}
|
|
result += String.fromCodePoint(...codePoints);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function testPropertyEscapes(regex, string, expression) {
|
|
if (!regex.test(string)) {
|
|
for (const symbol of string) {
|
|
const hex = symbol
|
|
.codePointAt(0)
|
|
.toString(16)
|
|
.toUpperCase()
|
|
.padStart(6, "0");
|
|
assert(
|
|
regex.test(symbol),
|
|
`\`${ expression }\` should match U+${ hex } (\`${ symbol }\`)`
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Returns a function that will validate RegExp match result
|
|
//
|
|
// Example:
|
|
//
|
|
// var validate = matchValidator(['b'], 1, 'abc');
|
|
// validate(/b/.exec('abc'));
|
|
//
|
|
function matchValidator(expectedEntries, expectedIndex, expectedInput) {
|
|
return function(match) {
|
|
assert.compareArray(match, expectedEntries, 'Match entries');
|
|
assert.sameValue(match.index, expectedIndex, 'Match index');
|
|
assert.sameValue(match.input, expectedInput, 'Match input');
|
|
}
|
|
}
|