Skip to content

Commit

Permalink
DrTests does all the doc comment detecting, parsing and running all m…
Browse files Browse the repository at this point in the history
…anually, not relying on the PharoDocComment packate at all.

This is a first step to change that: we use PharoDocComment abstraction to find the methods. NOTE: the actually exuction is still does not use
PharoDocComment, this will be another step

- remove not needed example method
- improve comment and categerization in CommentTestCase
- add a #hasDocComment test for method and class
-  use this to simplify DrTest
  • Loading branch information
MarcusDenker committed Apr 15, 2021
1 parent 39edaa0 commit 6d96756
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
17 changes: 5 additions & 12 deletions src/DrTests-CommentsToTests/CommentTestCase.class.st
Expand Up @@ -50,17 +50,10 @@ CommentTestCase class >> errorComment: stringComment class: aClass selector: aSy
yourself
]

{ #category : #example }
CommentTestCase class >> example [
"1 + 1 >>> 2"
^ CommentTestCase comment: '1 + 1 >>> 2' class: CommentTestCase class selector: #example
]

{ #category : #accessing }
CommentTestCase class >> testSelectors [
self flag: #todo.
"missing comments. I have no ide what this method is doing."
^ super testSelectors \ {#testError . #testIt}
"we remove the selectors to add back later one of them, depending if is is error or not"
^ super testSelectors \ { #testError. #testIt }
]

{ #category : #accessing }
Expand Down Expand Up @@ -124,7 +117,7 @@ CommentTestCase >> expression: anObject [
expression := anObject
]

{ #category : #accessing }
{ #category : #printing }
CommentTestCase >> printString [
^ expression
]
Expand All @@ -139,12 +132,12 @@ CommentTestCase >> selectorExample: anObject [
selectorExample := anObject
]

{ #category : #accessing }
{ #category : #tests }
CommentTestCase >> testError [
self error: 'syntax error on the comment'
]

{ #category : #accessing }
{ #category : #tests }
CommentTestCase >> testIt [
self assert: expectedValue equals: currentValue
]
Expand Up @@ -14,9 +14,8 @@ DTCommentTestConfiguration >> asTestSuite [
suite := TestSuite named: 'Test Generated From Comments'.
methods := (self items reject: [ :each | each isAbstract ]) flatCollect: [ :each | each methods ].
methods := methods select: [:each | each sourceCode includesSubstring: '>>>' ].
methods do: [ :m | m comments do: [ :com |
(com includesSubstring: '>>>')
ifTrue: [ suite addTest:
(CommentTestCase comment: com class: m methodClass selector: m selector) ] ] ].
methods do: [ :m | m pharoDocCommentNodes do: [ :docComment |
suite addTest:
(CommentTestCase comment: docComment sourceNode contents class: m methodClass selector: m selector) ] ].
^ suite
]
11 changes: 3 additions & 8 deletions src/DrTests-CommentsToTests/DTCommentToTestPlugin.class.st
Expand Up @@ -37,14 +37,9 @@ DTCommentToTestPlugin >> firstListLabel [

{ #category : #api }
DTCommentToTestPlugin >> itemsToBeAnalysedFor: packagesSelected [
^ packagesSelected
flatCollect: [ :p |
p definedClasses
select: [ :c |
c methods
anySatisfy: [ :m |
( m sourceCode includesSubstring: '>>>') and: [
m comments anySatisfy: [ :com | com includesSubstring: '>>>' ] ] ] ]]

^ packagesSelected flatCollect: [ :package |
package definedClasses select: [ :class | class hasDocComment ] ]
]

{ #category : #api }
Expand Down
6 changes: 6 additions & 0 deletions src/PharoDocComment/Behavior.extension.st
@@ -0,0 +1,6 @@
Extension { #name : #Behavior }

{ #category : #'*PharoDocComment' }
Behavior >> hasDocComment [
^ self methods anySatisfy: [:method | method hasDocComment ]
]
5 changes: 5 additions & 0 deletions src/PharoDocComment/CompiledMethod.extension.st
@@ -1,5 +1,10 @@
Extension { #name : #CompiledMethod }

{ #category : #'*PharoDocComment' }
CompiledMethod >> hasDocComment [
^ self pharoDocCommentNodes notEmpty
]

{ #category : #'*PharoDocComment' }
CompiledMethod >> pharoDocCommentNodes [
"we try to avoid to have to create the AST if we are sure that we do not need it"
Expand Down

0 comments on commit 6d96756

Please sign in to comment.