From 7fa6b83bb2c1da4b8331a99b24367ea240f724cb Mon Sep 17 00:00:00 2001 From: Steven Levithan Date: Sat, 2 Nov 2024 19:45:08 +0100 Subject: [PATCH] Fix tests --- README.md | 5 ++--- spec/helpers/features.js | 12 +++++++++++- spec/match-char-set.spec.js | 6 +++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 16cc159..17f7bfb 100644 --- a/README.md +++ b/README.md @@ -423,17 +423,16 @@ Notice that nearly every feature below has at least subtle differences from Java ✅ ✅ - ✔ Any char (any flags)
+ ✔ Any char (with any flags)
✔ Identity escape in char class
- Non-newline + Not newline \N ✅ ✅ - ✔ Excludes only \n (any flags)
✔ Identity escape in char class
diff --git a/spec/helpers/features.js b/spec/helpers/features.js index 9f334c2..a223a54 100644 --- a/spec/helpers/features.js +++ b/spec/helpers/features.js @@ -6,9 +6,19 @@ const duplicateCaptureNamesSupported = (() => { } return true; })(); - const maxTargetForDuplicateNames = duplicateCaptureNamesSupported ? null : 'ES2024'; +const patternModsSupported = (() => { + try { + new RegExp('(?i:)'); + } catch (e) { + return false; + } + return true; +})(); +const maxTargetForPatternMods = patternModsSupported ? null : 'ESNext'; + export { maxTargetForDuplicateNames, + maxTargetForPatternMods, }; diff --git a/spec/match-char-set.spec.js b/spec/match-char-set.spec.js index dd103b9..4474725 100644 --- a/spec/match-char-set.spec.js +++ b/spec/match-char-set.spec.js @@ -1,4 +1,5 @@ import {r} from '../src/utils.js'; +import {maxTargetForPatternMods} from './helpers/features.js'; import {matchers} from './helpers/matchers.js'; beforeEach(() => { @@ -14,7 +15,10 @@ describe('CharacterSet', () => { }); it('should match line feed with flag m disabled', () => { - expect('\n').toExactlyMatch(r`(?-m)\O`); + expect('\n').toExactlyMatch({ + pattern: r`(?-m)\O`, + maxTarget: maxTargetForPatternMods, + }); }); it('should be identity escape within a char class', () => {