Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Regex Character Class Escape Tests #4195

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// Copyright (C) 2024 Aurèle Barrière. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: prod-CharacterClassEscape
description: Check that none of the non-digit characters are matched by \d.
info: |
21.2.2.12 CharacterClassEscape

The production CharacterClassEscape :: d evaluates as follows:
Return the ten-element set of characters containing the characters 0 through 9 inclusive.
features: [String.fromCodePoint]
includes: [regExpUtils.js]
---*/

const str = buildString({
loneCodePoints: [],
ranges: [
[0x000000, 0x00002F],
[0x00003A, 0x10FFFF],
],
});

const re = /\d/;
const re_u = /\d/u;

const regexes = [re, re_u];

const errors = [];

for (const regex of regexes) {
if (regex.test(str)) {
// Error, let's find out where
for (const char of str) {
if (regex.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
}
}
};

assert.sameValue(
errors.length,
0,
'Expected no match, but matched: ' + errors.join(',')
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (C) 2018 Leo Balter. All rights reserved.
// Copyright (C) 2024 Aurèle Barrière. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: prod-CharacterClassEscape
description: Check that all digit characters are matched by \d.
info: |
21.2.2.12 CharacterClassEscape

The production CharacterClassEscape :: d evaluates as follows:
Return the ten-element set of characters containing the characters 0 through 9 inclusive.
features: [String.fromCodePoint]
includes: [regExpUtils.js]
---*/

const str = buildString({
loneCodePoints: [],
ranges: [
[0x0030, 0x0039],
],
});

const re = /^\d+$/;
const re_u = /^\d+$/u;

const regexes = [re, re_u];

const errors = [];

for (const regex of regexes) {
if (!regex.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!regex.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
}
}
}
};

assert.sameValue(
errors.length,
0,
'Expected full match, but did not match: ' + errors.join(',')
);
Loading
Loading