Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Halt once on call #15543

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/Reflectivity-Tools-Tests/BreakpointTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ BreakpointTest >> testObjectCentricAPI [
object2 := ReflectivityExamples new.

Breakpoint breakOn: #exampleAssignment inObject: object1.

self should: [object1 exampleAssignment] raise: Break.
self shouldnt: [object2 exampleAssignment] raise: Break.

Breakpoint breakOnceOn: #exampleAssignment inObject: object2.
self should: [object2 exampleAssignment] raise: Break.
self shouldnt: [object2 exampleAssignment] raise: Break
]

Expand All @@ -227,8 +230,11 @@ BreakpointTest >> testObjectCentricASTAPI [
ast := (ReflectivityExamples >> #exampleAssignment) ast statements first.

Breakpoint breakOnAST: ast inObject: object1.

self should: [object1 exampleAssignment] raise: Break.
self shouldnt: [object2 exampleAssignment] raise: Break.

Breakpoint breakOnceOnAST: ast inObject: object2.
self should: [object2 exampleAssignment] raise: Break.
self shouldnt: [object2 exampleAssignment] raise: Break
]

Expand Down Expand Up @@ -258,11 +264,27 @@ BreakpointTest >> testObjectCentricObjectAPI [
object2 := ReflectivityExamples new.

object1 haltOnCallTo: #exampleAssignment.

self should: [object1 exampleAssignment] raise: Break.
self shouldnt: [object2 exampleAssignment] raise: Break.

object2 haltOnceOnCallTo: #exampleAssignment.
self should: [object2 exampleAssignment] raise: Break.
self shouldnt: [object2 exampleAssignment] raise: Break
]

{ #category : 'tests' }
BreakpointTest >> testOnceBreakpointDisableAfterHit [
|object breakpoint|
object := ReflectivityExamples new.

breakpoint := Breakpoint breakOnceOn: #exampleAssignment inObject: object.
breakpoint disable.
self shouldnt: [object exampleAssignment] raise: Break.
breakpoint enable.
self should: [object exampleAssignment] raise: Break.
self deny: breakpoint isEnabled
]

{ #category : 'tests' }
BreakpointTest >> testRemoveBreakpointWithRemoveFrom [
|bp node |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ Class {
#classVars : [
'ClassVar'
],
#category : 'Reflectivity-Tests-Breakpoints',
#package : 'Reflectivity-Tests',
#tag : 'Breakpoints'
#category : 'Reflectivity-Tools-Tests',
#package : 'Reflectivity-Tools-Tests'
}

{ #category : 'accessing' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ Class {
'testClass',
'testSubclass'
],
#category : 'Reflectivity-Tests-Breakpoints',
#package : 'Reflectivity-Tests',
#tag : 'Breakpoints'
#category : 'Reflectivity-Tools-Tests',
#package : 'Reflectivity-Tools-Tests'
}

{ #category : 'helpers' }
Expand Down
20 changes: 20 additions & 0 deletions src/Reflectivity/Breakpoint.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ Breakpoint class >> breakOnAST: aNode inObject: anObject [
^ breakpoint
]

{ #category : 'API - object-centric' }
Breakpoint class >> breakOnceOn: aSelector inObject: anObject [

| ast |
ast := (anObject class lookupSelector: aSelector) ast.
^ self breakOnceOnAST: ast inObject: anObject
]

{ #category : 'API - object-centric' }
Breakpoint class >> breakOnceOnAST: aNode inObject: anObject [

| breakpoint |
breakpoint := self new.
breakpoint once: true.
breakpoint node: aNode.
breakpoint scopeTo: anObject.
breakpoint install.
^ breakpoint
]

{ #category : 'accessing' }
Breakpoint class >> browseAll [
<script>
Expand Down
6 changes: 6 additions & 0 deletions src/Reflectivity/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ Object >> haltOnWriteTo: aVariableName [
inObject: self
]

{ #category : '*Reflectivity' }
Object >> haltOnceOnCallTo: aSelector [

^ Breakpoint breakOnceOn: aSelector inObject: self
]

{ #category : '*Reflectivity' }
Object >> intanceSpecificMetaLinksAvailable [
^true
Expand Down