Skip to content

Commit 09a2b20

Browse files
committed
Adding events
1 parent 3f373f6 commit 09a2b20

7 files changed

Lines changed: 107 additions & 6 deletions

src/ExecutableRequirements-Tests/ExReqMockRequirements.class.st

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,25 @@ ExReqMockRequirements >> testReq7 [
137137
withPostcondition: [ :obj :arguments :requirement | true ] ];
138138
yourself
139139
]
140+
141+
{ #category : 'tests' }
142+
ExReqMockRequirements >> testReq8 [
143+
144+
<ExReqTest>
145+
^ ExReqRequirement new
146+
title: 'A requirement verifications can have multiple steps';
147+
addVerification: [ :verify |
148+
verify addStepOnAST:
149+
((ExReqMockRequirements methodNamed: #testReq8) ast allChildren
150+
select: [ :each | each isSequence ]) second.
151+
verify addStepOnAST:
152+
((ExReqMockRequirements methodNamed: #testReq8) ast allChildren
153+
select: [ :each | each isSequence ]) second.
154+
verify addStepOnAST:
155+
((ExReqMockRequirements methodNamed: #testReq8) ast allChildren
156+
select: [ :each | each isSequence ]) second.
157+
verify addStepOnAST:
158+
((ExReqMockRequirements methodNamed: #testReq8) ast allChildren
159+
select: [ :each | each isSequence ]) second ];
160+
yourself
161+
]

src/ExecutableRequirements/ExReqRepositoryReport.class.st

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Class {
44
#instVars : [
55
'requirementReports',
66
'repository',
7-
'tracingPoints'
7+
'tracingPoints',
8+
'announcer'
89
],
910
#category : 'ExecutableRequirements-Model-Report',
1011
#package : 'ExecutableRequirements',
@@ -23,6 +24,34 @@ ExReqRepositoryReport >> allValidRequirementReports [
2324
^ self requirementReports select: [ :each | each isValid ]
2425
]
2526

27+
{ #category : 'as yet unclassified' }
28+
ExReqRepositoryReport >> annouceStepReportIsValid: aStepReport [
29+
30+
self announcer announce:
31+
(ExReqStepReportIsValidEvent new
32+
stepReport: aStepReport;
33+
yourself)
34+
]
35+
36+
{ #category : 'as yet unclassified' }
37+
ExReqRepositoryReport >> annouceTracingPointInstalled [
38+
39+
self announcer announce: (ExReqTracingPointInstalledEvent new)
40+
]
41+
42+
{ #category : 'as yet unclassified' }
43+
ExReqRepositoryReport >> annouceTracingPointRemoved [
44+
45+
self announcer ifNil: [ ^ self ].
46+
self announcer announce: ExReqTracingPointRemovedEvent new
47+
]
48+
49+
{ #category : 'initialization' }
50+
ExReqRepositoryReport >> announcer [
51+
52+
^ announcer
53+
]
54+
2655
{ #category : 'as yet unclassified' }
2756
ExReqRepositoryReport >> createTracingPoints [
2857

@@ -61,6 +90,7 @@ ExReqRepositoryReport >> initialize [
6190

6291
super initialize.
6392
tracingPoints := OrderedCollection new.
93+
announcer := Announcer new
6494
]
6595

6696
{ #category : 'as yet unclassified' }
@@ -72,6 +102,7 @@ ExReqRepositoryReport >> installTracingPoints [
72102
each postconditionTracingPoint install ].
73103
self isInstalled: true.
74104
self isRunning: true.
105+
self annouceTracingPointInstalled
75106
]
76107

77108
{ #category : 'testing' }
@@ -93,7 +124,7 @@ ExReqRepositoryReport >> removeTracingPoints [
93124
each preconditionTracingPoint remove.
94125
each postconditionTracingPoint remove ].
95126
self isRunning: false.
96-
127+
self annouceTracingPointRemoved
97128
]
98129

99130
{ #category : 'accessing' }

src/ExecutableRequirements/ExReqStepReport.class.st

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ ExReqStepReport >> verifyStepPostconditionWithContext: aContext [
179179
aContext
180180
arguments.
181181
self requirement }.
182-
self isValid ifTrue: [ self repositoryReport emitStepIsValid: self. ]
182+
self isValid ifTrue: [
183+
self repositoryReport annouceStepReportIsValid: self ]
183184
]
184185

185186
{ #category : 'as yet unclassified' }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Class {
2+
#name : 'ExReqStepReportIsValidEvent',
3+
#superclass : 'Announcement',
4+
#instVars : [
5+
'stepReport'
6+
],
7+
#category : 'ExecutableRequirements-Events',
8+
#package : 'ExecutableRequirements',
9+
#tag : 'Events'
10+
}
11+
12+
{ #category : 'accessing' }
13+
ExReqStepReportIsValidEvent >> stepReport [
14+
15+
^ stepReport
16+
]
17+
18+
{ #category : 'accessing' }
19+
ExReqStepReportIsValidEvent >> stepReport: anObject [
20+
21+
stepReport := anObject
22+
]

src/ExecutableRequirements/ExReqTracingPoint.class.st

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ ExReqTracingPoint class >> all [
2323
ExReqTracingPoint class >> cleanUp [
2424

2525
<script>
26-
ExReqPreconditionTracingPoint allInstances do: [ :each | each remove ].
27-
ExReqPostconditionTracingPoint allInstances do: [ :each | each remove ].
28-
self all removeAll
26+
ExReqPreconditionTracingPoint allInstances do: [ :each |
27+
each link uninstall.
28+
each remove ].
29+
ExReqPostconditionTracingPoint allInstances do: [ :each |
30+
each link uninstall.
31+
each remove ].
32+
self all removeAll.
33+
Smalltalk image garbageCollect
2934
]
3035

3136
{ #category : 'accessing' }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Class {
2+
#name : 'ExReqTracingPointInstalledEvent',
3+
#superclass : 'Announcement',
4+
#instVars : [
5+
'stepReport'
6+
],
7+
#category : 'ExecutableRequirements-Events',
8+
#package : 'ExecutableRequirements',
9+
#tag : 'Events'
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Class {
2+
#name : 'ExReqTracingPointRemovedEvent',
3+
#superclass : 'Announcement',
4+
#instVars : [
5+
'stepReport'
6+
],
7+
#category : 'ExecutableRequirements-Events',
8+
#package : 'ExecutableRequirements',
9+
#tag : 'Events'
10+
}

0 commit comments

Comments
 (0)