com.sun.source.tree.ErroneousTree Java Examples

The following examples show how to use com.sun.source.tree.ErroneousTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavacParserTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #2
Source File: JavacParserTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingParenthesisError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void f() {String s = new String; } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[new String()]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #3
Source File: JavacParserTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingClassError() throws IOException {

    String code = "package Test; clas ErrorTest {  "
            + "void f() {String s = new String(); } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[, clas]", "[]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #4
Source File: JavacParserTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #5
Source File: JavacParserTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMethodError() throws IOException {

    String code = "package Test; class ErrorTest {  "
            + "static final void f) {String s = new String(); } }";
    CompilationUnitTree cut = cut = getCompilationUnitTree(code);

    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(normalize(getErroneousTreeValues(node).toString()));
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMethodError: The Erroneous tree "
            + "error value: " + values
            + " does not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #6
Source File: JavacParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testOperatorMissingError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void method() { int x = y  z } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[z]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;

        }
    }.scan(cut, null);

    assertEquals("testOperatorMissingError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #7
Source File: JavacParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingParenthesisError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void f() {String s = new String; } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[new String()]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMissingParenthesisError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #8
Source File: JavacParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingClassError() throws IOException {

    String code = "package Test; clas ErrorTest {  "
            + "void f() {String s = new String(); } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[, clas]", "[]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMissingClassError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #9
Source File: JavacParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #10
Source File: JavacParserTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMethodError() throws IOException {

    String code = "package Test; class ErrorTest {  "
            + "static final void f) {String s = new String(); } }";
    CompilationUnitTree cut = cut = getCompilationUnitTree(code);

    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(normalize(getErroneousTreeValues(node).toString()));
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMethodError: The Erroneous tree "
            + "error value: " + values
            + " does not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #11
Source File: JavacParserTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testOperatorMissingError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void method() { int x = y  z } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[z]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;

        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #12
Source File: JavacParserTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingParenthesisError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void f() {String s = new String; } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[new String()]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #13
Source File: JavacParserTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingClassError() throws IOException {

    String code = "package Test; clas ErrorTest {  "
            + "void f() {String s = new String(); } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[, clas]", "[]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #14
Source File: JavacParserTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testOperatorMissingError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void method() { int x = y  z } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[z]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;

        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #15
Source File: JavacParserTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMethodError() throws IOException {

    String code = "package Test; class ErrorTest {  "
            + "static final void f) {String s = new String(); } }";
    CompilationUnitTree cut = cut = getCompilationUnitTree(code);

    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(normalize(getErroneousTreeValues(node).toString()));
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMethodError: The Erroneous tree "
            + "error value: " + values
            + " does not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #16
Source File: JavacParserTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testOperatorMissingError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void method() { int x = y  z } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[z]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;

        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #17
Source File: JavacParserTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingParenthesisError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void f() {String s = new String; } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[new String()]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #18
Source File: JavacParserTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingClassError() throws IOException {

    String code = "package Test; clas ErrorTest {  "
            + "void f() {String s = new String(); } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[, clas]", "[]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #19
Source File: JavacParserTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #20
Source File: JavacParserTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMethodError() throws IOException {

    String code = "package Test; class ErrorTest {  "
            + "static final void f) {String s = new String(); } }";
    CompilationUnitTree cut = cut = getCompilationUnitTree(code);

    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(normalize(getErroneousTreeValues(node).toString()));
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMethodError: The Erroneous tree "
            + "error value: " + values
            + " does not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #21
Source File: JavacParserTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testOperatorMissingError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void method() { int x = y  z } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[z]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;

        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #22
Source File: JavacParserTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingParenthesisError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void f() {String s = new String; } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[new String()]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #23
Source File: JavacParserTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingClassError() throws IOException {

    String code = "package Test; clas ErrorTest {  "
            + "void f() {String s = new String(); } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[, clas]", "[]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #24
Source File: JavacParserTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #25
Source File: JavacParserTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMethodError() throws IOException {

    String code = "package Test; class ErrorTest {  "
            + "static final void f) {String s = new String(); } }";
    CompilationUnitTree cut = cut = getCompilationUnitTree(code);

    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(normalize(getErroneousTreeValues(node).toString()));
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMethodError: The Erroneous tree "
            + "error value: " + values
            + " does not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #26
Source File: JavacParserTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #27
Source File: JavacParserTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingClassError() throws IOException {

    String code = "package Test; clas ErrorTest {  "
            + "void f() {String s = new String(); } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[, clas]", "[]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #28
Source File: JavacParserTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testSwitchError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "int numDays; void m1(int i) { switchh {i} { case 1: "
            + "numDays = 31; break; } } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[switchh]", "[i]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #29
Source File: JavacParserTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMissingParenthesisError() throws IOException {

    String code = "package test; public class ErrorTest { "
            + "void f() {String s = new String; } }";
    CompilationUnitTree cut = getCompilationUnitTree(code);
    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[new String()]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(getErroneousTreeValues(node).toString());
            return null;
        }
    }.scan(cut, null);

    assertEquals("testSwitchError: The Erroneous tree "
            + "error values: " + values
            + " do not match expected error values: "
            + expectedValues, values, expectedValues);
}
 
Example #30
Source File: JavacParserTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
void testMethodError() throws IOException {

    String code = "package Test; class ErrorTest {  "
            + "static final void f) {String s = new String(); } }";
    CompilationUnitTree cut = cut = getCompilationUnitTree(code);

    final List<String> values = new ArrayList<>();
    final List<String> expectedValues =
            new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));

    new TreeScanner<Void, Void>() {
        @Override
        public Void visitErroneous(ErroneousTree node, Void p) {
            values.add(normalize(getErroneousTreeValues(node).toString()));
            return null;
        }
    }.scan(cut, null);

    assertEquals("testMethodError: The Erroneous tree "
            + "error value: " + values
            + " does not match expected error values: "
            + expectedValues, values, expectedValues);
}