mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
Fixing tests.
This commit is contained in:
parent
ca43f533f7
commit
1c17012fa5
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
// key: compiler.err.not.exhaustive.details
|
||||
// key: compiler.misc.binding.pattern
|
||||
|
||||
class BindingPattern {
|
||||
int t(Object o) {
|
||||
return switch (o) {
|
||||
case String s -> 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -22,13 +22,16 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.not.exhaustive.details
|
||||
// key: compiler.misc.not.exhaustive.detail
|
||||
// options: -XDexhaustivityTimeout=-1
|
||||
// key: compiler.misc.enum.constant.pattern
|
||||
|
||||
class NotExhaustiveDetails {
|
||||
int t(int i) {
|
||||
int t(I i) {
|
||||
return switch (i) {
|
||||
case 0 -> -1;
|
||||
case R r -> -1;
|
||||
case E.A -> -1;
|
||||
};
|
||||
}
|
||||
sealed interface I {}
|
||||
enum E implements I {A, B}
|
||||
record R(E e) implements I {}
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.not.exhaustive
|
||||
// options: -XDexhaustivityTimeout=0
|
||||
// options: -XDexhaustivityMaxBaseChecks=0
|
||||
|
||||
class NotExhaustive {
|
||||
int t(int i) {
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.not.exhaustive.statement
|
||||
// options: -XDexhaustivityTimeout=0
|
||||
// options: -XDexhaustivityMaxBaseChecks=0
|
||||
|
||||
class NotExhaustive {
|
||||
void t(Object o) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,13 +22,17 @@
|
||||
*/
|
||||
|
||||
// key: compiler.err.not.exhaustive.statement.details
|
||||
// key: compiler.misc.not.exhaustive.detail
|
||||
// options: -XDexhaustivityTimeout=-1
|
||||
// key: compiler.misc.record.pattern
|
||||
// key: compiler.misc.binding.pattern
|
||||
|
||||
class NotExhaustiveDetails {
|
||||
void t(Object o) {
|
||||
switch (o) {
|
||||
case String s -> System.err.println("String of length: " + s.length());
|
||||
class RecordPattern {
|
||||
void t(R r) {
|
||||
switch (r) {
|
||||
case R(C1 _) -> {}
|
||||
};
|
||||
}
|
||||
sealed interface I {}
|
||||
record C1() implements I {}
|
||||
record C2() implements I {}
|
||||
record R(I i) {}
|
||||
}
|
||||
@ -103,19 +103,19 @@ public class PrimitiveInstanceOfComboTest extends ComboInstance<PrimitiveInstanc
|
||||
ComboTask task1 = newCompilationTask()
|
||||
.withSourceFromTemplate(test1.replace("#{TYPE1}", type1.code).replace("#{TYPE2}", type2.code))
|
||||
.withOption("--enable-preview")
|
||||
.withOption("-XDexhaustivityTimeout=0")
|
||||
.withOption("-XDexhaustivityMaxBaseChecks=0")
|
||||
.withOption("-source").withOption(JAVA_VERSION);
|
||||
|
||||
ComboTask task2 = newCompilationTask()
|
||||
.withSourceFromTemplate(test2.replace("#{TYPE1}", type1.code).replace("#{TYPE2}", type2.code))
|
||||
.withOption("--enable-preview")
|
||||
.withOption("-XDexhaustivityTimeout=0")
|
||||
.withOption("-XDexhaustivityMaxBaseChecks=0")
|
||||
.withOption("-source").withOption(JAVA_VERSION);
|
||||
|
||||
ComboTask task3 = newCompilationTask()
|
||||
.withSourceFromTemplate(test3.replace("#{TYPE1}", type1.code).replace("#{TYPE2}", type2.code))
|
||||
.withOption("--enable-preview")
|
||||
.withOption("-XDexhaustivityTimeout=0")
|
||||
.withOption("-XDexhaustivityMaxBaseChecks=0")
|
||||
.withOption("-source").withOption(JAVA_VERSION);
|
||||
|
||||
task1.generate(result1 -> {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @summary Retain exhaustiveness properties of switches with a constant selector
|
||||
* @enablePreview
|
||||
* @compile/fail/ref=PrimitivePatternsSwitchConstants.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityTimeout=0 PrimitivePatternsSwitchConstants.java
|
||||
* @compile/fail/ref=PrimitivePatternsSwitchConstants.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityMaxBaseChecks=0 PrimitivePatternsSwitchConstants.java
|
||||
*/
|
||||
public class PrimitivePatternsSwitchConstants {
|
||||
void testConstExpressions() {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* @bug 8304487 8325653 8332463
|
||||
* @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview)
|
||||
* @enablePreview
|
||||
* @compile/fail/ref=PrimitivePatternsSwitchErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityTimeout=0 PrimitivePatternsSwitchErrors.java
|
||||
* @compile/fail/ref=PrimitivePatternsSwitchErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityMaxBaseChecks=0 PrimitivePatternsSwitchErrors.java
|
||||
*/
|
||||
public class PrimitivePatternsSwitchErrors {
|
||||
record R_int(int x) {}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8262891 8269146 8269113 8348928
|
||||
* @summary Verify errors related to pattern switches.
|
||||
* @compile/fail/ref=SwitchErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityTimeout=0 SwitchErrors.java
|
||||
* @compile/fail/ref=SwitchErrors.out -XDrawDiagnostics -XDshould-stop.at=FLOW -XDexhaustivityMaxBaseChecks=0 SwitchErrors.java
|
||||
*/
|
||||
|
||||
public class SwitchErrors {
|
||||
|
||||
@ -26,9 +26,9 @@
|
||||
* @bug 8318913
|
||||
* @summary Verify no error is when compiling a class whose permitted types are not exported
|
||||
* @modules jdk.compiler
|
||||
* @compile/fail/ref=NonExportedPermittedTypes.out -XDrawDiagnostics -XDexhaustivityTimeout=0 NonExportedPermittedTypes.java
|
||||
* @compile/fail/ref=NonExportedPermittedTypes.out --release 21 -XDrawDiagnostics -XDexhaustivityTimeout=0 NonExportedPermittedTypes.java
|
||||
* @compile/fail/ref=NonExportedPermittedTypes.out --release ${jdk.version} -XDrawDiagnostics -XDexhaustivityTimeout=0 NonExportedPermittedTypes.java
|
||||
* @compile/fail/ref=NonExportedPermittedTypes.out -XDrawDiagnostics -XDexhaustivityMaxBaseChecks=0 NonExportedPermittedTypes.java
|
||||
* @compile/fail/ref=NonExportedPermittedTypes.out --release 21 -XDrawDiagnostics -XDexhaustivityMaxBaseChecks=0 NonExportedPermittedTypes.java
|
||||
* @compile/fail/ref=NonExportedPermittedTypes.out --release ${jdk.version} -XDrawDiagnostics -XDexhaustivityMaxBaseChecks=0 NonExportedPermittedTypes.java
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8206986
|
||||
* @summary Verify behavior of not exhaustive switch expressions.
|
||||
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics -XDexhaustivityTimeout=0 ExpressionSwitchNotExhaustive.java
|
||||
* @compile/fail/ref=ExpressionSwitchNotExhaustive.out -XDrawDiagnostics -XDexhaustivityMaxBaseChecks=0 ExpressionSwitchNotExhaustive.java
|
||||
*/
|
||||
|
||||
public class ExpressionSwitchNotExhaustive {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user