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: vertical_bar.js michael@0: Description: 'Tests regular expressions containing |' michael@0: michael@0: Author: Nick Lerissa michael@0: Date: March 10, 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: vertical_bar.js'); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: michael@0: // 'abc'.match(new RegExp('xyz|abc')) michael@0: new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))", michael@0: String(["abc"]), String('abc'.match(new RegExp('xyz|abc')))); michael@0: michael@0: // 'this is a test'.match(new RegExp('quiz|exam|test|homework')) michael@0: new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))", michael@0: String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework')))); michael@0: michael@0: // 'abc'.match(new RegExp('xyz|...')) michael@0: new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))", michael@0: String(["abc"]), String('abc'.match(new RegExp('xyz|...')))); michael@0: michael@0: // 'abc'.match(new RegExp('(.)..|abc')) michael@0: new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))", michael@0: String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc')))); michael@0: michael@0: // 'color: grey'.match(new RegExp('.+: gr(a|e)y')) michael@0: new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))", michael@0: String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y')))); michael@0: michael@0: // 'no match'.match(new RegExp('red|white|blue')) michael@0: new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))", michael@0: null, 'no match'.match(new RegExp('red|white|blue'))); michael@0: michael@0: // 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')) michael@0: new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))", michael@0: String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)')))); michael@0: michael@0: // 'abcdef'.match(new RegExp('abc|bcd|cde|def')) michael@0: new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))", michael@0: String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def')))); michael@0: michael@0: // 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/) michael@0: new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)", michael@0: String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/))); michael@0: michael@0: // 'abcdef'.match(/abc|bcd|cde|def/) michael@0: new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)", michael@0: String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/))); michael@0: michael@0: test();