Skip to content

Commit 166b1ec

Browse files
committed
Fixing too many instances + pre/post conditions validation order
1 parent 693813b commit 166b1ec

8 files changed

Lines changed: 84 additions & 35 deletions

src/ExecutableRequirements-Tests/ExReqMockRequirements.class.st

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ ExReqMockRequirements >> testReq5 [
7979
title: 'A requirement can have a title';
8080
addVerification: [ :verify |
8181
verify
82-
addStepOnAST:
83-
((ExReqMockRequirements methodNamed: #testReq5) ast)
82+
addStepOnAST: (ExReqMockRequirements methodNamed: #testReq5) ast
8483
withPostcondition: [ :obj :arguments :requirement |
8584
requirement title = 'A requirement can have a title' and: [
8685
obj title = 'A requirement can have a title' ] ] ];

src/ExecutableRequirements-Tests/ExReqRepositoryReportTest.class.st

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ ExReqRepositoryReportTest >> setUp [
3737
ExReqRepositoryReportTest >> tearDown [
3838

3939
super tearDown.
40-
self report removeTracingPoints
40+
self report removeTracingPoints.
41+
self report closeReport.
42+
repository := nil
4143
]
4244

4345
{ #category : 'tests' }

src/ExecutableRequirements/ExReqAbstractReport.class.st

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Class {
1111
#tag : 'Model-Report'
1212
}
1313

14+
{ #category : 'as yet unclassified' }
15+
ExReqAbstractReport >> closeReport [
16+
self subReports do: #closeReport.
17+
]
18+
1419
{ #category : 'initialization' }
1520
ExReqAbstractReport >> initialize [
1621

src/ExecutableRequirements/ExReqRepositoryReport.class.st

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ ExReqRepositoryReport >> associatedPackages [
7373
^ self repository associatedPackages.
7474
]
7575

76+
{ #category : 'as yet unclassified' }
77+
ExReqRepositoryReport >> closeReport [
78+
79+
super closeReport.
80+
repository := nil.
81+
requirementReports := { }
82+
]
83+
7684
{ #category : 'as yet unclassified' }
7785
ExReqRepositoryReport >> createTracingPoints [
7886

src/ExecutableRequirements/ExReqRequirementReport.class.st

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Class {
1010
#tag : 'Model-Report'
1111
}
1212

13+
{ #category : 'as yet unclassified' }
14+
ExReqRequirementReport >> closeReport [
15+
16+
super closeReport.
17+
requirement := nil.
18+
verificationReports := { }
19+
]
20+
1321
{ #category : 'testing' }
1422
ExReqRequirementReport >> isRequirementReport [
1523

src/ExecutableRequirements/ExReqStepReport.class.st

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ Class {
1616
#tag : 'Model-Report'
1717
}
1818

19+
{ #category : 'as yet unclassified' }
20+
ExReqStepReport >> announceValidity [
21+
22+
self repositoryReport annouceStepReportIsValid: self
23+
]
24+
25+
{ #category : 'as yet unclassified' }
26+
ExReqStepReport >> closeReport [
27+
28+
super closeReport.
29+
step := nil.
30+
requirement := nil.
31+
previousStepReport := nil.
32+
nextStepReport := nil
33+
]
34+
1935
{ #category : 'accessing' }
2036
ExReqStepReport >> hasNextStepReport [
2137

@@ -94,13 +110,13 @@ ExReqStepReport >> numberOfSteps: anObject [
94110
{ #category : 'as yet unclassified' }
95111
ExReqStepReport >> postconditionIsValid [
96112

97-
^ postconditionValidity
113+
^ postconditionValidity or: [ self hasPostcondition not ]
98114
]
99115

100116
{ #category : 'as yet unclassified' }
101117
ExReqStepReport >> preconditionIsValid [
102118

103-
^ preconditionValidity
119+
^ preconditionValidity or: [ self hasPrecondition not ]
104120
]
105121

106122
{ #category : 'accessing' }
@@ -166,44 +182,39 @@ ExReqStepReport >> verifyStepPostconditionWithContext: aContext [
166182
3 - Postcondition not nil -> evaluation
167183
"
168184

169-
self postconditionIsValid ifTrue: [ ^ self ].
185+
postconditionValidity ifTrue: [ ^ self ].
170186
self preconditionIsValid ifFalse: [ ^ self ].
171187
self step postcondition ifNil: [
172188
postconditionValidity := true.
189+
self announceValidity.
173190
^ self ].
174-
preconditionValidity := postconditionValidity := self step
175-
postcondition
176-
valueWithEnoughArguments:
177-
{
178-
aContext receiver.
179-
aContext
180-
arguments.
181-
self requirement }.
182-
self isValid ifTrue: [
183-
self repositoryReport annouceStepReportIsValid: self ]
191+
postconditionValidity := self hasPostcondition
192+
ifTrue: [
193+
self step postcondition
194+
valueWithEnoughArguments: {
195+
aContext receiver.
196+
aContext arguments.
197+
self requirement } ]
198+
ifFalse: [ true ].
199+
200+
self isValid ifTrue: [ self announceValidity ]
184201
]
185202

186203
{ #category : 'as yet unclassified' }
187204
ExReqStepReport >> verifyStepPreconditionWithContext: aContext [
188-
"
189-
0 - Precondition ok -> ok
190-
1 - Previous step valid
191-
2 - Precondition = nil -> true
192-
3 - Precondition not nil -> evaluation
193-
"
194-
self preconditionIsValid ifTrue: [ ^ self ].
205+
206+
preconditionValidity ifTrue: [ ^ self ].
195207
self isPreviousStepValid ifFalse: [
196208
preconditionValidity := false.
197209
postconditionValidity := false.
198210
^ self ].
199-
200-
self step precondition ifNil: [
201-
preconditionValidity := true.
202-
^ self ].
203-
204-
preconditionValidity := self step precondition
205-
valueWithEnoughArguments: {
206-
aContext receiver.
207-
aContext arguments.
208-
self requirement }
211+
preconditionValidity := self hasPrecondition
212+
ifTrue: [
213+
self step precondition
214+
valueWithEnoughArguments: {
215+
aContext receiver.
216+
aContext arguments.
217+
self requirement } ]
218+
ifFalse: [ true ].
219+
self isValid ifTrue: [ self announceValidity ].
209220
]

src/ExecutableRequirements/ExReqTracingPoint.class.st

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ ExReqTracingPoint class >> all [
1919
^ TracingPoints ifNil: [ TracingPoints := Set new ]
2020
]
2121

22+
{ #category : 'removing' }
23+
ExReqTracingPoint class >> remove: aDebugPoint [
24+
25+
self all remove: aDebugPoint ifAbsent: [ ].
26+
DebugPoint all remove: aDebugPoint ifAbsent: [ ].
27+
]
28+
2229
{ #category : 'accessing' }
2330
ExReqTracingPoint >> bePostcondition [
2431

@@ -110,11 +117,11 @@ ExReqTracingPoint >> remove [
110117

111118
| method |
112119
super remove.
113-
method := self target node methodNode compiledMethod.
120+
"method := self target node methodNode compiledMethod.
114121
method methodClass
115122
compile: method sourceCode
116123
classified: method protocolName
117-
notifying: nil
124+
notifying: nil"
118125
]
119126

120127
{ #category : 'accessing' }

src/ExecutableRequirements/ExReqVerificationReport.class.st

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ Class {
1111
#tag : 'Model-Report'
1212
}
1313

14+
{ #category : 'as yet unclassified' }
15+
ExReqVerificationReport >> closeReport [
16+
17+
super closeReport.
18+
requirement := nil.
19+
verification := nil.
20+
stepReports := { }
21+
]
22+
1423
{ #category : 'testing' }
1524
ExReqVerificationReport >> isValid [
1625

0 commit comments

Comments
 (0)