Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/asterisk.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 = 'asterisk.js';
7
8 /**
9 Filename: asterisk.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: aterisk.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 // 'abcddddefg'.match(new RegExp('d*'))
25 new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('d*'))",
26 String([""]), String('abcddddefg'.match(new RegExp('d*'))));
27
28 // 'abcddddefg'.match(new RegExp('cd*'))
29 new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('cd*'))",
30 String(["cdddd"]), String('abcddddefg'.match(new RegExp('cd*'))));
31
32 // 'abcdefg'.match(new RegExp('cx*d'))
33 new TestCase ( SECTION, "'abcdefg'.match(new RegExp('cx*d'))",
34 String(["cd"]), String('abcdefg'.match(new RegExp('cx*d'))));
35
36 // 'xxxxxxx'.match(new RegExp('(x*)(x+)'))
37 new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x*)(x+)'))",
38 String(["xxxxxxx","xxxxxx","x"]), String('xxxxxxx'.match(new RegExp('(x*)(x+)'))));
39
40 // '1234567890'.match(new RegExp('(\\d*)(\\d+)'))
41 new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)(\\d+)'))",
42 String(["1234567890","123456789","0"]),
43 String('1234567890'.match(new RegExp('(\\d*)(\\d+)'))));
44
45 // '1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))
46 new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))",
47 String(["1234567890","12345678","0"]),
48 String('1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))));
49
50 // 'xxxxxxx'.match(new RegExp('(x+)(x*)'))
51 new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x+)(x*)'))",
52 String(["xxxxxxx","xxxxxxx",""]), String('xxxxxxx'.match(new RegExp('(x+)(x*)'))));
53
54 // 'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))
55 new TestCase ( SECTION, "'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))",
56 String(["xxxxxxyyyyyy"]), String('xxxxxxyyyyyy'.match(new RegExp('x*y+$'))));
57
58 // 'abcdef'.match(/[\d]*[\s]*bc./)
59 new TestCase ( SECTION, "'abcdef'.match(/[\\d]*[\\s]*bc./)",
60 String(["bcd"]), String('abcdef'.match(/[\d]*[\s]*bc./)));
61
62 // 'abcdef'.match(/bc..[\d]*[\s]*/)
63 new TestCase ( SECTION, "'abcdef'.match(/bc..[\\d]*[\\s]*/)",
64 String(["bcde"]), String('abcdef'.match(/bc..[\d]*[\s]*/)));
65
66 // 'a1b2c3'.match(/.*/)
67 new TestCase ( SECTION, "'a1b2c3'.match(/.*/)",
68 String(["a1b2c3"]), String('a1b2c3'.match(/.*/)));
69
70 // 'a0.b2.c3'.match(/[xyz]*1/)
71 new TestCase ( SECTION, "'a0.b2.c3'.match(/[xyz]*1/)",
72 null, 'a0.b2.c3'.match(/[xyz]*1/));
73
74 test();