Fri, 18 Jan 2013 15:38:14 +0000
8006561: Langtools test failure: missing diags/examples
Summary: forgot to hg add tests
Reviewed-by: jjg
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/diags/examples/UnderscoreAsIdentifier.java Fri Jan 18 15:38:14 2013 +0000 1.3 @@ -0,0 +1,28 @@ 1.4 +/* 1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +// key: compiler.warn.underscore.as.identifier 1.28 + 1.29 +class UnderscoreAsIdentifier { 1.30 + String _ = null; 1.31 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/lambda/WarnUnderscoreAsIdent.java Fri Jan 18 15:38:14 2013 +0000 2.3 @@ -0,0 +1,55 @@ 2.4 +/* 2.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @summary Check usages of underscore as identifier generate warnings 2.30 + * @compile/fail/ref=WarnUnderscoreAsIdent.out -XDrawDiagnostics -Werror WarnUnderscoreAsIdent.java 2.31 + */ 2.32 +package _._; 2.33 + 2.34 +import _._; 2.35 + 2.36 +class _ { 2.37 + String _ = null; 2.38 + void _(String _) { } 2.39 + void testLocal() { 2.40 + String _ = null; 2.41 + } 2.42 + void testFor() { 2.43 + for (int _ = 0; _ < 10; _++); 2.44 + } 2.45 + void testTry() { 2.46 + try { } catch (Throwable _) { } 2.47 + } 2.48 + void testLabel() { 2.49 + _: 2.50 + for (;;) { 2.51 + break _; 2.52 + } 2.53 + _: 2.54 + for (;;) { 2.55 + continue _; 2.56 + } 2.57 + } 2.58 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/tools/javac/lambda/WarnUnderscoreAsIdent.out Fri Jan 18 15:38:14 2013 +0000 3.3 @@ -0,0 +1,20 @@ 3.4 +WarnUnderscoreAsIdent.java:29:9: compiler.warn.underscore.as.identifier 3.5 +WarnUnderscoreAsIdent.java:29:11: compiler.warn.underscore.as.identifier 3.6 +WarnUnderscoreAsIdent.java:31:8: compiler.warn.underscore.as.identifier 3.7 +WarnUnderscoreAsIdent.java:31:10: compiler.warn.underscore.as.identifier 3.8 +WarnUnderscoreAsIdent.java:33:7: compiler.warn.underscore.as.identifier 3.9 +WarnUnderscoreAsIdent.java:34:12: compiler.warn.underscore.as.identifier 3.10 +WarnUnderscoreAsIdent.java:35:10: compiler.warn.underscore.as.identifier 3.11 +WarnUnderscoreAsIdent.java:35:19: compiler.warn.underscore.as.identifier 3.12 +WarnUnderscoreAsIdent.java:37:16: compiler.warn.underscore.as.identifier 3.13 +WarnUnderscoreAsIdent.java:40:18: compiler.warn.underscore.as.identifier 3.14 +WarnUnderscoreAsIdent.java:40:25: compiler.warn.underscore.as.identifier 3.15 +WarnUnderscoreAsIdent.java:40:33: compiler.warn.underscore.as.identifier 3.16 +WarnUnderscoreAsIdent.java:43:34: compiler.warn.underscore.as.identifier 3.17 +WarnUnderscoreAsIdent.java:46:9: compiler.warn.underscore.as.identifier 3.18 +WarnUnderscoreAsIdent.java:48:19: compiler.warn.underscore.as.identifier 3.19 +WarnUnderscoreAsIdent.java:50:9: compiler.warn.underscore.as.identifier 3.20 +WarnUnderscoreAsIdent.java:52:22: compiler.warn.underscore.as.identifier 3.21 +- compiler.err.warnings.and.werror 3.22 +1 error 3.23 +17 warnings