Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/simple_form.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 = 'simple_form.js';
7
8 /**
9 Filename: simple_form.js
10 Description: 'Tests regular expressions using simple form: re(...)'
11
12 Author: Nick Lerissa
13 Date: March 19, 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: simple form';
20
21 writeHeaderToLog('Executing script: simple_form.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 new TestCase ( SECTION,
25 "/[0-9]{3}/('23 2 34 678 9 09')",
26 String(["678"]), String(/[0-9]{3}/('23 2 34 678 9 09')));
27
28 new TestCase ( SECTION,
29 "/3.{4}8/('23 2 34 678 9 09')",
30 String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09')));
31
32 new TestCase ( SECTION,
33 "(/3.{4}8/('23 2 34 678 9 09').length",
34 1, (/3.{4}8/('23 2 34 678 9 09')).length);
35
36 var re = /[0-9]{3}/;
37 new TestCase ( SECTION,
38 "re('23 2 34 678 9 09')",
39 String(["678"]), String(re('23 2 34 678 9 09')));
40
41 re = /3.{4}8/;
42 new TestCase ( SECTION,
43 "re('23 2 34 678 9 09')",
44 String(["34 678"]), String(re('23 2 34 678 9 09')));
45
46 new TestCase ( SECTION,
47 "/3.{4}8/('23 2 34 678 9 09')",
48 String(["34 678"]), String(/3.{4}8/('23 2 34 678 9 09')));
49
50 re =/3.{4}8/;
51 new TestCase ( SECTION,
52 "(re('23 2 34 678 9 09').length",
53 1, (re('23 2 34 678 9 09')).length);
54
55 new TestCase ( SECTION,
56 "(/3.{4}8/('23 2 34 678 9 09').length",
57 1, (/3.{4}8/('23 2 34 678 9 09')).length);
58
59 test();