Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/RegExp/S15.10.2.3_A1_T15.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_T15
10 description: >
11 Execute /(Rob)|(Bob)|(Robert)|(Bobby)/.exec("Hi Bob") and check
12 results
13 ---*/
14
15 var __executed = /(Rob)|(Bob)|(Robert)|(Bobby)/.exec("Hi Bob");
16
17 var __expected = ["Bob",undefined,"Bob", undefined, undefined];
18 __expected.index = 3;
19 __expected.input = "Hi Bob";
20
21 //CHECK#1
22 if (__executed.length !== __expected.length) {
23 $ERROR('#1: __executed = /(Rob)|(Bob)|(Robert)|(Bobby)/.exec("Hi Bob"); __executed.length === ' + __expected.length + '. Actual: ' + __executed.length);
24 }
25
26 //CHECK#2
27 if (__executed.index !== __expected.index) {
28 $ERROR('#2: __executed = /(Rob)|(Bob)|(Robert)|(Bobby)/.exec("Hi Bob"); __executed.index === ' + __expected.index + '. Actual: ' + __executed.index);
29 }
30
31 //CHECK#3
32 if (__executed.input !== __expected.input) {
33 $ERROR('#3: __executed = /(Rob)|(Bob)|(Robert)|(Bobby)/.exec("Hi Bob"); __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 = /(Rob)|(Bob)|(Robert)|(Bobby)/.exec("Hi Bob"); __executed[' + index + '] === ' + __expected[index] + '. Actual: ' + __executed[index]);
40 }
41 }