Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/vertical_bar.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'vertical_bar.js';
7
8 /**
9 Filename: vertical_bar.js
10 Description: 'Tests regular expressions containing |'
11
12 Author: Nick Lerissa
13 Date: March 10, 1998
14 */
15
16 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
17 var VERSION = 'no version';
18 startTest();
19 var TITLE = 'RegExp: |';
20
21 writeHeaderToLog('Executing script: vertical_bar.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24
25 // 'abc'.match(new RegExp('xyz|abc'))
26 new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))",
27 String(["abc"]), String('abc'.match(new RegExp('xyz|abc'))));
28
29 // 'this is a test'.match(new RegExp('quiz|exam|test|homework'))
30 new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))",
31 String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework'))));
32
33 // 'abc'.match(new RegExp('xyz|...'))
34 new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))",
35 String(["abc"]), String('abc'.match(new RegExp('xyz|...'))));
36
37 // 'abc'.match(new RegExp('(.)..|abc'))
38 new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))",
39 String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc'))));
40
41 // 'color: grey'.match(new RegExp('.+: gr(a|e)y'))
42 new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))",
43 String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y'))));
44
45 // 'no match'.match(new RegExp('red|white|blue'))
46 new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))",
47 null, 'no match'.match(new RegExp('red|white|blue')));
48
49 // 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))
50 new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))",
51 String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))));
52
53 // 'abcdef'.match(new RegExp('abc|bcd|cde|def'))
54 new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))",
55 String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def'))));
56
57 // 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)
58 new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)",
59 String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)));
60
61 // 'abcdef'.match(/abc|bcd|cde|def/)
62 new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)",
63 String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/)));
64
65 test();