~ubuntu-branches/ubuntu/saucy/mozjs17/saucy-proposed

« back to all changes in this revision

Viewing changes to js/src/tests/js1_2/regexp/vertical_bar.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* This Source Code Form is subject to the terms of the Mozilla Public
 
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
5
 
 
6
 
 
7
/**
 
8
   Filename:     vertical_bar.js
 
9
   Description:  'Tests regular expressions containing |'
 
10
 
 
11
   Author:       Nick Lerissa
 
12
   Date:         March 10, 1998
 
13
*/
 
14
 
 
15
var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
 
16
var VERSION = 'no version';
 
17
startTest();
 
18
var TITLE   = 'RegExp: |';
 
19
 
 
20
writeHeaderToLog('Executing script: vertical_bar.js');
 
21
writeHeaderToLog( SECTION + " "+ TITLE);
 
22
 
 
23
 
 
24
// 'abc'.match(new RegExp('xyz|abc'))
 
25
new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|abc'))",
 
26
               String(["abc"]), String('abc'.match(new RegExp('xyz|abc'))));
 
27
 
 
28
// 'this is a test'.match(new RegExp('quiz|exam|test|homework'))
 
29
new TestCase ( SECTION, "'this is a test'.match(new RegExp('quiz|exam|test|homework'))",
 
30
               String(["test"]), String('this is a test'.match(new RegExp('quiz|exam|test|homework'))));
 
31
 
 
32
// 'abc'.match(new RegExp('xyz|...'))
 
33
new TestCase ( SECTION, "'abc'.match(new RegExp('xyz|...'))",
 
34
               String(["abc"]), String('abc'.match(new RegExp('xyz|...'))));
 
35
 
 
36
// 'abc'.match(new RegExp('(.)..|abc'))
 
37
new TestCase ( SECTION, "'abc'.match(new RegExp('(.)..|abc'))",
 
38
               String(["abc","a"]), String('abc'.match(new RegExp('(.)..|abc'))));
 
39
 
 
40
// 'color: grey'.match(new RegExp('.+: gr(a|e)y'))
 
41
new TestCase ( SECTION, "'color: grey'.match(new RegExp('.+: gr(a|e)y'))",
 
42
               String(["color: grey","e"]), String('color: grey'.match(new RegExp('.+: gr(a|e)y'))));
 
43
 
 
44
// 'no match'.match(new RegExp('red|white|blue'))
 
45
new TestCase ( SECTION, "'no match'.match(new RegExp('red|white|blue'))",
 
46
               null, 'no match'.match(new RegExp('red|white|blue')));
 
47
 
 
48
// 'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))
 
49
new TestCase ( SECTION, "'Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))",
 
50
               String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(new RegExp('(Rob)|(Bob)|(Robert)|(Bobby)'))));
 
51
 
 
52
// 'abcdef'.match(new RegExp('abc|bcd|cde|def'))
 
53
new TestCase ( SECTION, "'abcdef'.match(new RegExp('abc|bcd|cde|def'))",
 
54
               String(["abc"]), String('abcdef'.match(new RegExp('abc|bcd|cde|def'))));
 
55
 
 
56
// 'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)
 
57
new TestCase ( SECTION, "'Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)",
 
58
               String(["Bob",undefined,"Bob", undefined, undefined]), String('Hi Bob'.match(/(Rob)|(Bob)|(Robert)|(Bobby)/)));
 
59
 
 
60
// 'abcdef'.match(/abc|bcd|cde|def/)
 
61
new TestCase ( SECTION, "'abcdef'.match(/abc|bcd|cde|def/)",
 
62
               String(["abc"]), String('abcdef'.match(/abc|bcd|cde|def/)));
 
63
 
 
64
test();