1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_2/regexp/string_search.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 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: string_search.js 1.12 + Description: 'Tests the search method on Strings using regular expressions' 1.13 + 1.14 + Author: Nick Lerissa 1.15 + Date: March 12, 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 = 'String: search'; 1.22 + 1.23 +writeHeaderToLog('Executing script: string_search.js'); 1.24 +writeHeaderToLog( SECTION + " "+ TITLE); 1.25 + 1.26 +// 'abcdefg'.search(/d/) 1.27 +new TestCase ( SECTION, "'abcdefg'.search(/d/)", 1.28 + 3, 'abcdefg'.search(/d/)); 1.29 + 1.30 +// 'abcdefg'.search(/x/) 1.31 +new TestCase ( SECTION, "'abcdefg'.search(/x/)", 1.32 + -1, 'abcdefg'.search(/x/)); 1.33 + 1.34 +// 'abcdefg123456hijklmn'.search(/\d+/) 1.35 +new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(/\d+/)", 1.36 + 7, 'abcdefg123456hijklmn'.search(/\d+/)); 1.37 + 1.38 +// 'abcdefg123456hijklmn'.search(new RegExp()) 1.39 +new TestCase ( SECTION, "'abcdefg123456hijklmn'.search(new RegExp())", 1.40 + 0, 'abcdefg123456hijklmn'.search(new RegExp())); 1.41 + 1.42 +// 'abc'.search(new RegExp('$')) 1.43 +new TestCase ( SECTION, "'abc'.search(new RegExp('$'))", 1.44 + 3, 'abc'.search(new RegExp('$'))); 1.45 + 1.46 +// 'abc'.search(new RegExp('^')) 1.47 +new TestCase ( SECTION, "'abc'.search(new RegExp('^'))", 1.48 + 0, 'abc'.search(new RegExp('^'))); 1.49 + 1.50 +// 'abc1'.search(/.\d/) 1.51 +new TestCase ( SECTION, "'abc1'.search(/.\d/)", 1.52 + 2, 'abc1'.search(/.\d/)); 1.53 + 1.54 +// 'abc1'.search(/\d{2}/) 1.55 +new TestCase ( SECTION, "'abc1'.search(/\d{2}/)", 1.56 + -1, 'abc1'.search(/\d{2}/)); 1.57 + 1.58 +test();