Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/backslash.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 = 'backslash.js';
7
8 /**
9 Filename: backslash.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: backslash.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 // 'abcde'.match(new RegExp('\e'))
25 new TestCase ( SECTION, "'abcde'.match(new RegExp('\e'))",
26 String(["e"]), String('abcde'.match(new RegExp('\e'))));
27
28 // 'ab\\cde'.match(new RegExp('\\\\'))
29 new TestCase ( SECTION, "'ab\\cde'.match(new RegExp('\\\\'))",
30 String(["\\"]), String('ab\\cde'.match(new RegExp('\\\\'))));
31
32 // 'ab\\cde'.match(/\\/) (using literal)
33 new TestCase ( SECTION, "'ab\\cde'.match(/\\\\/)",
34 String(["\\"]), String('ab\\cde'.match(/\\/)));
35
36 // 'before ^$*+?.()|{}[] after'.match(new RegExp('\^\$\*\+\?\.\(\)\|\{\}\[\]'))
37 new TestCase ( SECTION,
38 "'before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))",
39 String(["^$*+?.()|{}[]"]),
40 String('before ^$*+?.()|{}[] after'.match(new RegExp('\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]'))));
41
42 // 'before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/) (using literal)
43 new TestCase ( SECTION,
44 "'before ^$*+?.()|{}[] after'.match(/\\^\\$\\*\\+\\?\\.\\(\\)\\|\\{\\}\\[\\]/)",
45 String(["^$*+?.()|{}[]"]),
46 String('before ^$*+?.()|{}[] after'.match(/\^\$\*\+\?\.\(\)\|\{\}\[\]/)));
47
48 test();