Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/RegExp/S15.10.2.3_A1_T4.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 The | regular expression operator separates two alternatives.
7 The pattern first tries to match the left Alternative (followed by the sequel of the regular expression).
8 If it fails, it tries to match the right Disjunction (followed by the sequel of the regular expression)
9 es5id: 15.10.2.3_A1_T4
10 description: >
11 Execute /\d{3}|[a-z]{4}/.exec("2, 12 and 234 AND of course repeat
12 12") and check results
13 ---*/
14
15 var __executed = /\d{3}|[a-z]{4}/.exec("2, 12 and 234 AND of course repeat 12");
16
17 var __expected = ["234"];
18 __expected.index = 10;
19 __expected.input = "2, 12 and 234 AND of course repeat 12";
20
21 //CHECK#1
22 if (__executed.length !== __expected.length) {
23 $ERROR('#1: __executed = /\\d{3}|[a-z]{4}/.exec("2, 12 and 234 AND of course repeat 12"); __executed.length === ' + __expected.length + '. Actual: ' + __executed.length);
24 }
25
26 //CHECK#2
27 if (__executed.index !== __expected.index) {
28 $ERROR('#2: __executed = /\\d{3}|[a-z]{4}/.exec("2, 12 and 234 AND of course repeat 12"); __executed.index === ' + __expected.index + '. Actual: ' + __executed.index);
29 }
30
31 //CHECK#3
32 if (__executed.input !== __expected.input) {
33 $ERROR('#3: __executed = /\\d{3}|[a-z]{4}/.exec("2, 12 and 234 AND of course repeat 12"); __executed.input === ' + __expected.input + '. Actual: ' + __executed.input);
34 }
35
36 //CHECK#4
37 for(var index=0; index<__expected.length; index++) {
38 if (__executed[index] !== __expected[index]) {
39 $ERROR('#4: __executed = /\\d{3}|[a-z]{4}/.exec("2, 12 and 234 AND of course repeat 12"); __executed[' + index + '] === ' + __expected[index] + '. Actual: ' + __executed[index]);
40 }
41 }