js/src/tests/js1_2/regexp/RegExp_lastMatch_as_array.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:246d3a380864
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
7 /**
8 Filename: RegExp_lastMatch_as_array.js
9 Description: 'Tests RegExps $& property (same tests as RegExp_lastMatch.js but using $&)'
10
11 Author: Nick Lerissa
12 Date: March 13, 1998
13 */
14
15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
16 var VERSION = 'no version';
17 startTest();
18 var TITLE = 'RegExp: $&';
19
20 writeHeaderToLog('Executing script: RegExp_lastMatch_as_array.js');
21 writeHeaderToLog( SECTION + " "+ TITLE);
22
23
24 // 'foo'.match(/foo/); RegExp['$&']
25 'foo'.match(/foo/);
26 new TestCase ( SECTION, "'foo'.match(/foo/); RegExp['$&']",
27 'foo', RegExp['$&']);
28
29 // 'foo'.match(new RegExp('foo')); RegExp['$&']
30 'foo'.match(new RegExp('foo'));
31 new TestCase ( SECTION, "'foo'.match(new RegExp('foo')); RegExp['$&']",
32 'foo', RegExp['$&']);
33
34 // 'xxx'.match(/bar/); RegExp['$&']
35 'xxx'.match(/bar/);
36 new TestCase ( SECTION, "'xxx'.match(/bar/); RegExp['$&']",
37 'foo', RegExp['$&']);
38
39 // 'xxx'.match(/$/); RegExp['$&']
40 'xxx'.match(/$/);
41 new TestCase ( SECTION, "'xxx'.match(/$/); RegExp['$&']",
42 '', RegExp['$&']);
43
44 // 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']
45 'abcdefg'.match(/^..(cd)[a-z]+/);
46 new TestCase ( SECTION, "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']",
47 'abcdefg', RegExp['$&']);
48
49 // 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&']
50 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/);
51 new TestCase ( SECTION, "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']",
52 'abcdefgabcdefg', RegExp['$&']);
53
54 test();

mercurial