-
-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- This PR adds tests for RBGenericNodeVisitor
- adds #visit:anySatisfy: and #visit:noneSatify: - move RBCommentNodeVisitorTest close to the other visitor tests
- Loading branch information
1 parent
768c3c6
commit c8fb8b1
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Class { | ||
#name : #RBGenericNodeVisitorTest, | ||
#superclass : #RBParseTreeTest, | ||
#category : #'AST-Core-Tests-Visitors' | ||
} | ||
|
||
{ #category : #tests } | ||
RBGenericNodeVisitorTest >> testVisitAnySatisfy [ | ||
| result tree | | ||
tree := self parseExpression: 'Object new'. | ||
result := RBGenericNodeVisitor visit: tree anySatisfy: [ :n | n isMessage ]. | ||
self assert: result. | ||
result := RBGenericNodeVisitor visit: tree anySatisfy: [ :n | n isReturn ]. | ||
self deny: result | ||
] | ||
|
||
{ #category : #tests } | ||
RBGenericNodeVisitorTest >> testVisitDetect [ | ||
| node tree | | ||
tree := self parseExpression: 'Object new'. | ||
node := RBGenericNodeVisitor visit: tree detect: [ :n | n isMessage ]. | ||
self assert: node isMessage | ||
] | ||
|
||
{ #category : #tests } | ||
RBGenericNodeVisitorTest >> testVisitDetectIfNone [ | ||
| result tree | | ||
tree := self parseExpression: 'Object new'. | ||
result := RBGenericNodeVisitor visit: tree detect: [ :n | n isReturn ] ifNone: [ #none ]. | ||
self assert: result equals: #none | ||
] | ||
|
||
{ #category : #tests } | ||
RBGenericNodeVisitorTest >> testVisitNoneSatisfy [ | ||
| result tree | | ||
tree := self parseExpression: 'Object new'. | ||
result := RBGenericNodeVisitor visit: tree noneSatisfy: [ :n | n isMessage ]. | ||
self deny: result. | ||
result := RBGenericNodeVisitor visit: tree noneSatisfy: [ :n | n isReturn ]. | ||
self assert: result | ||
] | ||
|
||
{ #category : #tests } | ||
RBGenericNodeVisitorTest >> testVisitSelect [ | ||
| result tree | | ||
tree := self parseExpression: 'Object new'. | ||
result := RBGenericNodeVisitor visit: tree select: [ :n | n isMessage ]. | ||
self assert: result size equals: 1. | ||
self assert: result first selector equals: #new | ||
] |
This file contains 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