Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/everything.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 = 'everything.js';
7
8 /**
9 Filename: everything.js
10 Description: 'Tests regular expressions'
11
12 Author: Nick Lerissa
13 Date: March 24, 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: everything.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24
25 // 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i)
26 new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)",
27 String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i)));
28
29 // 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))
30 new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))",
31 String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))));
32
33 // 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)
34 new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)",
35 String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)));
36
37 var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/;
38 // 'See Spot run.'.match(simpleSentence)
39 new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)",
40 String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence)));
41
42 // 'I like it. What's up? I said NO!'.match(simpleSentence)
43 new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)",
44 String(["I like it. What's up? I said NO!",' I said NO!']), String('I like it. What\'s up? I said NO!'.match(simpleSentence)));
45
46 // 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/)
47 new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)",
48 String(['the quick brown fox jumped over the lazy dogs','dogs','dogs']),String('the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/)));
49
50 test();