Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/octal-001.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 /*
7 *
8 * Date: 18 July 2002
9 * SUMMARY: Testing octal sequences in regexps
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=141078
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = 'octal-001.js';
15 var i = 0;
16 var BUGNUMBER = 141078;
17 var summary = 'Testing octal sequences in regexps';
18 var status = '';
19 var statusmessages = new Array();
20 var pattern = '';
21 var patterns = new Array();
22 var string = '';
23 var strings = new Array();
24 var actualmatch = '';
25 var actualmatches = new Array();
26 var expectedmatch = '';
27 var expectedmatches = new Array();
28
29
30 status = inSection(1);
31 pattern = /\240/;
32 string = 'abc';
33 actualmatch = string.match(pattern);
34 expectedmatch = null;
35 addThis();
36
37 /*
38 * In the following sections, we test the octal escape sequence '\052'.
39 * This is character code 42, representing the asterisk character '*'.
40 * The Unicode escape for it would be '\u002A', the hex escape '\x2A'.
41 */
42 status = inSection(2);
43 pattern = /ab\052c/;
44 string = 'ab*c';
45 actualmatch = string.match(pattern);
46 expectedmatch = Array('ab*c');
47 addThis();
48
49 status = inSection(3);
50 pattern = /ab\052*c/;
51 string = 'abc';
52 actualmatch = string.match(pattern);
53 expectedmatch = Array('abc');
54 addThis();
55
56 status = inSection(4);
57 pattern = /ab(\052)+c/;
58 string = 'ab****c';
59 actualmatch = string.match(pattern);
60 expectedmatch = Array('ab****c', '*');
61 addThis();
62
63 status = inSection(5);
64 pattern = /ab((\052)+)c/;
65 string = 'ab****c';
66 actualmatch = string.match(pattern);
67 expectedmatch = Array('ab****c', '****', '*');
68 addThis();
69
70 status = inSection(6);
71 pattern = /(?:\052)c/;
72 string = 'ab****c';
73 actualmatch = string.match(pattern);
74 expectedmatch = Array('*c');
75 addThis();
76
77
78
79 //-----------------------------------------------------------------------------
80 test();
81 //-----------------------------------------------------------------------------
82
83
84
85 function addThis()
86 {
87 statusmessages[i] = status;
88 patterns[i] = pattern;
89 strings[i] = string;
90 actualmatches[i] = actualmatch;
91 expectedmatches[i] = expectedmatch;
92 i++;
93 }
94
95
96 function test()
97 {
98 enterFunc('test');
99 printBugNumber(BUGNUMBER);
100 printStatus(summary);
101 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
102 exitFunc ('test');
103 }