-
-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breakpoints: added experimental breakpoint notifications (trivial ded…
…icated observer) and refactorised a bit. Modified the standard Break meta-behavior so that it includes more contextual elements (added metalink parameters).
- Loading branch information
1 parent
e484d0e
commit 15c3a3a
Showing
10 changed files
with
323 additions
and
8 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/Reflectivity-Tools-Tests/BreakpointObserverTest.class.st
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,98 @@ | ||
Class { | ||
#name : #BreakpointObserverTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'oldObservers', | ||
'breakpoint', | ||
'cls', | ||
'previousBreakpoints', | ||
'observer' | ||
], | ||
#category : #'Reflectivity-Tools-Tests' | ||
} | ||
|
||
{ #category : #helpers } | ||
BreakpointObserverTest >> newDummyClass [ | ||
^ Object | ||
subclass: #DummyClassForBreakpoint | ||
instanceVariableNames: '' | ||
classVariableNames: '' | ||
package: 'DummyPackage' | ||
] | ||
|
||
{ #category : #running } | ||
BreakpointObserverTest >> setUp [ | ||
"Hooks that subclasses may override to define the fixture of test." | ||
|
||
super setUp. | ||
previousBreakpoints := Breakpoint all copy. | ||
oldObservers := Breakpoint observers copy. | ||
Breakpoint observers removeAll. | ||
cls := self newDummyClass. | ||
breakpoint := Breakpoint new. | ||
cls compile: 'dummy ^42'. | ||
breakpoint | ||
node: (cls >> #dummy) ast; | ||
once. | ||
observer := DummyBreakpointObserver new | ||
] | ||
|
||
{ #category : #running } | ||
BreakpointObserverTest >> tearDown [ | ||
|pkg| | ||
Breakpoint observers removeAll. | ||
Breakpoint observers addAll: oldObservers. | ||
cls ifNotNil: [ cls isObsolete ifFalse: [ cls removeFromSystem ] ]. | ||
pkg := 'DummyPackage' asPackageIfAbsent: [ ]. | ||
pkg ifNotNil: [ pkg removeFromSystem ]. | ||
Breakpoint removeAll. | ||
Breakpoint all addAll: previousBreakpoints. | ||
super tearDown | ||
] | ||
|
||
{ #category : #tests } | ||
BreakpointObserverTest >> testNotifyBreakpointAdded [ | ||
Breakpoint registerObserver: observer. | ||
breakpoint install. | ||
self assert: observer tag class equals: BreakpointAddedNotification. | ||
self assert: observer tag breakpoint identicalTo: breakpoint. | ||
self assertCollection: observer tag nodes equals: { (cls >> #dummy) ast } asSet | ||
] | ||
|
||
{ #category : #tests } | ||
BreakpointObserverTest >> testNotifyBreakpointHit [ | ||
Breakpoint registerObserver: observer. | ||
breakpoint install. | ||
self should: [cls new dummy] raise: Break. | ||
self assert: observer tag class equals: BreakpointHitNotification. | ||
self assert: observer tag breakpoint identicalTo: breakpoint. | ||
self assert: observer tag valueOrNil isNil | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
BreakpointObserverTest >> testNotifyBreakpointRemoved [ | ||
breakpoint install. | ||
Breakpoint registerObserver: observer. | ||
breakpoint remove. | ||
self assert: observer tag class equals: BreakpointRemovedNotification. | ||
self assert: observer tag breakpoint identicalTo: breakpoint. | ||
self assertCollection: observer tag nodes equals: { (cls >> #dummy) ast } asSet | ||
] | ||
|
||
{ #category : #tests } | ||
BreakpointObserverTest >> testRegisterObserver [ | ||
|obs| | ||
obs := DummyBreakpointObserver new. | ||
Breakpoint registerObserver: obs. | ||
self assertCollection: Breakpoint observers includesAll: {obs} | ||
] | ||
|
||
{ #category : #tests } | ||
BreakpointObserverTest >> testUnregisterObserver [ | ||
|obs| | ||
obs := DummyBreakpointObserver new. | ||
Breakpoint registerObserver: obs. | ||
Breakpoint unregisterObserver: obs. | ||
self assertEmpty: Breakpoint observers | ||
] |
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
23 changes: 23 additions & 0 deletions
23
src/Reflectivity-Tools-Tests/DummyBreakpointObserver.class.st
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,23 @@ | ||
" | ||
I am a dummy breakpoint observer. | ||
I am also an example observer. | ||
I receives update notifications from the Breakpoint class whenever a breakpoint is added, modified or removed. | ||
" | ||
Class { | ||
#name : #DummyBreakpointObserver, | ||
#superclass : #Object, | ||
#instVars : [ | ||
'tag' | ||
], | ||
#category : #'Reflectivity-Tools-Tests' | ||
} | ||
|
||
{ #category : #accessing } | ||
DummyBreakpointObserver >> tag [ | ||
^ tag | ||
] | ||
|
||
{ #category : #updating } | ||
DummyBreakpointObserver >> update: anAspect [ | ||
tag := anAspect | ||
] |
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
27 changes: 27 additions & 0 deletions
27
src/Reflectivity/BreakpointActivationNotification.class.st
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,27 @@ | ||
" | ||
A trivial breakpoint activation notification. | ||
" | ||
Class { | ||
#name : #BreakpointActivationNotification, | ||
#superclass : #BreakpointNotification, | ||
#instVars : [ | ||
'activated' | ||
], | ||
#category : #'Reflectivity-Breakpoints' | ||
} | ||
|
||
{ #category : #accessing } | ||
BreakpointActivationNotification >> activated [ | ||
^ activated | ||
] | ||
|
||
{ #category : #accessing } | ||
BreakpointActivationNotification >> activated: anObject [ | ||
activated := anObject | ||
] | ||
|
||
{ #category : #initialize } | ||
BreakpointActivationNotification >> initialize [ | ||
super initialize. | ||
activated := true | ||
] |
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,8 @@ | ||
" | ||
A trivial breakpoint added notification. | ||
" | ||
Class { | ||
#name : #BreakpointAddedNotification, | ||
#superclass : #BreakpointNotification, | ||
#category : #'Reflectivity-Breakpoints' | ||
} |
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,22 @@ | ||
" | ||
I am a notification sent to Breakpoint observers when a breakpoint is hit. | ||
I can hold a value from the execution context the breakpoint was hit. | ||
" | ||
Class { | ||
#name : #BreakpointHitNotification, | ||
#superclass : #BreakpointNotification, | ||
#instVars : [ | ||
'valueOrNil' | ||
], | ||
#category : #'Reflectivity-Breakpoints' | ||
} | ||
|
||
{ #category : #accessing } | ||
BreakpointHitNotification >> valueOrNil [ | ||
^ valueOrNil | ||
] | ||
|
||
{ #category : #accessing } | ||
BreakpointHitNotification >> valueOrNil: anObject [ | ||
valueOrNil := anObject | ||
] |
Oops, something went wrong.