Skip to content

Commit

Permalink
using inline code for testing position of package protected elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed Dec 5, 2016
1 parent b874d56 commit 85f6cfa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 162 deletions.
@@ -1,9 +1,6 @@
package com.github.javaparser.ast;

import com.github.javaparser.JavaParser;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ParseStart;
import com.github.javaparser.StreamProvider;
import com.github.javaparser.*;
import org.junit.Test;

import java.io.IOException;
Expand All @@ -23,19 +20,28 @@ private List<Node> getAllNodes(Node node) {
return nodes;
}

@Test
public void packageProtectedClassShouldHavePositionSet() throws IOException {
ensureAllNodesHaveValidBeginPosition("class A { }");
}

@Test
public void packageProtectedFieldShouldHavePositionSet() throws IOException {
ensureAllNodesHaveValidBeginPosition("public class A { int i; }");
}

@Test
public void packageProtectedMethodShouldHavePositionSet() throws IOException {
ensureAllNodesHaveValidBeginPosition("SourcesHelperOldVersion.java.txt");
ensureAllNodesHaveValidBeginPosition("public class A { void foo() {} }");
}

@Test
public void packageProtectedConstructorShouldHavePositionSet() throws IOException {
ensureAllNodesHaveValidBeginPosition("PackageProtectedCtorNodePositionTest.java.txt");
ensureAllNodesHaveValidBeginPosition("public class A { A() {} }");
}

private void ensureAllNodesHaveValidBeginPosition(final String testResourceName) throws IOException {
InputStream is = this.getClass().getResourceAsStream("/com/github/javaparser/issue_samples/" + testResourceName);
ParseResult<CompilationUnit> res = new JavaParser().parse(ParseStart.COMPILATION_UNIT, new StreamProvider(is));
private void ensureAllNodesHaveValidBeginPosition(final String code) throws IOException {
ParseResult<CompilationUnit> res = new JavaParser().parse(ParseStart.COMPILATION_UNIT, Providers.provider(code));
assertTrue(res.getProblems().isEmpty());

CompilationUnit cu = res.getResult().get();
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 85f6cfa

Please sign in to comment.