michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: Filename: RegExp_multiline_as_array.js michael@0: Description: 'Tests RegExps $* property (same tests as RegExp_multiline.js but using $*)' michael@0: michael@0: Author: Nick Lerissa michael@0: Date: March 13, 1998 michael@0: */ michael@0: michael@0: var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; michael@0: var VERSION = 'no version'; michael@0: startTest(); michael@0: var TITLE = 'RegExp: $*'; michael@0: michael@0: writeHeaderToLog('Executing script: RegExp_multiline_as_array.js'); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: michael@0: // First we do a series of tests with RegExp['$*'] set to false (default value) michael@0: // Following this we do the same tests with RegExp['$*'] set true(**). michael@0: // RegExp['$*'] michael@0: new TestCase ( SECTION, "RegExp['$*']", michael@0: false, RegExp['$*']); michael@0: michael@0: // (['$*'] == false) '123\n456'.match(/^4../) michael@0: new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/^4../)", michael@0: null, '123\n456'.match(/^4../)); michael@0: michael@0: // (['$*'] == false) 'a11\na22\na23\na24'.match(/^a../g) michael@0: new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/^a../g)", michael@0: String(['a11']), String('a11\na22\na23\na24'.match(/^a../g))); michael@0: michael@0: // (['$*'] == false) 'a11\na22'.match(/^.+^./) michael@0: new TestCase ( SECTION, "(['$*'] == false) 'a11\na22'.match(/^.+^./)", michael@0: null, 'a11\na22'.match(/^.+^./)); michael@0: michael@0: // (['$*'] == false) '123\n456'.match(/.3$/) michael@0: new TestCase ( SECTION, "(['$*'] == false) '123\\n456'.match(/.3$/)", michael@0: null, '123\n456'.match(/.3$/)); michael@0: michael@0: // (['$*'] == false) 'a11\na22\na23\na24'.match(/a..$/g) michael@0: new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(/a..$/g)", michael@0: String(['a24']), String('a11\na22\na23\na24'.match(/a..$/g))); michael@0: michael@0: // (['$*'] == false) 'abc\ndef'.match(/c$...$/) michael@0: new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(/c$...$/)", michael@0: null, 'abc\ndef'.match(/c$...$/)); michael@0: michael@0: // (['$*'] == false) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) michael@0: new TestCase ( SECTION, "(['$*'] == false) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", michael@0: String(['a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); michael@0: michael@0: // (['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$')) michael@0: new TestCase ( SECTION, "(['$*'] == false) 'abc\ndef'.match(new RegExp('c$...$'))", michael@0: null, 'abc\ndef'.match(new RegExp('c$...$'))); michael@0: michael@0: // **Now we do the tests with RegExp['$*'] set to true michael@0: // RegExp['$*'] = true; RegExp['$*'] michael@0: RegExp['$*'] = true; michael@0: new TestCase ( SECTION, "RegExp['$*'] = true; RegExp['$*']", michael@0: true, RegExp['$*']); michael@0: michael@0: // (['$*'] == true) '123\n456'.match(/^4../) michael@0: new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/^4../)", michael@0: String(['456']), String('123\n456'.match(/^4../))); michael@0: michael@0: // (['$*'] == true) 'a11\na22\na23\na24'.match(/^a../g) michael@0: new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/^a../g)", michael@0: String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/^a../g))); michael@0: michael@0: // (['$*'] == true) 'a11\na22'.match(/^.+^./) michael@0: //new TestCase ( SECTION, "(['$*'] == true) 'a11\na22'.match(/^.+^./)", michael@0: // String(['a11\na']), String('a11\na22'.match(/^.+^./))); michael@0: michael@0: // (['$*'] == true) '123\n456'.match(/.3$/) michael@0: new TestCase ( SECTION, "(['$*'] == true) '123\\n456'.match(/.3$/)", michael@0: String(['23']), String('123\n456'.match(/.3$/))); michael@0: michael@0: // (['$*'] == true) 'a11\na22\na23\na24'.match(/a..$/g) michael@0: new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(/a..$/g)", michael@0: String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(/a..$/g))); michael@0: michael@0: // (['$*'] == true) 'a11\na22\na23\na24'.match(new RegExp('a..$','g')) michael@0: new TestCase ( SECTION, "(['$*'] == true) 'a11\\na22\\na23\\na24'.match(new RegExp('a..$','g'))", michael@0: String(['a11','a22','a23','a24']), String('a11\na22\na23\na24'.match(new RegExp('a..$','g')))); michael@0: michael@0: // (['$*'] == true) 'abc\ndef'.match(/c$....$/) michael@0: //new TestCase ( SECTION, "(['$*'] == true) 'abc\ndef'.match(/c$.+$/)", michael@0: // 'c\ndef', String('abc\ndef'.match(/c$.+$/))); michael@0: michael@0: RegExp['$*'] = false; michael@0: michael@0: test();