1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/everything.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + Filename: everything.js 1.12 + Description: 'Tests regular expressions' 1.13 + 1.14 + Author: Nick Lerissa 1.15 + Date: March 24, 1998 1.16 +*/ 1.17 + 1.18 +var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; 1.19 +var VERSION = 'no version'; 1.20 +startTest(); 1.21 +var TITLE = 'RegExp'; 1.22 + 1.23 +writeHeaderToLog('Executing script: everything.js'); 1.24 +writeHeaderToLog( SECTION + " "+ TITLE); 1.25 + 1.26 + 1.27 +// 'Sally and Fred are sure to come.'.match(/^[a-z\s]*/i) 1.28 +new TestCase ( SECTION, "'Sally and Fred are sure to come'.match(/^[a-z\\s]*/i)", 1.29 + String(["Sally and Fred are sure to come"]), String('Sally and Fred are sure to come'.match(/^[a-z\s]*/i))); 1.30 + 1.31 +// 'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')) 1.32 +new TestCase ( SECTION, "'test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$'))", 1.33 + String(["test123W+xyz","xyz"]), String('test123W+xyz'.match(new RegExp('^[a-z]*[0-9]+[A-Z]?.(123|xyz)$')))); 1.34 + 1.35 +// 'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/) 1.36 +new TestCase ( SECTION, "'number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/)", 1.37 + String(["12365 number two 9898","12365","9898"]), String('number one 12365 number two 9898'.match(/(\d+)\D+(\d+)/))); 1.38 + 1.39 +var simpleSentence = /(\s?[^\!\?\.]+[\!\?\.])+/; 1.40 +// 'See Spot run.'.match(simpleSentence) 1.41 +new TestCase ( SECTION, "'See Spot run.'.match(simpleSentence)", 1.42 + String(["See Spot run.","See Spot run."]), String('See Spot run.'.match(simpleSentence))); 1.43 + 1.44 +// 'I like it. What's up? I said NO!'.match(simpleSentence) 1.45 +new TestCase ( SECTION, "'I like it. What's up? I said NO!'.match(simpleSentence)", 1.46 + 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))); 1.47 + 1.48 +// 'the quick brown fox jumped over the lazy dogs'.match(/((\w+)\s*)+/) 1.49 +new TestCase ( SECTION, "'the quick brown fox jumped over the lazy dogs'.match(/((\\w+)\\s*)+/)", 1.50 + 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*)+/))); 1.51 + 1.52 +test();