Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/regress-216591.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: 19 August 2003
9 * SUMMARY: Regexp conformance test
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=216591
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-216591.js';
16 var i = 0;
17 var BUGNUMBER = 216591;
18 var summary = 'Regexp conformance test';
19 var status = '';
20 var statusmessages = new Array();
21 var pattern = '';
22 var patterns = new Array();
23 var string = '';
24 var strings = new Array();
25 var actualmatch = '';
26 var actualmatches = new Array();
27 var expectedmatch = '';
28 var expectedmatches = new Array();
29
30
31 status = inSection(1);
32 string = 'a {result.data.DATA} b';
33 pattern = /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/i;
34 actualmatch = string.match(pattern);
35 expectedmatch = Array('{result.data.DATA}', 'result.data.', 'data.', 'DATA');
36 addThis();
37
38 /*
39 * Add a global flag to the regexp. In Perl 5, this gives the same results as above. Compare:
40 *
41 * [ ] perl -e '"a {result.data.DATA} b" =~ /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/i; print("$&, $1, $2, $3");'
42 * {result.data.DATA}, result.data., data., DATA
43 *
44 * [ ] perl -e '"a {result.data.DATA} b" =~ /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/gi; print("$&, $1, $2, $3");'
45 * {result.data.DATA}, result.data., data., DATA
46 *
47 *
48 * But in JavaScript, there will no longer be any sub-captures:
49 */
50 status = inSection(2);
51 string = 'a {result.data.DATA} b';
52 pattern = /\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}/gi;
53 actualmatch = string.match(pattern);
54 expectedmatch = Array('{result.data.DATA}');
55 addThis();
56
57
58
59
60 //-----------------------------------------------------------------------------
61 test();
62 //-----------------------------------------------------------------------------
63
64
65
66 function addThis()
67 {
68 statusmessages[i] = status;
69 patterns[i] = pattern;
70 strings[i] = string;
71 actualmatches[i] = actualmatch;
72 expectedmatches[i] = expectedmatch;
73 i++;
74 }
75
76
77 function test()
78 {
79 enterFunc ('test');
80 printBugNumber(BUGNUMBER);
81 printStatus (summary);
82 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
83 exitFunc ('test');
84 }