From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- ...egExp-invalid-control-escape-character-class.js | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 js/src/tests/test262/annexB/built-ins/RegExp/RegExp-invalid-control-escape-character-class.js (limited to 'js/src/tests/test262/annexB/built-ins/RegExp/RegExp-invalid-control-escape-character-class.js') diff --git a/js/src/tests/test262/annexB/built-ins/RegExp/RegExp-invalid-control-escape-character-class.js b/js/src/tests/test262/annexB/built-ins/RegExp/RegExp-invalid-control-escape-character-class.js new file mode 100644 index 0000000000..0e9451e537 --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/RegExp/RegExp-invalid-control-escape-character-class.js @@ -0,0 +1,56 @@ +// Copyright 2017 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: prod-annexB-ClassAtomNoDash +description: > + Character classes containing an invalid control escape behave like [\\c] +info: | + ClassAtomNoDash :: `\` + + The production ClassAtomNoDash :: `\` evaluates as follows: + 1. Return the CharSet containing the single character `\`. +features: [generators] +---*/ + +function* invalidControls() { + // Check ASCII characters which are not in the extended range or syntax + // characters + for (let alpha = 0x00; alpha <= 0x7F; alpha++) { + let letter = String.fromCharCode(alpha); + if (!letter.match(/[0-9A-Za-z_\$(|)\[\]\/\\^]/)) { + yield letter; + } + } + yield ""; +} + +for (let letter of invalidControls()) { + var source = "[\\c" + letter + "]"; + var re = new RegExp(source); + + if (letter.length > 0) { + var char = letter.charCodeAt(0); + var str = String.fromCharCode(char % 32); + var arr = re.exec(str); + if (str !== letter && arr !== null) { + throw new Test262Error(`Character ${letter} unreasonably wrapped around as a control character`); + } + + arr = re.exec(letter); + if (arr === null) { + throw new Test262Error(`Character ${letter} missing from character class ${source}`); + } + } + arr = re.exec("\\") + if (arr === null) { + throw new Test262Error(`Character \\ missing from character class ${source}`); + } + arr = re.exec("c") + if (arr === null) { + throw new Test262Error(`Character c missing from character class ${source}`); + } +} + + +reportCompare(0, 0); -- cgit v1.2.3