Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/RegExp_lastMatch_as_array.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 = 'RegExp_lastMatch_as_array.js';
7
8 /**
9 Filename: RegExp_lastMatch_as_array.js
10 Description: 'Tests RegExps $& property (same tests as RegExp_lastMatch.js but using $&)'
11
12 Author: Nick Lerissa
13 Date: March 13, 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: RegExp_lastMatch_as_array.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24
25 // 'foo'.match(/foo/); RegExp['$&']
26 'foo'.match(/foo/);
27 new TestCase ( SECTION, "'foo'.match(/foo/); RegExp['$&']",
28 'foo', RegExp['$&']);
29
30 // 'foo'.match(new RegExp('foo')); RegExp['$&']
31 'foo'.match(new RegExp('foo'));
32 new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp['$&']",
33 'foo', RegExp['$&']);
34
35 // 'xxx'.match(/bar/); RegExp['$&']
36 'xxx'.match(/bar/);
37 new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp['$&']",
38 'foo', RegExp['$&']);
39
40 // 'xxx'.match(/$/); RegExp['$&']
41 'xxx'.match(/$/);
42 new TestCase ( SECTION, "'xxx'.match(/$/); RegExp['$&']",
43 '', RegExp['$&']);
44
45 // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']
46 'abcdefg'.match(/^..(cd)[a-z]+/);
47 new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']",
48 'abcdefg', RegExp['$&']);
49
50 // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&']
51 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/);
52 new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']",
53 'abcdefgabcdefg', RegExp['$&']);
54
55 test();