node/deps/v8/test/mjsunit/regexp-14098.js
Michaël Zasso d8c97e4857
deps: update V8 to 11.9.169.7
PR-URL: https://github.com/nodejs/node/pull/50115
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2024-01-04 09:30:13 +01:00

31 lines
1.0 KiB
JavaScript

// Copyright 2023 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --enable-experimental-regexp-engine
// Flags: --no-default-to-experimental-regexp-engine
// An example where the Experimental regexp engine
// used to disagree with the backtracking engine and the specification
// for nullable quantifiers.
// v8:14098
var str = "ab";
// executed by the Experimental engine (l flag)
var exp_repetitions = /(?:a?b??){0,2}/l;
var exp_empty_star = /(?:a?b??)*/l;
// executed by the backtracking engine
var bt_empty_star = /(?:a?b??)*/;
// The engines should both match "ab":
// The first star repetition should match 'a'
// because ignoring 'b' has highest-priority.
// Then the greedy star should be entered again.
// Then the second repetition should match 'b',
// a non-empty repetition of the star.
assertEquals(["ab"], bt_empty_star.exec(str));
assertEquals(['ab'], exp_empty_star.exec(str));
assertEquals(['ab'], exp_repetitions.exec(str));