~ubuntu-branches/ubuntu/trusty/mozjs24/trusty-proposed

« back to all changes in this revision

Viewing changes to js/src/tests/ecma_3/extensions/regress-188206-02.js

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2014-02-11 21:55:34 UTC
  • Revision ID: package-import@ubuntu.com-20140211215534-m1zyq5aj59md3y07
Tags: upstream-24.2.0
ImportĀ upstreamĀ versionĀ 24.2.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
var UBound = 0;
 
8
var BUGNUMBER = 188206;
 
9
var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors';
 
10
var CHECK_PASSED = 'Should not generate an error';
 
11
var CHECK_FAILED = 'Generated an error!';
 
12
var status = '';
 
13
var statusitems = [];
 
14
var actual = '';
 
15
var actualvalues = [];
 
16
var expect= '';
 
17
var expectedvalues = [];
 
18
 
 
19
 
 
20
/*
 
21
 * Misusing the {DecmalDigits} quantifier - according to ECMA,
 
22
 * but not according to Perl.
 
23
 *
 
24
 * ECMA-262 Edition 3 prohibits the use of unescaped braces in
 
25
 * regexp patterns, unless they form part of a quantifier.
 
26
 *
 
27
 * Hovever, Perl does not prohibit this. If not used as part
 
28
 * of a quantifer, Perl treats braces literally.
 
29
 *
 
30
 * We decided to follow Perl on this for backward compatibility.
 
31
 * See http://bugzilla.mozilla.org/show_bug.cgi?id=190685.
 
32
 *
 
33
 * Therefore NONE of the following ECMA violations should generate
 
34
 * a SyntaxError. Note we use checkThis() instead of testThis().
 
35
 */
 
36
status = inSection(13);
 
37
checkThis(' /a*{/ ');
 
38
 
 
39
status = inSection(14);
 
40
checkThis(' /a{}/ ');
 
41
 
 
42
status = inSection(15);
 
43
checkThis(' /{a/ ');
 
44
 
 
45
status = inSection(16);
 
46
checkThis(' /}a/ ');
 
47
 
 
48
status = inSection(17);
 
49
checkThis(' /x{abc}/ ');
 
50
 
 
51
status = inSection(18);
 
52
checkThis(' /{{0}/ ');
 
53
 
 
54
status = inSection(19);
 
55
checkThis(' /{{1}/ ');
 
56
 
 
57
status = inSection(20);
 
58
checkThis(' /x{{0}/ ');
 
59
 
 
60
status = inSection(21);
 
61
checkThis(' /x{{1}/ ');
 
62
 
 
63
status = inSection(22);
 
64
checkThis(' /x{{0}}/ ');
 
65
 
 
66
status = inSection(23);
 
67
checkThis(' /x{{1}}/ ');
 
68
 
 
69
status = inSection(24);
 
70
checkThis(' /x{{0}}/ ');
 
71
 
 
72
status = inSection(25);
 
73
checkThis(' /x{{1}}/ ');
 
74
 
 
75
status = inSection(26);
 
76
checkThis(' /x{{0}}/ ');
 
77
 
 
78
status = inSection(27);
 
79
checkThis(' /x{{1}}/ ');
 
80
 
 
81
 
 
82
//-----------------------------------------------------------------------------
 
83
test();
 
84
//-----------------------------------------------------------------------------
 
85
 
 
86
 
 
87
 
 
88
/*
 
89
 * Allowed syntax shouldn't generate any errors
 
90
 */
 
91
function checkThis(sAllowedSyntax)
 
92
{
 
93
  expect = CHECK_PASSED;
 
94
  actual = CHECK_PASSED;
 
95
 
 
96
  try
 
97
  {
 
98
    eval(sAllowedSyntax);
 
99
  }
 
100
  catch(e)
 
101
  {
 
102
    actual = CHECK_FAILED;
 
103
  }
 
104
 
 
105
  statusitems[UBound] = status;
 
106
  expectedvalues[UBound] = expect;
 
107
  actualvalues[UBound] = actual;
 
108
  UBound++;
 
109
}
 
110
 
 
111
 
 
112
function test()
 
113
{
 
114
  enterFunc('test');
 
115
  printBugNumber(BUGNUMBER);
 
116
  printStatus(summary);
 
117
 
 
118
  for (var i=0; i<UBound; i++)
 
119
  {
 
120
    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
 
121
  }
 
122
 
 
123
  exitFunc ('test');
 
124
}