Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/test.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 = 'test.js';
7
8 /**
9 Filename: test.js
10 Description: 'Tests regular expressions method compile'
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: test';
20
21 writeHeaderToLog('Executing script: test.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 new TestCase ( SECTION,
25 "/[0-9]{3}/.test('23 2 34 678 9 09')",
26 true, /[0-9]{3}/.test('23 2 34 678 9 09'));
27
28 new TestCase ( SECTION,
29 "/[0-9]{3}/.test('23 2 34 78 9 09')",
30 false, /[0-9]{3}/.test('23 2 34 78 9 09'));
31
32 new TestCase ( SECTION,
33 "/\w+ \w+ \w+/.test('do a test')",
34 true, /\w+ \w+ \w+/.test("do a test"));
35
36 new TestCase ( SECTION,
37 "/\w+ \w+ \w+/.test('a test')",
38 false, /\w+ \w+ \w+/.test("a test"));
39
40 new TestCase ( SECTION,
41 "(new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')",
42 true, (new RegExp('[0-9]{3}')).test('23 2 34 678 9 09'));
43
44 new TestCase ( SECTION,
45 "(new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')",
46 false, (new RegExp('[0-9]{3}')).test('23 2 34 78 9 09'));
47
48 new TestCase ( SECTION,
49 "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('do a test')",
50 true, (new RegExp('\\w+ \\w+ \\w+')).test("do a test"));
51
52 new TestCase ( SECTION,
53 "(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test('a test')",
54 false, (new RegExp('\\w+ \\w+ \\w+')).test("a test"));
55
56 test();