Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/annexB/language/literals/regexp/quantifiable-assertion-followed-by.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-regular-expressions-patterns
5 es6id: B.1.4
6 description: Quantifiable assertions `?=` ("followed by")
7 info: |
8 Term[U] ::
9 [~U] QuantifiableAssertion Quantifier
10
11 QuantifiableAssertion ::
12 ( ?= Disjunction )
13 ( ?! Disjunction )
14
15 The production Term::QuantifiableAssertionQuantifier evaluates the same as
16 the production Term::AtomQuantifier but with QuantifiableAssertion
17 substituted for Atom.
18
19 The production Assertion::QuantifiableAssertion evaluates by evaluating
20 QuantifiableAssertion to obtain a Matcher and returning that Matcher.
21
22 Assertion (21.2.2.6) evaluation rules for the Assertion::(?=Disjunction)
23 and Assertion::(?!Disjunction) productions are also used for the
24 QuantifiableAssertion productions, but with QuantifiableAssertion
25 substituted for Assertion.
26 ---*/
27
28 var match;
29
30 match = /.(?=Z)*/.exec('a bZ cZZ dZZZ eZZZZ');
31 assert.sameValue(match[0], 'a', 'quantifier: *');
32
33 match = /.(?=Z)+/.exec('a bZ cZZ dZZZ eZZZZ');
34 assert.sameValue(match[0], 'b', 'quantifier: +');
35
36 match = /.(?=Z)?/.exec('a bZ cZZ dZZZ eZZZZ');
37 assert.sameValue(match[0], 'a', 'quantifier: ?');
38
39 match = /.(?=Z){2}/.exec('a bZ cZZ dZZZ eZZZZ');
40 assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits }');
41
42 match = /.(?=Z){2,}/.exec('a bZ cZZ dZZZ eZZZZ');
43 assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits , }');
44
45 match = /.(?=Z){2,3}/.exec('a bZ cZZ dZZZ eZZZZ');
46 assert.sameValue(
47 match[0], 'b', 'quantifier: { DecimalDigits , DecimalDigits }'
48 );
49
50 match = /.(?=Z)*?/.exec('a bZ cZZ dZZZ eZZZZ');
51 assert.sameValue(match[0], 'a', 'quantifier: * ?');
52
53 match = /.(?=Z)+?/.exec('a bZ cZZ dZZZ eZZZZ');
54 assert.sameValue(match[0], 'b', 'quantifier: + ?');
55
56 match = /.(?=Z)??/.exec('a bZ cZZ dZZZ eZZZZ');
57 assert.sameValue(match[0], 'a', 'quantifier: ? ?');
58
59 match = /.(?=Z){2}?/.exec('a bZ cZZ dZZZ eZZZZ');
60 assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits } ?');
61
62 match = /.(?=Z){2,}?/.exec('a bZ cZZ dZZZ eZZZZ');
63 assert.sameValue(match[0], 'b', 'quantifier: { DecimalDigits , } ?');
64
65 match = /.(?=Z){2,3}?/.exec('a bZ cZZ dZZZ eZZZZ');
66 assert.sameValue(
67 match[0], 'b', 'quantifier: { DecimalDigits , DecimalDigits } ?'
68 );