diff --git a/test/built-ins/RegExp/prototype/source/value-carriage-return.js b/test/built-ins/RegExp/prototype/source/value-carriage-return.js new file mode 100644 index 00000000000..e6d544a2984 --- /dev/null +++ b/test/built-ins/RegExp/prototype/source/value-carriage-return.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 dmvjs. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-regexp.prototype.source +description: > + Return value can be used to create an equivalent RegExp when the + [[OriginalSource]] internal slot contains a carriage return (U+000D) +info: | + [...] + 5. Let src be R.[[OriginalSource]]. + 6. Let flags be R.[[OriginalFlags]]. + 7. Return EscapeRegExpPattern(src, flags). + + 21.2.3.2.4 Runtime Semantics: EscapeRegExpPattern + + [...] the internal procedure that would result from evaluating S as a + Pattern[~U] (Pattern[+U] if F contains "u") must behave identically to the + internal procedure given by the constructed object's [[RegExpMatcher]] + internal slot. +---*/ + +var re = eval('/' + new RegExp('\r').source + '/'); + +assert.sameValue(re.test('\r'), true, 'input: "\\r"'); +assert.sameValue(re.test('_\r_'), true, 'input: "_\\r_"'); +assert.sameValue(re.test('\\r'), false, 'input: "\\\\r"'); +assert.sameValue(re.test('\n'), false, 'input: "\\n"'); +assert.sameValue(re.test('r'), false, 'input: "r"'); diff --git a/test/built-ins/RegExp/prototype/source/value-line-separator.js b/test/built-ins/RegExp/prototype/source/value-line-separator.js new file mode 100644 index 00000000000..a9de29f407a --- /dev/null +++ b/test/built-ins/RegExp/prototype/source/value-line-separator.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 dmvjs. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-regexp.prototype.source +description: > + Return value can be used to create an equivalent RegExp when the + [[OriginalSource]] internal slot contains a line separator (U+2028) +info: | + [...] + 5. Let src be R.[[OriginalSource]]. + 6. Let flags be R.[[OriginalFlags]]. + 7. Return EscapeRegExpPattern(src, flags). + + 21.2.3.2.4 Runtime Semantics: EscapeRegExpPattern + + [...] the internal procedure that would result from evaluating S as a + Pattern[~U] (Pattern[+U] if F contains "u") must behave identically to the + internal procedure given by the constructed object's [[RegExpMatcher]] + internal slot. +---*/ + +var re = eval('/' + new RegExp('\u2028').source + '/'); + +assert.sameValue(re.test('\u2028'), true, 'input: "\\u2028"'); +assert.sameValue(re.test('_\u2028_'), true, 'input: "_\\u2028_"'); +assert.sameValue(re.test('\\u2028'), false, 'input: "\\\\u2028"'); +assert.sameValue(re.test('\u2029'), false, 'input: "\\u2029"'); +assert.sameValue(re.test('\n'), false, 'input: "\\n"'); diff --git a/test/built-ins/RegExp/prototype/source/value-paragraph-separator.js b/test/built-ins/RegExp/prototype/source/value-paragraph-separator.js new file mode 100644 index 00000000000..1e4b662c551 --- /dev/null +++ b/test/built-ins/RegExp/prototype/source/value-paragraph-separator.js @@ -0,0 +1,28 @@ +// Copyright (C) 2026 dmvjs. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-get-regexp.prototype.source +description: > + Return value can be used to create an equivalent RegExp when the + [[OriginalSource]] internal slot contains a paragraph separator (U+2029) +info: | + [...] + 5. Let src be R.[[OriginalSource]]. + 6. Let flags be R.[[OriginalFlags]]. + 7. Return EscapeRegExpPattern(src, flags). + + 21.2.3.2.4 Runtime Semantics: EscapeRegExpPattern + + [...] the internal procedure that would result from evaluating S as a + Pattern[~U] (Pattern[+U] if F contains "u") must behave identically to the + internal procedure given by the constructed object's [[RegExpMatcher]] + internal slot. +---*/ + +var re = eval('/' + new RegExp('\u2029').source + '/'); + +assert.sameValue(re.test('\u2029'), true, 'input: "\\u2029"'); +assert.sameValue(re.test('_\u2029_'), true, 'input: "_\\u2029_"'); +assert.sameValue(re.test('\\u2029'), false, 'input: "\\\\u2029"'); +assert.sameValue(re.test('\u2028'), false, 'input: "\\u2028"'); +assert.sameValue(re.test('\n'), false, 'input: "\\n"');