|
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: backspace.js |
|
9 Description: 'Tests regular expressions containing [\b]' |
|
10 |
|
11 Author: Nick Lerissa |
|
12 Date: March 10, 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: [\b]'; |
|
19 |
|
20 writeHeaderToLog('Executing script: backspace.js'); |
|
21 writeHeaderToLog( SECTION + " "+ TITLE); |
|
22 |
|
23 // 'abc\bdef'.match(new RegExp('.[\b].')) |
|
24 new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('.[\\b].'))", |
|
25 String(["c\bd"]), String('abc\bdef'.match(new RegExp('.[\\b].')))); |
|
26 |
|
27 // 'abc\\bdef'.match(new RegExp('.[\b].')) |
|
28 new TestCase ( SECTION, "'abc\\bdef'.match(new RegExp('.[\\b].'))", |
|
29 null, 'abc\\bdef'.match(new RegExp('.[\\b].'))); |
|
30 |
|
31 // 'abc\b\b\bdef'.match(new RegExp('c[\b]{3}d')) |
|
32 new TestCase ( SECTION, "'abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d'))", |
|
33 String(["c\b\b\bd"]), String('abc\b\b\bdef'.match(new RegExp('c[\\b]{3}d')))); |
|
34 |
|
35 // 'abc\bdef'.match(new RegExp('[^\\[\b\\]]+')) |
|
36 new TestCase ( SECTION, "'abc\bdef'.match(new RegExp('[^\\[\\b\\]]+'))", |
|
37 String(["abc"]), String('abc\bdef'.match(new RegExp('[^\\[\\b\\]]+')))); |
|
38 |
|
39 // 'abcdef'.match(new RegExp('[^\\[\b\\]]+')) |
|
40 new TestCase ( SECTION, "'abcdef'.match(new RegExp('[^\\[\\b\\]]+'))", |
|
41 String(["abcdef"]), String('abcdef'.match(new RegExp('[^\\[\\b\\]]+')))); |
|
42 |
|
43 // 'abcdef'.match(/[^\[\b\]]+/) |
|
44 new TestCase ( SECTION, "'abcdef'.match(/[^\\[\\b\\]]+/)", |
|
45 String(["abcdef"]), String('abcdef'.match(/[^\[\b\]]+/))); |
|
46 |
|
47 test(); |