|
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 * File Name: RegExp/octal-002.js |
|
9 * ECMA Section: 15.7.1 |
|
10 * Description: Based on ECMA 2 Draft 7 February 1999 |
|
11 * Simple test cases for matching OctalEscapeSequences. |
|
12 * Author: christine@netscape.com |
|
13 * Date: 19 February 1999 |
|
14 */ |
|
15 var SECTION = "RegExp/octal-002.js"; |
|
16 var VERSION = "ECMA_2"; |
|
17 var TITLE = "RegExp patterns that contain OctalEscapeSequences"; |
|
18 var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; |
|
19 |
|
20 startTest(); |
|
21 |
|
22 // backreference |
|
23 AddRegExpCases( |
|
24 /(.)(.)(.)(.)(.)(.)(.)(.)\8/, |
|
25 "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", |
|
26 "aabbccaaabbbccc", |
|
27 "aabbccaaabbbccc", |
|
28 0, |
|
29 ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); |
|
30 |
|
31 AddRegExpCases( |
|
32 /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, |
|
33 "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", |
|
34 "aabbccaabbcc", |
|
35 "aabbccaabbcc", |
|
36 0, |
|
37 ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); |
|
38 |
|
39 AddRegExpCases( |
|
40 /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, |
|
41 "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", |
|
42 "aabbccaababcc", |
|
43 "aabbccaababcc", |
|
44 0, |
|
45 ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); |
|
46 |
|
47 test(); |
|
48 |
|
49 function AddRegExpCases( |
|
50 regexp, str_regexp, pattern, str_pattern, index, matches_array ) { |
|
51 |
|
52 // prevent a runtime error |
|
53 |
|
54 if ( regexp.exec(pattern) == null || matches_array == null ) { |
|
55 AddTestCase( |
|
56 regexp + ".exec(" + str_pattern +")", |
|
57 matches_array, |
|
58 regexp.exec(pattern) ); |
|
59 |
|
60 return; |
|
61 } |
|
62 AddTestCase( |
|
63 str_regexp + ".exec(" + str_pattern +").length", |
|
64 matches_array.length, |
|
65 regexp.exec(pattern).length ); |
|
66 |
|
67 AddTestCase( |
|
68 str_regexp + ".exec(" + str_pattern +").index", |
|
69 index, |
|
70 regexp.exec(pattern).index ); |
|
71 |
|
72 AddTestCase( |
|
73 str_regexp + ".exec(" + str_pattern +").input", |
|
74 pattern, |
|
75 regexp.exec(pattern).input ); |
|
76 |
|
77 AddTestCase( |
|
78 str_regexp + ".exec(" + str_pattern +").toString()", |
|
79 matches_array.toString(), |
|
80 regexp.exec(pattern).toString() ); |
|
81 /* |
|
82 var limit = matches_array.length > regexp.exec(pattern).length |
|
83 ? matches_array.length |
|
84 : regexp.exec(pattern).length; |
|
85 |
|
86 for ( var matches = 0; matches < limit; matches++ ) { |
|
87 AddTestCase( |
|
88 str_regexp + ".exec(" + str_pattern +")[" + matches +"]", |
|
89 matches_array[matches], |
|
90 regexp.exec(pattern)[matches] ); |
|
91 } |
|
92 */ |
|
93 } |