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

make sure the activation is in state error when input is invalid for paral… #41

Merged
merged 4 commits into from
Jun 11, 2024
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
13 changes: 13 additions & 0 deletions source/FingerBoard-Core-Tests/FBFlowTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ FBFlowTest >> testNodeWithIdError [
raise: FBNodeNotFound
]

{ #category : #tests }
FBFlowTest >> testParallelNodeEmptyList [
| flow instance |
flow := FBFlow parallelFlowOpen.
instance := flow newInstance.
instance executeWith: { }.
self assert: instance atEnd.
self assert: instance state equals: #done.
"there should be one activation per node. The flow should have stopped at the parallel node because the collection was empty"
self assert: instance activations size equals: 2.

]

{ #category : #tests }
FBFlowTest >> testParallelNodeJoined [
| flow instance |
Expand Down
5 changes: 0 additions & 5 deletions source/FingerBoard-Core/FBActivation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ FBActivation >> events [
^ self flowInstance eventsOfActivation: self
]

{ #category : #accessing }
FBActivation >> instance [
^ executor flowInstance
]

{ #category : #'as yet unclassified' }
FBActivation >> isDone [
^ state = #done
Expand Down
5 changes: 5 additions & 0 deletions source/FingerBoard-Core/FBBaseActivation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ FBBaseActivation >> initialize [
state := #created
]

{ #category : #accessing }
FBBaseActivation >> instance [
^ executor flowInstance
]

{ #category : #accessing }
FBBaseActivation >> node [
^ node
Expand Down
7 changes: 1 addition & 6 deletions source/FingerBoard-Core/FBParallelExecutor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ FBParallelExecutor >> step [
transition := pending removeFirst.
values := transition source lastValueIn: self.
activation := self newActivation: transition.
(values isCollection and: [ values isSequenceable ]) ifFalse: [
self addEvent: (FBNodeActivationErrored new
activation: activation;
activationError:
'Input for parallel execution has to be a collection.').
^ self ].
activation initializeValues: list size.
lastValue := values at: index.
activation argument: lastValue.
self activate: activation.
Expand Down
16 changes: 11 additions & 5 deletions source/FingerBoard-Core/FBParallelNodeBehavior.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ Class {
}

{ #category : #execution }
FBParallelNodeBehavior >> execute [
activation flowInstance pushExecutor: (FBParallelExecutor new
node: activation node;
list: activation argument ).
activation value: activation argument
FBParallelNodeBehavior >> execute [

(activation argument isCollection and: [
activation argument isSequenceable ]) ifFalse: [
FBError signal:
'Input for parallel execution has to be a non empty collection.' ].
activation argument size > 0 ifFalse: [ ^ self ].
activation flowInstance pushExecutor: (FBParallelExecutor new
node: activation node;
list: activation argument).
activation value: activation argument
]
Loading