js/src/tests/js1_2/regexp/everything.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial