author | coleenp |
Wed, 15 Nov 2017 08:14:31 -0500 | |
changeset 47894 | 352b17f62ff7 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
33362 | 1 |
/* |
41158
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
33362 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
43587
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
25 |
* @test 8130450 8158906 8154374 8166400 8171892 8173807 8173848 |
33362 | 26 |
* @summary simple regression test |
27 |
* @build KullaTesting TestingInputStream |
|
28 |
* @run testng SimpleRegressionTest |
|
29 |
*/ |
|
30 |
||
31 |
||
32 |
import java.util.List; |
|
33 |
||
34 |
import javax.tools.Diagnostic; |
|
35 |
||
36 |
import jdk.jshell.Snippet; |
|
37 |
import jdk.jshell.VarSnippet; |
|
38 |
import jdk.jshell.SnippetEvent; |
|
39 |
import org.testng.annotations.Test; |
|
40 |
||
41 |
import static org.testng.Assert.assertEquals; |
|
40512
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
42 |
import static org.testng.Assert.assertFalse; |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
43 |
import static org.testng.Assert.assertTrue; |
37005
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
44 |
import static jdk.jshell.Snippet.Status.OVERWRITTEN; |
33362 | 45 |
import static jdk.jshell.Snippet.SubKind.TEMP_VAR_EXPRESSION_SUBKIND; |
46 |
import static jdk.jshell.Snippet.Status.VALID; |
|
47 |
||
48 |
@Test |
|
49 |
public class SimpleRegressionTest extends KullaTesting { |
|
50 |
||
51 |
public void testSnippetMemberAssignment() { |
|
52 |
assertEval("class C { int y; }"); |
|
53 |
assertEval("C c = new C();"); |
|
54 |
assertVarKeyMatch("c.y = 4;", true, "$1", TEMP_VAR_EXPRESSION_SUBKIND, "int", added(VALID)); |
|
55 |
} |
|
56 |
||
57 |
public void testUserTakesTempVarName() { |
|
58 |
assertEval("int $2 = 4;"); |
|
59 |
assertEval("String $1;"); |
|
60 |
assertVarKeyMatch("1234;", true, "$3", TEMP_VAR_EXPRESSION_SUBKIND, "int", added(VALID)); |
|
61 |
} |
|
62 |
||
63 |
public void testCompileThrow() { |
|
64 |
assertEvalException("throw new Exception();"); |
|
65 |
} |
|
66 |
||
67 |
public void testMultiSnippetDependencies() { |
|
68 |
List<SnippetEvent> events = assertEval("int a = 3, b = a+a, c = b *100;", |
|
69 |
DiagCheck.DIAG_OK, DiagCheck.DIAG_OK, |
|
70 |
chain(added(VALID)), |
|
71 |
chain(added(VALID)), |
|
72 |
chain(added(VALID))); |
|
73 |
assertEquals(events.get(0).value(), "3"); |
|
74 |
assertEquals(events.get(1).value(), "6"); |
|
75 |
assertEquals(events.get(2).value(), "600"); |
|
76 |
assertEval("c;", "600"); |
|
77 |
} |
|
78 |
||
43586
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
79 |
public void testLessThanParsing() { |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
80 |
assertEval("int x = 3;", "3"); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
81 |
assertEval("int y = 4;", "4"); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
82 |
assertEval("int z = 5;", "5"); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
83 |
assertEval("x < y", "true"); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
84 |
assertEval("x < y;", "true"); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
85 |
assertEval("x < y && y < z", "true"); |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
86 |
} |
cc7a4eb79b29
8173848: JShell: less-than causes: reached end of file while parsing
rfield
parents:
42971
diff
changeset
|
87 |
|
33362 | 88 |
public void testNotStmtCannotResolve() { |
89 |
assertDeclareFail("dfasder;", new ExpectedDiagnostic("compiler.err.cant.resolve.location", 0, 7, 0, -1, -1, Diagnostic.Kind.ERROR)); |
|
90 |
} |
|
91 |
||
92 |
public void testNotStmtIncomparable() { |
|
93 |
assertDeclareFail("true == 5.0;", new ExpectedDiagnostic("compiler.err.incomparable.types", 0, 11, 5, -1, -1, Diagnostic.Kind.ERROR)); |
|
94 |
} |
|
95 |
||
96 |
public void testStringAdd() { |
|
97 |
assertEval("String s = \"a\" + \"b\";", "\"ab\""); |
|
98 |
} |
|
99 |
||
100 |
public void testExprSanity() { |
|
101 |
assertEval("int x = 3;", "3"); |
|
102 |
assertEval("int y = 4;", "4"); |
|
103 |
assertEval("x + y;", "7"); |
|
104 |
assertActiveKeys(); |
|
105 |
} |
|
106 |
||
107 |
public void testGenericMethodCrash() { |
|
108 |
assertDeclareWarn1("<T> void f(T...a) {}", (ExpectedDiagnostic) null); |
|
109 |
Snippet sn = methodKey(assertEval("<R> R n(R x) { return x; }", added(VALID))); |
|
110 |
VarSnippet sne = varKey(assertEval("n(5)", added(VALID))); |
|
111 |
assertEquals(sne.typeName(), "Integer"); |
|
112 |
} |
|
37005
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
113 |
|
40512
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
114 |
public void testLongRemoteStrings() { //8158906 |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
115 |
assertEval("String m(int x) { byte[] b = new byte[x]; for (int i = 0; i < x; ++i) b[i] = (byte) 'a'; return new String(b); }"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
116 |
boolean[] shut = new boolean[1]; |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
117 |
getState().onShutdown(j -> { |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
118 |
shut[0] = true; |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
119 |
}); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
120 |
for (String len : new String[]{"12345", "64000", "65535", "65536", "120000"}) { |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
121 |
List<SnippetEvent> el = assertEval("m(" + len + ");"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
122 |
assertFalse(shut[0], "JShell died with long string"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
123 |
assertEquals(el.size(), 1, "Excepted one event"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
124 |
assertTrue(el.get(0).value().length() > 10000, |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
125 |
"Expected truncated but long String, got: " + el.get(0).value().length()); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
126 |
} |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
127 |
} |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
128 |
|
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
129 |
public void testLongRemoteJapaneseStrings() { //8158906 |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
130 |
assertEval("import java.util.stream.*;"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
131 |
assertEval("String m(int x) { return Stream.generate(() -> \"\u3042\").limit(x).collect(Collectors.joining()); }"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
132 |
boolean[] shut = new boolean[1]; |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
133 |
getState().onShutdown(j -> { |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
134 |
shut[0] = true; |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
135 |
}); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
136 |
for (String len : new String[]{"12345", "21843", "21844", "21845", "21846", "64000", "65535", "65536", "120000"}) { |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
137 |
List<SnippetEvent> el = assertEval("m(" + len + ");"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
138 |
assertFalse(shut[0], "JShell died with long string"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
139 |
assertEquals(el.size(), 1, "Excepted one event"); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
140 |
assertTrue(el.get(0).value().length() > 10000, |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
141 |
"Expected truncated but long String, got: " + el.get(0).value().length()); |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
142 |
} |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
143 |
} |
b9359154240c
8158906: JShell: crashes with extremely long result value
rfield
parents:
37005
diff
changeset
|
144 |
|
37005
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
145 |
// 8130450 |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
146 |
public void testDuplicate() { |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
147 |
Snippet snm = methodKey(assertEval("void mm() {}", added(VALID))); |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
148 |
assertEval("void mm() {}", |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
149 |
ste(MAIN_SNIPPET, VALID, VALID, false, null), |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
150 |
ste(snm, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
151 |
Snippet snv = varKey(assertEval("boolean b;", added(VALID))); |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
152 |
assertEval("boolean b;", |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
153 |
ste(MAIN_SNIPPET, VALID, VALID, false, null), |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
154 |
ste(snv, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); |
71210037624f
8130450: JShell: events are not generated for repeated source
rfield
parents:
33362
diff
changeset
|
155 |
} |
40516
9e0e107c39dd
8154374: JShell: setContextClassLoader() for remote Snippet class loader
rfield
parents:
40512
diff
changeset
|
156 |
|
9e0e107c39dd
8154374: JShell: setContextClassLoader() for remote Snippet class loader
rfield
parents:
40512
diff
changeset
|
157 |
public void testContextClassLoader() { |
9e0e107c39dd
8154374: JShell: setContextClassLoader() for remote Snippet class loader
rfield
parents:
40512
diff
changeset
|
158 |
assertEval("class C {}"); |
9e0e107c39dd
8154374: JShell: setContextClassLoader() for remote Snippet class loader
rfield
parents:
40512
diff
changeset
|
159 |
assertEval("C.class.getClassLoader() == Thread.currentThread().getContextClassLoader()", "true"); |
9e0e107c39dd
8154374: JShell: setContextClassLoader() for remote Snippet class loader
rfield
parents:
40512
diff
changeset
|
160 |
} |
41158
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
161 |
|
42971
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
162 |
public void testArrayRepresentation() { |
41158
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
163 |
assertEval("new int[4]", "int[4] { 0, 0, 0, 0 }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
164 |
assertEval("new int[0]", "int[0] { }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
165 |
assertEval("new byte[2]", "byte[2] { 0, 0 }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
166 |
assertEval("new short[] { 1234, 4321 }", "short[2] { 1234, 4321 }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
167 |
assertEval("new long[] { 123456789 }", "long[1] { 123456789 }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
168 |
assertEval("new float[] { -23.5645f, 1.0101f }", "float[2] { -23.5645, 1.0101 }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
169 |
assertEval("new double[] { 1/8, Math.PI }", "double[2] { 0.0, 3.141592653589793 }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
170 |
assertEval("new String[] { \"hi\", \"low\", null }", "String[3] { \"hi\", \"low\", null }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
171 |
assertEval("new char[] { 'a', 34, 77 }", "char[3] { 'a', '\"', 'M' }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
172 |
assertEval("new boolean[] { false, true }", "boolean[2] { false, true }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
173 |
assertEval("new int[][] { new int[] {44, 55}, new int[] {88,99}}", |
42971
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
174 |
"int[2][] { int[2] { 44, 55 }, int[2] { 88, 99 } }"); |
41158
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
175 |
assertEval("new Object[] { \"howdy\", new int[] { 33, 44, 55 }, new String[] { \"up\", \"down\" }}", |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
176 |
"Object[3] { \"howdy\", int[3] { 33, 44, 55 }, String[2] { \"up\", \"down\" } }"); |
957f4fa38bd6
8166400: JShell: friendlier representation of array values
rfield
parents:
40516
diff
changeset
|
177 |
} |
42971
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
178 |
|
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
179 |
public void testMultiDimArrayRepresentation() { |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
180 |
assertEval("new int[3][1]", |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
181 |
"int[3][] { int[1] { 0 }, int[1] { 0 }, int[1] { 0 } }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
182 |
assertEval("new int[3][]", |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
183 |
"int[3][] { null, null, null }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
184 |
assertEval("new int[][] { new int[] {44}, new int[] {77, 88,99}}", |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
185 |
"int[2][] { int[1] { 44 }, int[3] { 77, 88, 99 } }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
186 |
assertEval("new String[3][1]", |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
187 |
"String[3][] { String[1] { null }, String[1] { null }, String[1] { null } }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
188 |
assertEval("class C { }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
189 |
assertEval("new C[3][2]", |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
190 |
"C[3][] { C[2] { null, null }, C[2] { null, null }, C[2] { null, null } }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
191 |
assertEval("new boolean[2][1][3]", |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
192 |
"boolean[2][][] { boolean[1][] { boolean[3] { false, false, false } }, boolean[1][] { boolean[3] { false, false, false } } }"); |
22c8c025a651
8171892: JShell: incorrect printing of multidemensional arrays
rfield
parents:
41158
diff
changeset
|
193 |
} |
43587
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
194 |
|
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
195 |
public void testStringRepresentation() { |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
196 |
assertEval("\"A!\\rB!\"", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
197 |
"\"A!\\rB!\""); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
198 |
assertEval("\"a\\bB\\tc\\nd\\fe\\rf\\\"g'\\\\h\"", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
199 |
"\"a\\bB\\tc\\nd\\fe\\rf\\\"g'\\\\h\""); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
200 |
assertEval("\"\\141\\10B\\11c\\nd\\fe\\15f\\42g\\'\\134h\"", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
201 |
"\"a\\bB\\tc\\nd\\fe\\rf\\\"g'\\\\h\""); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
202 |
assertEval("\"1234567890!@#$%^&*()-_=+qwertQWERT,./<>?;:[]{}\"", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
203 |
"\"1234567890!@#$%^&*()-_=+qwertQWERT,./<>?;:[]{}\""); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
204 |
assertEval("\"AA\\1\\7\\35\\25\"", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
205 |
"\"AA\\001\\007\\035\\025\""); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
206 |
assertEval("\"\"", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
207 |
"\"\""); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
208 |
assertEval("(String)null", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
209 |
"null"); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
210 |
} |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
211 |
|
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
212 |
public void testCharRepresentation() { |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
213 |
for (String s : new String[]{"'A'", "'Z'", "'0'", "'9'", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
214 |
"'a'", "'z'", "'*'", "'%'", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
215 |
"'\\b'", "'\\t'", "'\\n'", "'\\f'", "'\\r'", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
216 |
"'\"'", "'\\\''", "'\\\\'", "'\\007'", "'\\034'",}) { |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
217 |
assertEval(s, s); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
218 |
} |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
219 |
assertEval("'\\3'", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
220 |
"'\\003'"); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
221 |
assertEval("'\\u001D'", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
222 |
"'\\035'"); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
223 |
assertEval("\"a\\bb\\tc\\nd\\fe\\rf\\\"g'\\\\h\".charAt(1)", |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
224 |
"'\\b'"); |
6103af590758
8173807: JShell: control characters should be escaped in String values
rfield
parents:
43586
diff
changeset
|
225 |
} |
33362 | 226 |
} |