| 1 |
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 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 TITLE = 'RegExp: $&'; |
| 17 |
|
| 18 |
writeHeaderToLog('Executing script: RegExp_lastMatch_as_array.js'); |
| 19 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 20 |
|
| 21 |
|
| 22 |
// 'foo'.match(/foo/); RegExp['$&'] |
| 23 |
'foo'.match(/foo/); |
| 24 |
new TestCase ( "'foo'.match(/foo/); RegExp['$&']", |
| 25 |
'foo', RegExp['$&']); |
| 26 |
|
| 27 |
// 'foo'.match(new RegExp('foo')); RegExp['$&'] |
| 28 |
'foo'.match(new RegExp('foo')); |
| 29 |
new TestCase ( "'foo'.match(new RegExp('foo')); RegExp['$&']", |
| 30 |
'foo', RegExp['$&']); |
| 31 |
|
| 32 |
// 'xxx'.match(/bar/); RegExp['$&'] |
| 33 |
'xxx'.match(/bar/); |
| 34 |
new TestCase ( "'xxx'.match(/bar/); RegExp['$&']", |
| 35 |
'foo', RegExp['$&']); |
| 36 |
|
| 37 |
// 'xxx'.match(/$/); RegExp['$&'] |
| 38 |
'xxx'.match(/$/); |
| 39 |
new TestCase ( "'xxx'.match(/$/); RegExp['$&']", |
| 40 |
'', RegExp['$&']); |
| 41 |
|
| 42 |
// 'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&'] |
| 43 |
'abcdefg'.match(/^..(cd)[a-z]+/); |
| 44 |
new TestCase ( "'abcdefg'.match(/^..(cd)[a-z]+/); RegExp['$&']", |
| 45 |
'abcdefg', RegExp['$&']); |
| 46 |
|
| 47 |
// 'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); RegExp['$&'] |
| 48 |
'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\1/); |
| 49 |
new TestCase ( "'abcdefgabcdefg'.match(/(a(b(c(d)e)f)g)\\1/); RegExp['$&']", |
| 50 |
'abcdefgabcdefg', RegExp['$&']); |
| 51 |
|
| 52 |
test(); |