Debian Codegraph @

rhino/testsrc/org/mozilla/javascript/tests/es5/Test262RegExpTest.java

raw symbols SCIP
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 package org.mozilla.javascript.tests.es5;
6
7 import java.util.ArrayList;
8 import java.util.List;
9
10 import org.junit.After;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.mozilla.javascript.Context;
14 import org.mozilla.javascript.EcmaError;
15 import org.mozilla.javascript.ScriptableObject;
16
17 import static org.junit.Assert.assertTrue;
18
19 /**
20 * @author André Bargull
21 */
22 public class Test262RegExpTest {
23 private Context cx;
24 private ScriptableObject scope;
25
26 @Before
27 public void setUp() {
28 cx = Context.enter();
29 scope = cx.initStandardObjects();
30 }
31
32 @After
33 public void tearDown() {
34 Context.exit();
35 }
36
37 @Test
38 public void testS15_10_2_9_A1_T4() {
39 String source = "/\\b(\\w+) \\2\\b/.test('do you listen the the band');";
40 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.9_AtomEscape/S15.10.2.9_A1_T4.js";
41 cx.evaluateString(scope, source, sourceName, 0, null);
42 }
43
44 @Test
45 public void testS15_10_2_11_A1_T2() {
46 List<String> sources = new ArrayList<String>();
47 sources.add("/\\1/.exec('');");
48 sources.add("/\\2/.exec('');");
49 sources.add("/\\3/.exec('');");
50 sources.add("/\\4/.exec('');");
51 sources.add("/\\5/.exec('');");
52 sources.add("/\\6/.exec('');");
53 sources.add("/\\7/.exec('');");
54 sources.add("/\\8/.exec('');");
55 sources.add("/\\9/.exec('');");
56 sources.add("/\\10/.exec('');");
57
58 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.11_DecimalEscape/S15.10.2.11_A1_T2.js";
59 for (String source : sources) {
60 cx.evaluateString(scope, source, sourceName, 0, null);
61 }
62 }
63
64 @Test
65 public void testS15_10_2_11_A1_T3() {
66 String source = "/(?:A)\\2/.exec('AA');";
67 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.11_DecimalEscape/S15.10.2.11_A1_T3.js";
68 cx.evaluateString(scope, source, sourceName, 0, null);
69 }
70
71 @Test(expected = EcmaError.class)
72 public void testS15_10_2_15_A1_T4() {
73 String source = "(new RegExp('[\\\\Db-G]').exec('a'))";
74 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T4.js";
75 cx.evaluateString(scope, source, sourceName, 0, null);
76 }
77
78 @Test(expected = EcmaError.class)
79 public void testS15_10_2_15_A1_T5() {
80 String source = "(new RegExp('[\\\\sb-G]').exec('a'))";
81 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T5.js";
82 cx.evaluateString(scope, source, sourceName, 0, null);
83 }
84
85 @Test(expected = EcmaError.class)
86 public void testS15_10_2_15_A1_T6() {
87 String source = "(new RegExp('[\\\\Sb-G]').exec('a'))";
88 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T6.js";
89 cx.evaluateString(scope, source, sourceName, 0, null);
90 }
91
92 @Test(expected = EcmaError.class)
93 public void testS15_10_2_15_A1_T7() {
94 String source = "(new RegExp('[\\\\wb-G]').exec('a'))";
95 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T7.js";
96 cx.evaluateString(scope, source, sourceName, 0, null);
97 }
98
99 @Test(expected = EcmaError.class)
100 public void testS15_10_2_15_A1_T8() {
101 String source = "(new RegExp('[\\\\Wb-G]').exec('a'))";
102 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.2_Pattern_Semantics/15.10.2.15_NonemptyClassRanges/S15.10.2.15_A1_T8.js";
103 cx.evaluateString(scope, source, sourceName, 0, null);
104 }
105
106 @Test
107 public void testS15_10_4_1_T1() {
108 String source = "new RegExp().test('AA');";
109 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.4_Pattern_Semantics/15.10.2.11_DecimalEscape/S15.10.2.11_A1_T3.js";
110 assertTrue((Boolean) cx.evaluateString(scope, source, sourceName, 0, null));
111 }
112
113 @Test
114 public void testS15_10_4_1_T2_Undefined() {
115 String source = "new RegExp(undefined).test('AA');";
116 String sourceName = "Conformance/15_Native/15.10_RegExp_Objects/15.10.4_Pattern_Semantics/15.10.2.11_DecimalEscape/S15.10.2.11_A1_T3.js";
117 assertTrue((Boolean) cx.evaluateString(scope, source, sourceName, 0, null));
118 }
119 }