Debian Codegraph @

rhino/testsrc/tests/ecma_2/RegExp/octal-002.js

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