-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from TelescopeSt/development
v2.3.0
- Loading branch information
Showing
15 changed files
with
453 additions
and
29 deletions.
There are no files selected for viewing
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
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,36 @@ | ||
Class { | ||
#name : #TLConnectActionTest, | ||
#superclass : #TestCase, | ||
#category : #'Telescope-Core-Tests-Actions' | ||
} | ||
|
||
{ #category : #tests } | ||
TLConnectActionTest >> testTriggerAction [ | ||
| connectAction sourceNode targetNode | | ||
sourceNode := TLSimpleNode withEntity: 4. | ||
targetNode := TLSimpleNode withEntity: 2. | ||
connectAction := TLConnectAction | ||
property: [ :e | {e sqrt} ] | ||
context: (TLDrawableCollection with: sourceNode with: targetNode). | ||
connectAction actionOn: sourceNode. | ||
self assert: sourceNode outgoingConnections size equals: 1. | ||
self assert: targetNode incomingConnections size equals: 1. | ||
self | ||
assert: sourceNode outgoingConnections anyOne | ||
equals: targetNode incomingConnections anyOne | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectActionTest >> testTriggerActionTwiceForReversibility [ | ||
"this test is valid only if testTriggerAction is valid" | ||
| connectAction sourceNode targetNode | | ||
sourceNode := TLSimpleNode withEntity: 4. | ||
targetNode := TLSimpleNode withEntity: 2. | ||
connectAction := TLConnectAction | ||
property: [ :e | {e sqrt} ] | ||
context: (TLDrawableCollection with: sourceNode with: targetNode). | ||
connectAction actionOn: sourceNode. | ||
connectAction actionOn: sourceNode. | ||
self assert: sourceNode outgoingConnections isEmpty. | ||
self assert: targetNode incomingConnections isEmpty | ||
] |
38 changes: 38 additions & 0 deletions
38
src/Telescope-Core-Tests/TLConnectWithEntityActionTest.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,38 @@ | ||
Class { | ||
#name : #TLConnectWithEntityActionTest, | ||
#superclass : #TestCase, | ||
#category : #'Telescope-Core-Tests-Actions' | ||
} | ||
|
||
{ #category : #tests } | ||
TLConnectWithEntityActionTest >> testTriggerAction [ | ||
| connectAction sourceNode targetNode | | ||
sourceNode := TLSimpleNode withEntity: 4. | ||
targetNode := TLSimpleNode withEntity: 2. | ||
connectAction := TLConnectWithEntityAction | ||
connectionProperty: [ :e | {e squared} ] | ||
property: [ :connectionEntity | connectionEntity / 8 ] | ||
context: (TLDrawableCollection with: sourceNode with: targetNode). | ||
connectAction actionOn: sourceNode. | ||
self assert: sourceNode outgoingConnections size equals: 1. | ||
self assert: targetNode incomingConnections size equals: 1. | ||
self | ||
assert: sourceNode outgoingConnections anyOne | ||
equals: targetNode incomingConnections anyOne | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectWithEntityActionTest >> testTriggerActionTwiceForReversibility [ | ||
"this test is valid only if testTriggerAction is valid" | ||
| connectAction sourceNode targetNode | | ||
sourceNode := TLSimpleNode withEntity: 4. | ||
targetNode := TLSimpleNode withEntity: 2. | ||
connectAction := TLConnectWithEntityAction | ||
connectionProperty: [ :e | {e squared} ] | ||
property: [ :connectionEntity | connectionEntity / 8 ] | ||
context: (TLDrawableCollection with: sourceNode with: targetNode). | ||
connectAction actionOn: sourceNode. | ||
connectAction actionOn: sourceNode. | ||
self assert: sourceNode outgoingConnections isEmpty. | ||
self assert: targetNode incomingConnections isEmpty | ||
] |
83 changes: 83 additions & 0 deletions
83
src/Telescope-Core-Tests/TLConnectionsWithEntityTest.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,83 @@ | ||
Class { | ||
#name : #TLConnectionsWithEntityTest, | ||
#superclass : #TestCase, | ||
#instVars : [ | ||
'group' | ||
], | ||
#category : #'Telescope-Core-Tests-Model' | ||
} | ||
|
||
{ #category : #running } | ||
TLConnectionsWithEntityTest >> setUp [ | ||
super setUp. | ||
group := TLEntitiesGroup new. | ||
TLVisualization new addDrawable: group. | ||
group addNodesFromEntities: (1 to: 4) | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectGroupFromANode [ | ||
| connections | | ||
connections := group connectFrom: TLSimpleNode new entity: 42. | ||
self assert: connections size equals: 4. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectGroupToANode [ | ||
| connections | | ||
connections := group connectTo: TLSimpleNode new entity: 42. | ||
self assert: connections size equals: 4 | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectGroupWithSubgroupFromANode [ | ||
| connections | | ||
group > #subgroup addNodesFromEntities: (5 to: 8). | ||
connections := group connectFrom: TLSimpleNode new entity: 42.. | ||
self assert: connections size equals: 8. | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectGroupWithSubgroupToANode [ | ||
| connections | | ||
group > #subgroup addNodesFromEntities: (5 to: 8). | ||
connections := group connectTo: TLSimpleNode new entity: 42.. | ||
self assert: connections size equals: 8. | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectNodeFromAGroup [ | ||
| connections | | ||
connections := TLSimpleNode new connectFrom: group entity: 42.. | ||
self assert: connections size equals: 4. | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectNodeFromAnotherNode [ | ||
| connection nodeA nodeB | | ||
nodeA := TLSimpleNode withEntity: $a. | ||
nodeB := TLSimpleNode withEntity: $b. | ||
connection := nodeB connectFrom: nodeA entity: 42. | ||
self assert: connection fromNode equals: nodeA. | ||
self assert: connection toNode equals: nodeB. | ||
|
||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectNodeToAGroup [ | ||
| connections | | ||
connections := TLSimpleNode new connectTo: group entity: 42. | ||
self assert: connections size equals: 4. | ||
] | ||
|
||
{ #category : #tests } | ||
TLConnectionsWithEntityTest >> testConnectNodeToAnotherNode [ | ||
| connection nodeA nodeB | | ||
nodeA := TLSimpleNode withEntity: $a. | ||
nodeB := TLSimpleNode withEntity: $b. | ||
connection := nodeA connectTo: nodeB entity: 42. | ||
self assert: connection fromNode equals: nodeA. | ||
self assert: connection toNode equals: nodeB. | ||
|
||
] |
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
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,68 @@ | ||
" | ||
TLConnectionectAction is an action that create TLConnectionWithEntity from the receiver to an other node | ||
" | ||
Class { | ||
#name : #TLConnectWithEntityAction, | ||
#superclass : #TLConnectAction, | ||
#instVars : [ | ||
'connectionProperty' | ||
], | ||
#category : #'Telescope-Core-Actions' | ||
} | ||
|
||
{ #category : #'as yet unclassified' } | ||
TLConnectWithEntityAction class >> connectionProperty: aConnectionBlockOrProperty property: aBlockOrProperty [ | ||
^ self new | ||
connectionProperty: aConnectionBlockOrProperty; | ||
property: aBlockOrProperty; | ||
yourself | ||
] | ||
|
||
{ #category : #'as yet unclassified' } | ||
TLConnectWithEntityAction class >> connectionProperty: aConnectionBlockOrProperty property: aBlockOrProperty context: aTLGroup [ | ||
^ (self | ||
connectionProperty: aConnectionBlockOrProperty | ||
property: aBlockOrProperty) | ||
context: aTLGroup; | ||
yourself | ||
] | ||
|
||
{ #category : #accessing } | ||
TLConnectWithEntityAction >> connectionProperty [ | ||
^ connectionProperty | ||
] | ||
|
||
{ #category : #accessing } | ||
TLConnectWithEntityAction >> connectionProperty: anObject [ | ||
connectionProperty := anObject | ||
] | ||
|
||
{ #category : #action } | ||
TLConnectWithEntityAction >> regularActionOn: aNode [ | ||
| connectionEntities contextNodesByEntities | | ||
connectionEntities := self | ||
obtain: self connectionProperty | ||
on: aNode entity. | ||
contextNodesByEntities := (self obtainContextFor: aNode) | ||
groupedBy: #entity. | ||
self connectionsByNode | ||
at: aNode | ||
put: | ||
((self obtain: self connectToOrigin on: aNode entity) | ||
ifFalse: [ connectionEntities | ||
collect: [ :aConnectionEntity | | ||
aNode | ||
connectTo: | ||
(contextNodesByEntities | ||
at: (self obtain: self property on: aConnectionEntity)) | ||
entity: aConnectionEntity ] ] | ||
ifTrue: [ connectionEntities | ||
collect: [ :aConnectionEntity | | ||
(contextNodesByEntities | ||
at: (self obtain: self property on: aConnectionEntity)) | ||
connectTo: aNode | ||
entity: aConnectionEntity ] ]). | ||
self connectionStyle | ||
ifNotNil: [ (self connectionsByNode at: aNode) | ||
do: [ :c | c addStyle: self connectionStyle ] ] | ||
] |
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
Oops, something went wrong.