1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/asterisk.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 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: asterisk.js 1.12 + Description: 'Tests regular expressions containing *' 1.13 + 1.14 + Author: Nick Lerissa 1.15 + Date: March 10, 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: aterisk.js'); 1.24 +writeHeaderToLog( SECTION + " "+ TITLE); 1.25 + 1.26 +// 'abcddddefg'.match(new RegExp('d*')) 1.27 +new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('d*'))", 1.28 + String([""]), String('abcddddefg'.match(new RegExp('d*')))); 1.29 + 1.30 +// 'abcddddefg'.match(new RegExp('cd*')) 1.31 +new TestCase ( SECTION, "'abcddddefg'.match(new RegExp('cd*'))", 1.32 + String(["cdddd"]), String('abcddddefg'.match(new RegExp('cd*')))); 1.33 + 1.34 +// 'abcdefg'.match(new RegExp('cx*d')) 1.35 +new TestCase ( SECTION, "'abcdefg'.match(new RegExp('cx*d'))", 1.36 + String(["cd"]), String('abcdefg'.match(new RegExp('cx*d')))); 1.37 + 1.38 +// 'xxxxxxx'.match(new RegExp('(x*)(x+)')) 1.39 +new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x*)(x+)'))", 1.40 + String(["xxxxxxx","xxxxxx","x"]), String('xxxxxxx'.match(new RegExp('(x*)(x+)')))); 1.41 + 1.42 +// '1234567890'.match(new RegExp('(\\d*)(\\d+)')) 1.43 +new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)(\\d+)'))", 1.44 + String(["1234567890","123456789","0"]), 1.45 + String('1234567890'.match(new RegExp('(\\d*)(\\d+)')))); 1.46 + 1.47 +// '1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')) 1.48 +new TestCase ( SECTION, "'1234567890'.match(new RegExp('(\\d*)\\d(\\d+)'))", 1.49 + String(["1234567890","12345678","0"]), 1.50 + String('1234567890'.match(new RegExp('(\\d*)\\d(\\d+)')))); 1.51 + 1.52 +// 'xxxxxxx'.match(new RegExp('(x+)(x*)')) 1.53 +new TestCase ( SECTION, "'xxxxxxx'.match(new RegExp('(x+)(x*)'))", 1.54 + String(["xxxxxxx","xxxxxxx",""]), String('xxxxxxx'.match(new RegExp('(x+)(x*)')))); 1.55 + 1.56 +// 'xxxxxxyyyyyy'.match(new RegExp('x*y+$')) 1.57 +new TestCase ( SECTION, "'xxxxxxyyyyyy'.match(new RegExp('x*y+$'))", 1.58 + String(["xxxxxxyyyyyy"]), String('xxxxxxyyyyyy'.match(new RegExp('x*y+$')))); 1.59 + 1.60 +// 'abcdef'.match(/[\d]*[\s]*bc./) 1.61 +new TestCase ( SECTION, "'abcdef'.match(/[\\d]*[\\s]*bc./)", 1.62 + String(["bcd"]), String('abcdef'.match(/[\d]*[\s]*bc./))); 1.63 + 1.64 +// 'abcdef'.match(/bc..[\d]*[\s]*/) 1.65 +new TestCase ( SECTION, "'abcdef'.match(/bc..[\\d]*[\\s]*/)", 1.66 + String(["bcde"]), String('abcdef'.match(/bc..[\d]*[\s]*/))); 1.67 + 1.68 +// 'a1b2c3'.match(/.*/) 1.69 +new TestCase ( SECTION, "'a1b2c3'.match(/.*/)", 1.70 + String(["a1b2c3"]), String('a1b2c3'.match(/.*/))); 1.71 + 1.72 +// 'a0.b2.c3'.match(/[xyz]*1/) 1.73 +new TestCase ( SECTION, "'a0.b2.c3'.match(/[xyz]*1/)", 1.74 + null, 'a0.b2.c3'.match(/[xyz]*1/)); 1.75 + 1.76 +test();