langtools/test/jdk/jshell/ModifiersTest.java
changeset 41858 5843b57ce3a6
parent 33362 65ec6de1d6b4
child 41940 048d559e9da7
equal deleted inserted replaced
41857:44d30e3656f5 41858:5843b57ce3a6
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test 8167643
    26  * @summary Tests for modifiers
    26  * @summary Tests for modifiers
    27  * @build KullaTesting TestingInputStream ExpectedDiagnostic
    27  * @build KullaTesting TestingInputStream ExpectedDiagnostic
    28  * @run testng ModifiersTest
    28  * @run testng ModifiersTest
    29  */
    29  */
    30 
    30 
    41 
    41 
    42     @DataProvider(name = "ignoredModifiers")
    42     @DataProvider(name = "ignoredModifiers")
    43     public Object[][] getTestCases() {
    43     public Object[][] getTestCases() {
    44         List<Object[]> testCases = new ArrayList<>();
    44         List<Object[]> testCases = new ArrayList<>();
    45         String[] ignoredModifiers = new String[] {
    45         String[] ignoredModifiers = new String[] {
    46             "public", "protected", "private", "static", "final"
    46             "static", "final"
    47         };
    47         };
    48         for (String ignoredModifier : ignoredModifiers) {
    48         for (String ignoredModifier : ignoredModifiers) {
    49             for (ClassType classType : ClassType.values()) {
    49             for (ClassType classType : ClassType.values()) {
    50                 testCases.add(new Object[] { ignoredModifier, classType });
    50                 testCases.add(new Object[] { ignoredModifier, classType });
    51             }
    51             }
    55 
    55 
    56     @Test(dataProvider = "ignoredModifiers")
    56     @Test(dataProvider = "ignoredModifiers")
    57     public void ignoredModifiers(String modifier, ClassType classType) {
    57     public void ignoredModifiers(String modifier, ClassType classType) {
    58         assertDeclareWarn1(
    58         assertDeclareWarn1(
    59                 String.format("%s %s A {}", modifier, classType), "jdk.eval.warn.illegal.modifiers");
    59                 String.format("%s %s A {}", modifier, classType), "jdk.eval.warn.illegal.modifiers");
       
    60         assertNumberOfActiveClasses(1);
       
    61         assertClasses(clazz(classType, "A"));
       
    62         assertActiveKeys();
       
    63     }
       
    64 
       
    65     @DataProvider(name = "silentlyIgnoredModifiers")
       
    66     public Object[][] getSilentTestCases() {
       
    67         List<Object[]> testCases = new ArrayList<>();
       
    68         String[] ignoredModifiers = new String[] {
       
    69             "public", "protected", "private"
       
    70         };
       
    71         for (String ignoredModifier : ignoredModifiers) {
       
    72             for (ClassType classType : ClassType.values()) {
       
    73                 testCases.add(new Object[] { ignoredModifier, classType });
       
    74             }
       
    75         }
       
    76         return testCases.toArray(new Object[testCases.size()][]);
       
    77     }
       
    78 
       
    79     @Test(dataProvider = "silentlyIgnoredModifiers")
       
    80     public void silentlyIgnoredModifiers(String modifier, ClassType classType) {
       
    81         assertEval(String.format("%s %s A {}", modifier, classType));
    60         assertNumberOfActiveClasses(1);
    82         assertNumberOfActiveClasses(1);
    61         assertClasses(clazz(classType, "A"));
    83         assertClasses(clazz(classType, "A"));
    62         assertActiveKeys();
    84         assertActiveKeys();
    63     }
    85     }
    64 
    86