Created
January 15, 2015 10:04
-
-
Save SmiddyPence/f8922ab21c233e686c1b to your computer and use it in GitHub Desktop.
#82 JavaParser Example Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: javaparser-testing/src/test/resources/com/github/javaparser/bdd/parsing_scenarios.story | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- javaparser-testing/src/test/resources/com/github/javaparser/bdd/parsing_scenarios.story (revision 15a23ae2350c29a11da98fdd9d5d3765e3f2ee27) | |
+++ javaparser-testing/src/test/resources/com/github/javaparser/bdd/parsing_scenarios.story (revision ) | |
@@ -162,7 +162,7 @@ | |
Then lambda in statement 1 in method 1 in class 1 body is "System.out.println("Hello world!");" | |
Then lambda in statement 2 in method 1 in class 1 block statement is null | |
Then lambda in statement 3 in method 1 in class 1 block statement is "System.out.println("Hello world two!");" | |
- | |
+Then lambda in statement 3 in method 1 in class 1 is parent of contained block statement | |
Scenario: A class with a method reference is parsed by the Java Parser | |
Index: javaparser-testing/src/test/java/com/github/javaparser/bdd/steps/ParsingSteps.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- javaparser-testing/src/test/java/com/github/javaparser/bdd/steps/ParsingSteps.java (revision 15a23ae2350c29a11da98fdd9d5d3765e3f2ee27) | |
+++ javaparser-testing/src/test/java/com/github/javaparser/bdd/steps/ParsingSteps.java (revision ) | |
@@ -122,6 +122,21 @@ | |
assertThat(lambdaStmt.toString(), is(expectedBody)); | |
} | |
+ @Then("lambda in statement $statementPosition in method $methodPosition in class $classPosition is parent of " + | |
+ "contained block statement") | |
+ public void thenLambdaInStatementInMethodInClassIsParentOfContainedBlockStatement(int statementPosition, | |
+ int methodPosition, int classPosition) { | |
+ CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1"); | |
+ MethodDeclaration method = getMethodByPositionAndClassPosition(compilationUnit, | |
+ methodPosition, classPosition); | |
+ Statement statement = method.getBody().getStmts().get(statementPosition-1); | |
+ VariableDeclarator variableDeclarator = (VariableDeclarator)statement.getChildrenNodes().get(0) | |
+ .getChildrenNodes().get(1); | |
+ LambdaExpr lambdaExpr = (LambdaExpr) variableDeclarator.getInit(); | |
+ BlockStmt blockStmt = (BlockStmt) lambdaExpr.getBody(); | |
+ assertThat(lambdaExpr, is(blockStmt.getParentNode())); | |
+ } | |
+ | |
@Then("method reference in statement $statementPosition in method $methodPosition in class $classPosition scope is $expectedName") | |
public void thenMethodReferenceInStatementInMethodInClassIsScope(int statementPosition, int methodPosition, | |
int classPosition, String expectedName) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment