1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/question_mark.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 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: question_mark.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: question_mark.js'); 1.24 +writeHeaderToLog( SECTION + " "+ TITLE); 1.25 + 1.26 +// 'abcdef'.match(new RegExp('cd?e')) 1.27 +new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))", 1.28 + String(["cde"]), String('abcdef'.match(new RegExp('cd?e')))); 1.29 + 1.30 +// 'abcdef'.match(new RegExp('cdx?e')) 1.31 +new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))", 1.32 + String(["cde"]), String('abcdef'.match(new RegExp('cdx?e')))); 1.33 + 1.34 +// 'pqrstuvw'.match(new RegExp('o?pqrst')) 1.35 +new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))", 1.36 + String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst')))); 1.37 + 1.38 +// 'abcd'.match(new RegExp('x?y?z?')) 1.39 +new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))", 1.40 + String([""]), String('abcd'.match(new RegExp('x?y?z?')))); 1.41 + 1.42 +// 'abcd'.match(new RegExp('x?ay?bz?c')) 1.43 +new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))", 1.44 + String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c')))); 1.45 + 1.46 +// 'abcd'.match(/x?ay?bz?c/) 1.47 +new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)", 1.48 + String(["abc"]), String('abcd'.match(/x?ay?bz?c/))); 1.49 + 1.50 +// 'abbbbc'.match(new RegExp('b?b?b?b')) 1.51 +new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))", 1.52 + String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b')))); 1.53 + 1.54 +// '123az789'.match(new RegExp('ab?c?d?x?y?z')) 1.55 +new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))", 1.56 + String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z')))); 1.57 + 1.58 +// '123az789'.match(/ab?c?d?x?y?z/) 1.59 +new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)", 1.60 + String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/))); 1.61 + 1.62 +// '?????'.match(new RegExp('\\??\\??\\??\\??\\??')) 1.63 +new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))", 1.64 + String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??')))); 1.65 + 1.66 +// 'test'.match(new RegExp('.?.?.?.?.?.?.?')) 1.67 +new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))", 1.68 + String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?')))); 1.69 + 1.70 +test();