Skip to content

Commit

Permalink
change 06 to fix issue #103
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobuzzi committed Aug 13, 2018
1 parent 2a8f00c commit 1c25f85
Showing 1 changed file with 39 additions and 18 deletions.
57 changes: 39 additions & 18 deletions sources/uml/UMLVirtualMachineTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -68,47 +68,64 @@ testIssue51
testIssue53
| parsedCode result |

executionSnapshot := UMLScriptExecutionSnapshot virtualMachine: virtualMachine.
parsedCode := self umlCompiler parseExpression: 'Card new account: 9'. "type mismatch to get an error"
executionSnapshot activateSnaphotWith: parsedCode.
result := virtualMachine executeSequenceNodeReturningAll: parsedCode in: executionSnapshot.

result := virtualMachine executeSequenceNodeReturningAll: parsedCode in: nil.

self assert: (result last umlClass name = 'Error').!

testIssue54
| isActive parsedCode |

isActive := virtualMachine transLog logIsActive.
virtualMachine transLog logIsActive: true.
virtualMachine transLog cleanAll; logIsActive: true.

executionSnapshot := UMLScriptExecutionSnapshot virtualMachine: virtualMachine.
parsedCode := self umlCompiler parseExpression: 'Card new expirationDate: Date new'.
executionSnapshot activateSnaphotWith: parsedCode.
virtualMachine executeSequenceNodeReturningAll: parsedCode in: executionSnapshot.
self assert: (virtualMachine transLog logs detect: [:each | (each methodName = #expirationDate:) and: [each snapshot == executionSnapshot]] ifNone: [self assert: false]) notNil.
virtualMachine executeSequenceNodeReturningAll: parsedCode in: nil.

self assert: (virtualMachine transLog logs detect: [:each | (each methodName = #expirationDate:)] ifNone: [self assert: false]) notNil.

executionSnapshot := UMLScriptExecutionSnapshot virtualMachine: virtualMachine.
parsedCode := self umlCompiler parseExpression: 'Card new expirationDate'.
executionSnapshot activateSnaphotWith: parsedCode.
virtualMachine executeSequenceNodeReturningAll: parsedCode in: executionSnapshot.
self assert: (virtualMachine transLog logs detect: [:each | (each methodName = #expirationDate) and: [each snapshot == executionSnapshot]] ifNone: [self assert: false]) notNil.
virtualMachine executeSequenceNodeReturningAll: parsedCode in: nil.

self assert: (virtualMachine transLog logs detect: [:each | (each methodName = #expirationDate)] ifNone: [self assert: false]) notNil.

virtualMachine transLog logIsActive: isActive.
!

testIssue56
| parsedCode result |

executionSnapshot := UMLScriptExecutionSnapshot virtualMachine: virtualMachine.
parsedCode := self umlCompiler parseExpression: '[Card foo] on: Error do: [:ex | ]'.
executionSnapshot activateSnaphotWith: parsedCode.
parsedCode := self umlCompiler parseExpression: '[Card foo] on: Error do: [:ex |]'.

result := virtualMachine executeSequenceNodeReturningAll: parsedCode in: executionSnapshot.
result := virtualMachine executeSequenceNodeReturningAll: parsedCode in: nil.

self assert: (virtualMachine nilObject == result last).

!

testIssue56_b
| parsedCode result |

parsedCode := self umlCompiler parseExpression: '[Card foo] on: Error do: [:ex | 97]'.

result := virtualMachine executeSequenceNodeReturningAll: parsedCode in: nil.

self assert: (result last smalltalkObject = 97).

!

testIssue56_c
| parsedCode result |

parsedCode := self umlCompiler parseExpression: '[Array new. String new. Card foo. Array new] on: Error do: [:ex | 97]'.

result := virtualMachine executeSequenceNodeReturningAll: parsedCode in: nil.

self assert: (result last smalltalkObject = 97).

!

testIssue66
| personClass transactionRuleClass method |

Expand Down Expand Up @@ -138,7 +155,8 @@ testIssue69

implementation := self externaFileClass addSourceImplementation: source.
umlObject := self externaFileClass newInstance.
snapshot := UMLImplementationExecutionSnapshot activateSnapshotWith: implementation receiver: umlObject arguments: #() virtualMachine: virtualMachine.
snapshot := UMLImplementationExecutionSnapshot activateSnapshotWith: implementation receiver: umlObject arguments: #() virtualMachine: virtualMachine.
snapshot parentSnapshot: nil.
virtualMachine apply: implementation to: umlObject with: #() snapshot: snapshot isFakeImplementation: false.

UMLDebuggerShell allInstances do: [:each | each view destroy].
Expand All @@ -157,7 +175,8 @@ testIssue69_b

implementation := self externaFileClass addSourceImplementation: source.
umlObject := self externaFileClass newInstance.
snapshot := UMLImplementationExecutionSnapshot activateSnapshotWith: implementation receiver: umlObject arguments: #() virtualMachine: virtualMachine.
snapshot := UMLImplementationExecutionSnapshot activateSnapshotWith: implementation receiver: umlObject arguments: #() virtualMachine: virtualMachine.
snapshot parentSnapshot: nil.
result := virtualMachine apply: implementation to: umlObject with: #() snapshot: snapshot isFakeImplementation: false.

UMLDebuggerShell allInstances do: [:each | each view destroy].
Expand Down Expand Up @@ -195,6 +214,8 @@ testIssue72
!UMLVirtualMachineTest categoriesFor: #testIssue53!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue54!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue56!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue56_b!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue56_c!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue66!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue69!public! !
!UMLVirtualMachineTest categoriesFor: #testIssue69_b!public! !
Expand Down

0 comments on commit 1c25f85

Please sign in to comment.