Skip to content

Commit

Permalink
Merge pull request #626 from adri09070/assertion-rewriting
Browse files Browse the repository at this point in the history
Integrating assertion rewriting (2nd attempt)
  • Loading branch information
StevenCostiou authored Dec 4, 2023
2 parents 3c8642d + 1eca8c5 commit 14fe9a3
Show file tree
Hide file tree
Showing 15 changed files with 464 additions and 66 deletions.
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

0 comments on commit 14fe9a3

Please sign in to comment.