Skip to content

Commit fe2654a

Browse files
committed
Change breakpoints with debugpoints
1 parent 54fb5dc commit fe2654a

5 files changed

Lines changed: 116 additions & 71 deletions

File tree

src/ExecutableRequirements-Tests/ExReqRepositoryReportTest.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ ExReqRepositoryReportTest >> testCreateTracingPoints [
4646
self assert: ExReqTracingPoint all isEmpty.
4747
self assert: self report tracingPoints isEmpty.
4848
self report createTracingPoints.
49-
self assert: ExReqTracingPoint all isEmpty.
49+
self assert: ExReqTracingPoint all isNotEmpty.
5050
self assert: self report tracingPoints isNotEmpty
51-
5251
]
5352

5453
{ #category : 'tests' }
@@ -68,6 +67,7 @@ ExReqRepositoryReportTest >> testInstallTracingPoints [
6867
self assert: ExReqTracingPoint all isEmpty.
6968
self assert: self report tracingPoints isEmpty.
7069
self report installTracingPoints.
70+
7171
self assert: ExReqTracingPoint all isNotEmpty.
7272
self assert: self report tracingPoints isNotEmpty.
7373
self report removeTracingPoints.

src/ExecutableRequirements/ExReqPostconditionTracingPoint.class.st

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/ExecutableRequirements/ExReqPreconditionTracingPoint.class.st

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 88 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Class {
22
#name : 'ExReqTracingPoint',
3-
#superclass : 'Breakpoint',
3+
#superclass : 'DebugPoint',
44
#instVars : [
5+
'isPrecondition',
56
'stepReports'
67
],
78
#classVars : [
@@ -15,47 +16,93 @@ Class {
1516
{ #category : 'accessing' }
1617
ExReqTracingPoint class >> all [
1718

18-
^ TracingPoints ifNil: [
19-
TracingPoints := OrderedCollection new ]
19+
^ TracingPoints ifNil: [ TracingPoints := Set new ]
2020
]
2121

22-
{ #category : 'cleanup' }
23-
ExReqTracingPoint class >> cleanUp [
24-
25-
<script>
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
22+
{ #category : 'accessing' }
23+
ExReqTracingPoint >> bePostcondition [
24+
25+
isPrecondition := false
3426
]
3527

3628
{ #category : 'accessing' }
37-
ExReqTracingPoint class >> removeBreakpoint: aBreakpoint [
29+
ExReqTracingPoint >> bePrecondition [
30+
31+
isPrecondition := true
32+
]
3833

39-
| nodes |
40-
nodes := aBreakpoint link nodes copy.
41-
self notifyBreakpointRemoved: aBreakpoint fromNodes: nodes.
42-
self all remove: aBreakpoint ifAbsent: [ ].
34+
{ #category : 'API' }
35+
ExReqTracingPoint >> hitWithContext: aContext [
36+
37+
"We do not emit an event for some obscure reason ..."
38+
self enabled ifFalse: [ ^ false ].
39+
self saveContext: aContext.
40+
(self checkBehaviors allSatisfy: [ :behavior | behavior execute ])
41+
ifFalse: [ ^ false ].
42+
self sideEffectBehaviors do: [ :behavior | behavior execute ].
43+
44+
self enabled: false.
45+
self verifyStepsConditionWithContext: aContext.
46+
self enabled: true.
47+
^ true
4348
]
4449

45-
{ #category : 'api' }
46-
ExReqTracingPoint >> breakInContext: aContext node: aNode [
50+
{ #category : 'API' }
51+
ExReqTracingPoint >> hitWithContext: aContext value: aValue [
4752

48-
self isEnabled ifFalse: [ ^ self ].
53+
(self hitWithContext: aContext) ifFalse: [ ^ self ].
54+
self enabled ifFalse: [ ^ self ].
4955
self enabled: false.
5056
self verifyStepsConditionWithContext: aContext.
5157
self enabled: true
5258
]
5359

54-
{ #category : 'initialization' }
60+
{ #category : 'accessing' }
5561
ExReqTracingPoint >> initialize [
5662

5763
super initialize.
58-
enabled := true
64+
isPrecondition := true.
65+
]
66+
67+
{ #category : 'accessing' }
68+
ExReqTracingPoint >> isPrecondition [
69+
70+
^ isPrecondition
71+
]
72+
73+
{ #category : 'default values' }
74+
ExReqTracingPoint >> metaLink [
75+
76+
^ self isPrecondition
77+
ifTrue: [ self preconditionMetaLink ]
78+
ifFalse: [ self postconditionMetaLink ]
79+
]
80+
81+
{ #category : 'accessing' }
82+
ExReqTracingPoint >> name [
83+
84+
^ name ifNil: [ #TracingPoint ]
85+
]
86+
87+
{ #category : 'default values' }
88+
ExReqTracingPoint >> postconditionMetaLink [
89+
90+
^ MetaLink new
91+
metaObject: self;
92+
options: #( #+ optionCompileOnLinkInstallation );
93+
selector: #hitWithContext:;
94+
control: #after;
95+
arguments: #( context )
96+
]
97+
98+
{ #category : 'default values' }
99+
ExReqTracingPoint >> preconditionMetaLink [
100+
101+
^ MetaLink new
102+
metaObject: self;
103+
options: #( #+ optionCompileOnLinkInstallation );
104+
selector: #hitWithContext:;
105+
arguments: #( context )
59106
]
60107

61108
{ #category : 'accessing' }
@@ -65,13 +112,25 @@ ExReqTracingPoint >> stepReports [
65112
]
66113

67114
{ #category : 'accessing' }
68-
ExReqTracingPoint >> stepReports: aCollection [
115+
ExReqTracingPoint >> stepReports: anObject [
116+
117+
stepReports := anObject
118+
]
119+
120+
{ #category : 'accessing' }
121+
ExReqTracingPoint >> type [
69122

70-
stepReports := aCollection
123+
^ #TracingPoint
71124
]
72125

73-
{ #category : 'api' }
126+
{ #category : 'API' }
74127
ExReqTracingPoint >> verifyStepsConditionWithContext: aContext [
75128

76-
self shouldBeImplemented
129+
self isPrecondition
130+
ifTrue: [
131+
self stepReports do: [ :stepReport |
132+
stepReport verifyStepPreconditionWithContext: aContext ] ]
133+
ifFalse: [
134+
self stepReports do: [ :stepReport |
135+
stepReport verifyStepPostconditionWithContext: aContext ] ]
77136
]

src/ExecutableRequirements/ExReqTracingPointContainer.class.st

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,36 @@ ExReqTracingPointContainer >> createTracingPoint [
1616

1717
| astNode |
1818
astNode := self stepReports first step node.
19-
preconditionTracingPoint := ExReqPreconditionTracingPoint new
19+
20+
preconditionTracingPoint := ExReqTracingPoint new
21+
bePrecondition;
2022
node: astNode;
23+
stepReports: self stepReports;
2124
yourself.
22-
postconditionTracingPoint := ExReqPostconditionTracingPoint new
25+
postconditionTracingPoint := ExReqTracingPoint new
26+
bePostcondition;
2327
node: astNode;
28+
stepReports: self stepReports;
2429
yourself.
25-
preconditionTracingPoint stepReports: self stepReports.
26-
postconditionTracingPoint stepReports: self stepReports.
30+
31+
self installTracingPoint: preconditionTracingPoint withBehaviors: { }.
32+
self installTracingPoint: postconditionTracingPoint withBehaviors: { }
33+
]
34+
35+
{ #category : 'as yet unclassified' }
36+
ExReqTracingPointContainer >> installTracingPoint: dp withBehaviors: aListOfBehaviorClasses [
37+
38+
| ml |
39+
ml := dp metaLink.
40+
41+
dp link: ml.
42+
dp install.
43+
ExReqTracingPoint add: dp.
44+
45+
"adding behaviors"
46+
aListOfBehaviorClasses do: [ :bhc | dp addBehavior: bhc new ].
47+
48+
^ dp
2749
]
2850

2951
{ #category : 'initialization' }

0 commit comments

Comments
 (0)