-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add toList and toSortedList operators
Signed-off-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
494bbb0
commit ddeee05
Showing
6 changed files
with
480 additions
and
247 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
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 |
---|---|---|
|
@@ -16,10 +16,12 @@ | |
|
||
package nextflow.extension | ||
|
||
import groovyx.gpars.dataflow.DataflowQueue | ||
import groovyx.gpars.dataflow.DataflowVariable | ||
import groovyx.gpars.dataflow.operator.DataflowEventListener | ||
import nextflow.Session | ||
import spock.lang.Specification | ||
import spock.lang.Unroll | ||
|
||
/** | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
|
@@ -70,4 +72,75 @@ class DataflowHelperTest extends Specification { | |
[0,1,4] | ['A','B','C','D','E','F'] | ['A','B','E'] | ['C','D','F'] | ||
[0] | 'A' | ['A'] | [] | ||
} | ||
|
||
def 'should validate reduce params' () { | ||
given: | ||
def source = new DataflowQueue() | ||
def target = new DataflowVariable() | ||
def action = {-> 1} | ||
def beforeBind = {-> 2} | ||
def params = new DataflowHelper.ReduceParams() | ||
.withSource(source) | ||
.withTarget(target) | ||
.withSeed('xyz') | ||
.withAction(action) | ||
.withBeforeBind(beforeBind) | ||
|
||
expect: | ||
params.source.is(source) | ||
params.target.is(target) | ||
params.seed.is('xyz') | ||
params.action.is(action) | ||
params.beforeBind.is(beforeBind) | ||
} | ||
|
||
def 'should validate operator params' () { | ||
when: | ||
def p1 = new DataflowHelper.OpParams().toMap() | ||
then: | ||
p1.inputs == List.of() | ||
p1.outputs == List.of() | ||
p1.listeners == List.of() | ||
|
||
when: | ||
def s1 = new DataflowQueue() | ||
def t1 = new DataflowQueue() | ||
def l1 = Mock(DataflowEventListener) | ||
and: | ||
def p2 = new DataflowHelper.OpParams() | ||
.withInput(s1) | ||
.withOutput(t1) | ||
.withListener(l1) | ||
.withAccumulator(true) | ||
then: | ||
p2.inputs == List.of(s1) | ||
p2.outputs == List.of(t1) | ||
p2.listeners == List.of(l1) | ||
p2.accumulator | ||
and: | ||
p2.toMap().inputs == List.of(s1) | ||
p2.toMap().outputs == List.of(t1) | ||
p2.toMap().listeners == List.of(l1) | ||
|
||
when: | ||
def s2 = new DataflowQueue() | ||
def t2 = new DataflowQueue() | ||
def l2 = Mock(DataflowEventListener) | ||
and: | ||
def p3 = new DataflowHelper.OpParams() | ||
.withInputs([s1,s2]) | ||
.withOutputs([t1,t2]) | ||
.withListeners([l1,l2]) | ||
.withAccumulator(false) | ||
then: | ||
p3.inputs == List.of(s1,s2) | ||
p3.outputs == List.of(t1,t2) | ||
p3.listeners == List.of(l1,l2) | ||
!p3.accumulator | ||
and: | ||
p3.toMap().inputs == List.of(s1,s2) | ||
p3.toMap().outputs == List.of(t1,t2) | ||
p3.toMap().listeners == List.of(l1,l2) | ||
|
||
} | ||
} |
Oops, something went wrong.