tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

everything.js (2254B)


      1 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 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 
      7 /**
      8   Filename:     everything.js
      9   Description:  'Tests regular expressions'
     10 
     11   Author:       Nick Lerissa
     12   Date:         March 24, 1998
     13 */
     14 
     15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
     16 var TITLE   = 'RegExp';
     17 
     18 writeHeaderToLog('Executing script: everything.js');
     19 writeHeaderToLog( SECTION + " "+ TITLE);
     20 
     21 
     22 // 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i)
     23 new TestCase ( "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)",
     24        String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i)));
     25 
     26 // 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))
     27 new TestCase ( "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))",
     28        String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))));
     29 
     30 // 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)
     31 new TestCase ( "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)",
     32        String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)));
     33 
     34 var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/;
     35 // 'See Spot run.'.match(simpleSentence)
     36 new TestCase ( "'See Spot run.'.match(simpleSentence)",
     37        String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence)));
     38 
     39 // 'I like it. What's up? I said NO!'.match(simpleSentence)
     40 new TestCase ( "'I like it. What's up? I said NO!'.match(simpleSentence)",
     41        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)));
     42 
     43 // 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/)
     44 new TestCase ( "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)",
     45        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*)+/)));
     46 
     47 test();