test/langtools/tools/javac/preview/PreviewErrors.java
author jlahoda
Tue, 24 Sep 2019 15:40:26 +0200
branchJDK-8226585-branch
changeset 58290 d885633d9de4
parent 58109 ee07de0d2c16
permissions -rw-r--r--
Converting the test to a combo-framework test.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     1
/*
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     4
 *
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     8
 *
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    14
 *
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    18
 *
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    21
 * questions.
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    22
 */
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    23
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    24
/*
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    25
 * @test
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    26
 * @bug 8226585
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    27
 * @summary Verify behavior w.r.t. preview feature API errors and warnings
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    28
 * @library /tools/lib /tools/javac/lib
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    29
 * @modules
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    30
 *      java.base/jdk.internal
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    31
 *      jdk.compiler/com.sun.tools.javac.api
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    32
 *      jdk.compiler/com.sun.tools.javac.file
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    33
 *      jdk.compiler/com.sun.tools.javac.main
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    34
 *      jdk.compiler/com.sun.tools.javac.util
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    35
 * @build toolbox.ToolBox toolbox.JavacTask
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    36
 * @build combo.ComboTestHelper
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    37
 * @compile --enable-preview -source ${jdk.version} PreviewErrors.java
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    38
 * @run main/othervm --enable-preview PreviewErrors
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    39
 */
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    40
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    41
import java.io.IOException;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    42
import java.nio.file.Files;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    43
import java.nio.file.Path;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    44
import java.nio.file.Paths;
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    45
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    46
import combo.ComboInstance;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    47
import combo.ComboParameter;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    48
import combo.ComboTask;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    49
import combo.ComboTestHelper;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    50
import java.util.Arrays;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    51
import java.util.Set;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    52
import java.util.stream.Collectors;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    53
import javax.tools.Diagnostic;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    54
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    55
import jdk.internal.PreviewFeature;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    56
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    57
import toolbox.JavacTask;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    58
import toolbox.ToolBox;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    59
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    60
public class PreviewErrors extends ComboInstance<PreviewErrors> {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    61
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    62
    protected ToolBox tb;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    63
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    64
    PreviewErrors() {
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    65
        super();
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    66
        tb = new ToolBox();
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    67
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    68
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    69
    public static void main(String... args) throws Exception {
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    70
        new ComboTestHelper<PreviewErrors>()
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    71
                .withDimension("ESSENTIAL", (x, essential) -> x.essential = essential, EssentialAPI.values())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    72
                .withDimension("PREVIEW", (x, preview) -> x.preview = preview, Preview.values())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    73
                .withDimension("LINT", (x, lint) -> x.lint = lint, Lint.values())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    74
                .withDimension("SUPPRESS", (x, suppress) -> x.suppress = suppress, Suppress.values())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    75
                .run(PreviewErrors::new);
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    76
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    77
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    78
    private EssentialAPI essential;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    79
    private Preview preview;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    80
    private Lint lint;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    81
    private Suppress suppress;
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    82
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    83
    @Override
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    84
    public void doWork() throws IOException {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    85
        Path base = Paths.get(".");
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    86
        Path src = base.resolve("src");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    87
        Path srcJavaBase = src.resolve("java.base");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    88
        Path classes = base.resolve("classes");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    89
        Path classesJavaBase = classes.resolve("java.base");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    90
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    91
        Files.createDirectories(classesJavaBase);
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
    92
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    93
        tb.writeJavaFiles(srcJavaBase,
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    94
                          """
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    95
                          package java.lang;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    96
                          public class Extra {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    97
                              @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.${preview}
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    98
                                                           ${essential})
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
    99
                              public static void test() { }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   100
                          }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   101
                          """.replace("${preview}", PreviewFeature.Feature.values()[0].name())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   102
                             .replace("${essential}", essential.expand(null)));
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   103
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   104
        new JavacTask(tb)
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   105
                .outdir(classesJavaBase)
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   106
                .options("--patch-module", "java.base=" + srcJavaBase.toString())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   107
                .files(tb.findJavaFiles(srcJavaBase))
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   108
                .run()
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   109
                .writeAll();
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   110
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   111
        ComboTask task = newCompilationTask()
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   112
                .withSourceFromTemplate("""
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   113
                                        package test;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   114
                                        public class Test {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   115
                                            #{SUPPRESS}
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   116
                                            public void test() {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   117
                                                Extra.test();
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   118
                                            }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   119
                                        }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   120
                                        """)
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   121
                .withOption("-XDrawDiagnostics")
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   122
                .withOption("--patch-module")
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   123
                .withOption("java.base=" + classesJavaBase.toString())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   124
                .withOption("-source")
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   125
                .withOption(String.valueOf(Runtime.version().feature()));
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   126
        if (preview.expand(null)!= null) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   127
            task = task.withOption(preview.expand(null));
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   128
        }
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   129
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   130
        if (lint.expand(null) != null) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   131
            task = task.withOption(lint.expand(null));
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   132
        }
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   133
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   134
        task.generate(result -> {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   135
                Set<String> actual = Arrays.stream(Diagnostic.Kind.values())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   136
                                            .flatMap(kind -> result.diagnosticsForKind(kind).stream())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   137
                                            .map(d -> d.getLineNumber() + ":" + d.getColumnNumber() + ":" + d.getCode())
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   138
                                            .collect(Collectors.toSet());
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   139
                Set<String> expected;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   140
                boolean ok;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   141
                if (essential == EssentialAPI.YES) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   142
                    if (preview == Preview.YES) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   143
                        if (lint == Lint.ENABLE_PREVIEW) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   144
                            expected = Set.of("5:14:compiler.warn.is.preview");
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   145
                        } else {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   146
                            expected = Set.of("-1:-1:compiler.note.preview.filename",
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   147
                                              "-1:-1:compiler.note.preview.recompile");
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   148
                        }
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   149
                        ok = true;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   150
                    } else {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   151
                        expected = Set.of("5:14:compiler.err.is.preview");
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   152
                        ok = false;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   153
                    }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   154
                } else {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   155
                    if (suppress == Suppress.YES) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   156
                        expected = Set.of();
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   157
                    } else if ((preview == Preview.YES && (lint == Lint.NONE || lint == Lint.DISABLE_PREVIEW)) ||
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   158
                               (preview == Preview.NO && lint == Lint.DISABLE_PREVIEW)) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   159
                        expected = Set.of("-1:-1:compiler.note.preview.filename",
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   160
                                          "-1:-1:compiler.note.preview.recompile");
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   161
                    } else {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   162
                        expected = Set.of("5:14:compiler.warn.is.preview");
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   163
                    }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   164
                    ok = true;
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   165
                }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   166
                if (ok) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   167
                    if (!result.get().iterator().hasNext()) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   168
                        throw new IllegalStateException("Did not succeed as expected.");
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   169
                    }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   170
                } else {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   171
                    if (result.get().iterator().hasNext()) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   172
                        throw new IllegalStateException("Succeed unexpectedly.");
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   173
                    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   174
                }
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   175
                if (!expected.equals(actual)) {
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   176
                    throw new IllegalStateException("Unexpected output for " + essential + ", " + preview + ", " + lint + ", " + suppress + ": " + actual.toString());
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   177
                }
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   178
            });
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   179
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   180
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   181
    public enum EssentialAPI implements ComboParameter {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   182
        YES(", essentialAPI=true"),
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   183
        NO(", essentialAPI=false");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   184
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   185
        private final String code;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   186
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   187
        private EssentialAPI(String code) {
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   188
            this.code = code;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   189
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   190
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   191
        public String expand(String optParameter) {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   192
            return code;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   193
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   194
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   195
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   196
    public enum Preview implements ComboParameter {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   197
        YES("--enable-preview"),
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   198
        NO(null);
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   199
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   200
        private final String opt;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   201
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   202
        private Preview(String opt) {
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   203
            this.opt = opt;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   204
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   205
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   206
        public String expand(String optParameter) {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   207
            return opt;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   208
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   209
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   210
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   211
    public enum Lint implements ComboParameter {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   212
        NONE(null),
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   213
        ENABLE_PREVIEW("-Xlint:preview"),
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   214
        DISABLE_PREVIEW("-Xlint:-preview");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   215
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   216
        private final String opt;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   217
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   218
        private Lint(String opt) {
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   219
            this.opt = opt;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   220
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   221
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   222
        public String expand(String optParameter) {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   223
            return opt;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   224
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   225
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   226
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   227
    public enum Suppress implements ComboParameter {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   228
        YES("@SuppressWarnings(\"preview\")"),
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   229
        NO("");
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   230
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   231
        private final String code;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   232
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   233
        private Suppress(String code) {
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   234
            this.code = code;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   235
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   236
58290
d885633d9de4 Converting the test to a combo-framework test.
jlahoda
parents: 58109
diff changeset
   237
        public String expand(String optParameter) {
58109
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   238
            return code;
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   239
        }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   240
    }
ee07de0d2c16 Updating javac behavior w.r.t. preview API. Based on darcy's patch.
jlahoda
parents:
diff changeset
   241
}