Source code

Revision control

Copy as Markdown

Other Tools

// |reftest| shell-option(--enable-regexp-buffer-boundaries) skip-if(release_or_beta||!xulRuntime.shell) -- regexp-buffer-boundaries is not released yet, requires shell-options
// Copyright 2026 Ron Buckton. All rights reserved.↩
// This code is governed by the BSD license found in the LICENSE file.↩
/*---↩
author: Ron Buckton↩
description: >↩
`\A` matches start of buffer in u-mode.↩
info: |↩
Runtime Semantics: CompileAssertion↩
Assertion :: \A↩
1. Return a new Matcher with parameters (matchState, continue) that captures nothing and performs the following steps when called:↩
a. Assert: matchState is a MatchState.↩
b. Assert: continue is a MatcherContinuation.↩
c. Let e be matchState.[[EndIndex]].↩
d. If e = 0, return continue(matchState).↩
e. Return ~failure~.↩
esid: sec-patterns↩
features: [regexp-buffer-boundaries]↩
---*/
assert(/\Ax/u.test("x"), "Expected \\A to match start-of-buffer outside of multiline mode (literal)");↩
assert(/\Ax/um.test("x"), "Expected \\A to match start-of-buffer inside of multiline mode (literal)");↩
assert(!/\Ax/u.test("yx"), "Expected \\A to not match when not at start-of-buffer outside of multiline mode (literal)");↩
assert(!/\Ax/um.test("yx"), "Expected \\A to not match when not at start-of-buffer inside of multiline mode (literal)");↩
assert(!/\Ax/u.test("\nx"), "Expected \\A to not match when at start-of-new-line outside of multiline mode (literal)");↩
assert(!/\Ax/um.test("\nx"), "Expected \\A to not match when at start-of-new-line inside of multiline mode (literal)");↩
assert(new RegExp("\\Ax", "u").test("x"), "Expected \\A to match start-of-buffer outside of multiline mode (constructed)");↩
assert(new RegExp("\\Ax", "um").test("x"), "Expected \\A to match start-of-buffer inside of multiline mode (constructed)");↩
assert(!new RegExp("\\Ax", "u").test("yx"), "Expected \\A to not match when not at start-of-buffer outside of multiline mode (constructed)");↩
assert(!new RegExp("\\Ax", "um").test("yx"), "Expected \\A to not match when not at start-of-buffer inside of multiline mode (constructed)");↩
assert(!new RegExp("\\Ax", "u").test("\nx"), "Expected \\A to not match when at start-of-new-line outside of multiline mode (constructed)");↩
assert(!new RegExp("\\Ax", "um").test("\nx"), "Expected \\A to not match when at start-of-new-line inside of multiline mode (constructed)");↩
reportCompare(0, 0);