js/src/tests/js1_2/regexp/vertical_bar.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_2/regexp/vertical_bar.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     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:     vertical_bar.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: vertical_bar.js');
    1.24 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.25 +
    1.26 +
    1.27 +// 'abc'.match(new RegExp('xyz|abc'))
    1.28 +new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))",
    1.29 +	       String(["abc"]), String('abc'.match(new RegExp('xyz|abc'))));
    1.30 +
    1.31 +// 'this is a test'.match(new RegExp('quiz|exam|test|homework'))
    1.32 +new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))",
    1.33 +	       String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework'))));
    1.34 +
    1.35 +// 'abc'.match(new RegExp('xyz|...'))
    1.36 +new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))",
    1.37 +	       String(["abc"]), String('abc'.match(new RegExp('xyz|...'))));
    1.38 +
    1.39 +// 'abc'.match(new RegExp('(.)..|abc'))
    1.40 +new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))",
    1.41 +	       String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc'))));
    1.42 +
    1.43 +// 'color: grey'.match(new RegExp('.+: gr(a|e)y'))
    1.44 +new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))",
    1.45 +	       String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y'))));
    1.46 +
    1.47 +// 'no match'.match(new RegExp('red|white|blue'))
    1.48 +new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))",
    1.49 +	       null, 'no match'.match(new RegExp('red|white|blue')));
    1.50 +
    1.51 +// 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))
    1.52 +new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))",
    1.53 +	       String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))));
    1.54 +
    1.55 +// 'abcdef'.match(new RegExp('abc|bcd|cde|def'))
    1.56 +new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))",
    1.57 +	       String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def'))));
    1.58 +
    1.59 +// 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)
    1.60 +new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)",
    1.61 +	       String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)));
    1.62 +
    1.63 +// 'abcdef'.match(/abc|bcd|cde|def/)
    1.64 +new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)",
    1.65 +	       String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/)));
    1.66 +
    1.67 +test();

mercurial