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 #4364

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
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// 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: >
Compare range for digit class escape \d with flags g
Check negative cases of digit class escape \d.
info: |
This is a generated test. Please check out
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
Expand Down Expand Up @@ -45,28 +46,38 @@ includes: [regExpUtils.js]
flags: [generated]
---*/

const str = buildString({
loneCodePoints: [],
ranges: [
[0x000030, 0x000039],
],
});
const str = buildString(
{
loneCodePoints: [],
ranges: [
[0x00DC00, 0x00DFFF],
[0x000000, 0x00002F],
[0x00003A, 0x00DBFF],
[0x00E000, 0x10FFFF]
]
}
);

const re = /\d/g;
const standard = /\d/;
const unicode = /\d/u;
const vflag = /\d/v;
const regexes = [standard,unicode,vflag];

const errors = [];

if (!re.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
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 matching code points, but received: ' + errors.join(',')
'Expected no match, but matched: ' + errors.join(',')
);
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// 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: >
Compare range for digit class escape \d+ with flags ug
Check positive cases of digit class escape \d.
info: |
This is a generated test. Please check out
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
Expand Down Expand Up @@ -45,28 +46,35 @@ includes: [regExpUtils.js]
flags: [generated]
---*/

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

const re = /\d+/ug;
const standard = /^\d+$/;
const unicode = /^\d+$/u;
const vflag = /^\d+$/v;
const regexes = [standard,unicode,vflag];

const errors = [];

if (!re.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
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 matching code points, but received: ' + errors.join(',')
'Expected full match, but did not match: ' + errors.join(',')
);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// 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: >
Compare range for digit class escape \d with flags ug
Check negative cases of non-digit class escape \D.
info: |
This is a generated test. Please check out
https://github.com/tc39/test262/tree/main/tools/regexp-generator/
Expand Down Expand Up @@ -45,28 +46,35 @@ includes: [regExpUtils.js]
flags: [generated]
---*/

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

const re = /\d/ug;
const standard = /\D/;
const unicode = /\D/u;
const vflag = /\D/v;
const regexes = [standard,unicode,vflag];

const errors = [];

if (!re.test(str)) {
// Error, let's find out where
for (const char of str) {
if (!re.test(char)) {
errors.push('0x' + char.codePointAt(0).toString(16));
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 matching code points, but received: ' + errors.join(',')
'Expected no match, but matched: ' + errors.join(',')
);

This file was deleted.

Loading
Loading