test/tools/javac/StringsInSwitch/StringSwitches.java

changeset 1063
64b9b7ae3366
parent 554
9d9f26857129
child 1448
7d34e91f66bb
equal deleted inserted replaced
1062:0d6d41563040 1063:64b9b7ae3366
1 /* 1 /*
2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 /* 24 /*
25 * @test 25 * @test
26 * @bug 6827009 26 * @bug 6827009 7071246
27 * @summary Positive tests for strings in switch. 27 * @summary Positive tests for strings in switch.
28 * @author Joseph D. Darcy 28 * @author Joseph D. Darcy
29 */ 29 */
30 30
31 public class StringSwitches { 31 public class StringSwitches {
34 int failures = 0; 34 int failures = 0;
35 35
36 failures += testPileup(); 36 failures += testPileup();
37 failures += testSwitchingTwoWays(); 37 failures += testSwitchingTwoWays();
38 failures += testNamedBreak(); 38 failures += testNamedBreak();
39 failures += testExtraParens();
39 40
40 if (failures > 0) { 41 if (failures > 0) {
41 throw new RuntimeException(); 42 throw new RuntimeException();
42 } 43 }
43 } 44 }
258 return result |= (1<<4); 259 return result |= (1<<4);
259 } 260 }
260 result |= (1<<5); 261 result |= (1<<5);
261 return result; 262 return result;
262 } 263 }
264
265 private static int testExtraParens() {
266 int failures = 1;
267 String s = "first";
268
269 switch(s) {
270 case (("first")):
271 failures = 0;
272 break;
273 case ("second"):
274 throw new RuntimeException("Should not be reached.");
275 }
276
277 return failures;
278 }
263 } 279 }

mercurial