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

Integrating assertion rewriting (2nd attempt) #626

Merged
merged 7 commits into from
Dec 4, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Class {
#name : 'StGenerateAndProceedCommand',
#superclass : 'StDebuggerCommand',
#category : 'NewTools-Debugger-Commands',
#package : 'NewTools-Debugger-Commands'
}

{ #category : 'default' }
StGenerateAndProceedCommand class >> defaultDescription [

^ 'Save and compile the modified source, relinquish debugger control and proceed execution from the start of the current method.'
]

{ #category : 'default' }
StGenerateAndProceedCommand class >> defaultIconName [

^ #debuggerProceed
]

{ #category : 'default' }
StGenerateAndProceedCommand class >> defaultName [

<toolbarDebugCommand: 1200>
^ 'Gen.&Proceed'
]

{ #category : 'default' }
StGenerateAndProceedCommand class >> defaultShortcut [

^ $g meta
]

{ #category : 'testing' }
StGenerateAndProceedCommand >> appliesTo: aDebugger [

^ aDebugger canGenerateAndProceed
]

{ #category : 'testing' }
StGenerateAndProceedCommand >> execute [

self debugger saveGeneratedCodeAndProceed
]
211 changes: 154 additions & 57 deletions src/NewTools-Debugger-Tests/StDebuggerCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ StDebuggerCommandTest >> testCommandsInDNUContext [
self deny:
(StDefineSubclassResponsabilityCommand forContext: debugger)
canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
Expand Down Expand Up @@ -88,6 +90,8 @@ StDebuggerCommandTest >> testCommandsInDeadContext [
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
Expand Down Expand Up @@ -126,6 +130,10 @@ StDebuggerCommandTest >> testCommandsInErrorContext [
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
Expand All @@ -142,62 +150,125 @@ StDebuggerCommandTest >> testCommandsInErrorContext [
{ #category : 'tests' }
StDebuggerCommandTest >> testCommandsInFailingTestContext [

|debugger|
| debugger |
debugger := debuggerProvider debuggerWithFailingTestContext.
self flag:'Cannot work until we can properly detect a failing assertion context'.

"Executable commands relative to context"
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert: (StReturnValueCommand forContext: debugger) canBeExecuted.

self flag:
'Cannot work until we can properly detect a failing assertion context'.

"Executable commands relative to context"
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert:
(StReturnValueCommand forContext: debugger) canBeExecuted.

"Non-executable commands relative to context"
self deny: (StStepIntoCommand forContext: debugger) canBeExecuted.
self deny: (StStepOverCommand forContext: debugger) canBeExecuted.
self deny: (StStepThroughCommand forContext: debugger) canBeExecuted.
self deny: (StRunToSelectionCommand forContext: debugger) canBeExecuted.
self deny: (StStepIntoCommand forContext: debugger) canBeExecuted.
self deny: (StStepOverCommand forContext: debugger) canBeExecuted.
self deny: (StStepThroughCommand forContext: debugger) canBeExecuted.
self deny:
(StRunToSelectionCommand forContext: debugger) canBeExecuted.
self deny: (StProceedCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny: (StDefineSubclassResponsabilityCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineSubclassResponsabilityCommand forContext: debugger)
canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMissingEntityCommand forContext: debugger) canBeExecuted.

self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert: (StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert: (StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert: (StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert:
(StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert:
(StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert:
(StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert: (StWhereIsCommand forContext: debugger) canBeExecuted.
debugger debuggerActionModel clear
]

{ #category : 'tests' }
StDebuggerCommandTest >> testCommandsInGeneratingCodeContext [

| debugger |
debugger := debuggerProvider debuggerWithGeneratingCodeContext.

"Executable commands relative to context"
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert:
(StReturnValueCommand forContext: debugger) canBeExecuted.
self assert:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Non-executable commands relative to context"
self deny: (StProceedCommand forContext: debugger) canBeExecuted.
self deny: (StStepIntoCommand forContext: debugger) canBeExecuted.
self deny: (StStepOverCommand forContext: debugger) canBeExecuted.
self deny: (StStepThroughCommand forContext: debugger) canBeExecuted.
self deny:
(StRunToSelectionCommand forContext: debugger) canBeExecuted.
self deny: (StProceedCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineSubclassResponsabilityCommand forContext: debugger)
canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
(StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert:
(StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert:
(StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert: (StWhereIsCommand forContext: debugger) canBeExecuted
]

{ #category : 'tests' }
StDebuggerCommandTest >> testCommandsInMissingClassContext [
"When a class is missing, it is possible we are trying to send it a message.
Define new class and define new method must be possible. "
Define new class and define new method must be possible. "

| debugger |

StTestDebuggerProvider compileMissingClassContextBuilder.
debugger := debuggerProvider debuggerWithMissingClassContext.

"Executable commands relative to context"
self assert: (StDefineClassCommand forContext: debugger) canBeExecuted.

"Executable commands relative to context"
self assert:
(StDefineClassCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self assert: (StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert: (StReturnValueCommand forContext: debugger) canBeExecuted.

self assert:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert:
(StReturnValueCommand forContext: debugger) canBeExecuted.

"Non-executable commands relative to context"
self assert: (StStepIntoCommand forContext: debugger) canBeExecuted.
self assert: (StStepOverCommand forContext: debugger) canBeExecuted.
self assert: (StStepThroughCommand forContext: debugger) canBeExecuted.
self assert: (StRunToSelectionCommand forContext: debugger) canBeExecuted.
self assert: (StProceedCommand forContext: debugger) canBeExecuted.
self deny: (StDefineSubclassResponsabilityCommand forContext: debugger) canBeExecuted.


self assert: (StStepIntoCommand forContext: debugger) canBeExecuted.
self assert: (StStepOverCommand forContext: debugger) canBeExecuted.
self assert:
(StStepThroughCommand forContext: debugger) canBeExecuted.
self assert:
(StRunToSelectionCommand forContext: debugger) canBeExecuted.
self assert: (StProceedCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineSubclassResponsabilityCommand forContext: debugger)
canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert: (StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert: (StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert: (StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert:
(StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert:
(StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert:
(StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert: (StWhereIsCommand forContext: debugger) canBeExecuted.
debugger debuggerActionModel clear
]
Expand Down Expand Up @@ -228,6 +299,8 @@ StDebuggerCommandTest >> testCommandsInMissingSubclassResponsibilityContext [
self deny: (StProceedCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
Expand Down Expand Up @@ -270,6 +343,8 @@ StDebuggerCommandTest >> testCommandsInMissingSubclassResponsibilityContextWithS
self deny: (StProceedCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert:
Expand All @@ -285,29 +360,40 @@ StDebuggerCommandTest >> testCommandsInMissingSubclassResponsibilityContextWithS
{ #category : 'tests' }
StDebuggerCommandTest >> testCommandsInRunnableContext [

|debugger|
| debugger |
debugger := debuggerProvider debuggerWithRunnableContext.

"Executable commands relative to context"
self assert: (StStepIntoCommand forContext: debugger) canBeExecuted.
self assert: (StStepOverCommand forContext: debugger) canBeExecuted.
self assert: (StStepThroughCommand forContext: debugger) canBeExecuted.
self assert: (StRunToSelectionCommand forContext: debugger) canBeExecuted.
self assert: (StProceedCommand forContext: debugger) canBeExecuted.
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert: (StReturnValueCommand forContext: debugger) canBeExecuted.

self assert: (StStepIntoCommand forContext: debugger) canBeExecuted.
self assert: (StStepOverCommand forContext: debugger) canBeExecuted.
self assert:
(StStepThroughCommand forContext: debugger) canBeExecuted.
self assert:
(StRunToSelectionCommand forContext: debugger) canBeExecuted.
self assert: (StProceedCommand forContext: debugger) canBeExecuted.
self assert: (StRestartCommand forContext: debugger) canBeExecuted.
self assert:
(StReturnValueCommand forContext: debugger) canBeExecuted.

"Non-executable commands relative to context"
self deny: (StDefineSubclassResponsabilityCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny: (StDefineMissingEntityCommand forContext: debugger) canBeExecuted.

self deny:
(StDefineSubclassResponsabilityCommand forContext: debugger)
canBeExecuted.
self deny: (StDefineMethodCommand forContext: debugger) canBeExecuted.
self deny: (StDefineClassCommand forContext: debugger) canBeExecuted.
self deny:
(StDefineMissingEntityCommand forContext: debugger) canBeExecuted.
self deny:
(StGenerateAndProceedCommand forContext: debugger) canBeExecuted.

"Executable commands, whatever the context"
self assert: (StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert: (StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert: (StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert: (StProceedCommand forContext: debugger) canBeExecuted.
self assert:
(StCopyStackToClipboardCommand forContext: debugger) canBeExecuted.
self assert:
(StFileOutMethodCommand forContext: debugger) canBeExecuted.
self assert:
(StPeelToFirstCommand forContext: debugger) canBeExecuted.
self assert: (StProceedCommand forContext: debugger) canBeExecuted.
self assert: (StWhereIsCommand forContext: debugger) canBeExecuted.
debugger debuggerActionModel clear
]
Expand Down Expand Up @@ -404,6 +490,17 @@ StDebuggerCommandTest >> testStFileOutMethodCommandExecution [
self assert: debugger tag equals: #fileOutSelectedContext
]

{ #category : 'tests' }
StDebuggerCommandTest >> testStGenerateAndProceedCommandExecution [

| debugger command |
debugger := StDummyDebuggerPresenter new.
command := StGenerateAndProceedCommand forContext: debugger.
"StGenerateAndProceedCommand command calls the #saveGeneratedCodeAndProceed action interface of the debugger object"
command execute.
self assert: debugger tag equals: #saveGeneratedCodeAndProceed
]

{ #category : 'tests - execution' }
StDebuggerCommandTest >> testStPeelToFirstCommandExecution [

Expand Down
Loading