@@ -7,12 +7,12 @@ import (
7
7
"testing"
8
8
)
9
9
10
- func TestComposition (t * testing.T ) {
10
+ func TestCompose (t * testing.T ) {
11
11
c1 := integers {1 , 2 , 3 , 4 , 5 }
12
12
c2 := integers {10 , 20 , 30 , 40 , 50 }
13
13
input := ep .NewDataset (c1 , c2 )
14
14
15
- t .Run ("OnePiece " , func (t * testing.T ) {
15
+ t .Run ("single Composable " , func (t * testing.T ) {
16
16
runner := ep .Compose (
17
17
[]ep.Type {integer },
18
18
& addInts {},
@@ -26,7 +26,7 @@ func TestComposition(t *testing.T) {
26
26
require .Equal (t , expected , res .At (0 ).Strings ())
27
27
})
28
28
29
- t .Run ("TwoPieces " , func (t * testing.T ) {
29
+ t .Run ("multiple Composables " , func (t * testing.T ) {
30
30
runner := ep .Compose (
31
31
[]ep.Type {integer },
32
32
& addInts {}, & negateInt {},
@@ -45,25 +45,25 @@ func TestComposeProject(t *testing.T) {
45
45
col := integers {1 , 2 , 3 , 4 , 5 }
46
46
input := ep .NewDataset (col )
47
47
48
- comp1 := ep .Compose (
49
- []ep.Type {integer },
50
- & negateInt {}, & mulIntBy2 {},
51
- ).(ep.Composable )
52
- comp2 := ep .Compose (
53
- []ep.Type {integer },
54
- & mulIntBy2 {}, & mulIntBy2 {}, & negateInt {},
55
- ).(ep.Composable )
56
- project := ep .ComposeProject (comp1 , comp2 )
48
+ proj1 := & negateInt {}
49
+ proj2 := ep .ComposeProject (& mulIntBy2 {}, & negateInt {})
50
+ proj3 := & mulIntBy2 {}
57
51
58
- composition := ep .Compose (
59
- []ep.Type {integer , integer },
60
- project , & addInts {},
61
- )
62
- expected := []string {"-6" , "-12" , "-18" , "-24" , "-30" }
52
+ project := ep .ComposeProject (proj1 , proj2 , proj3 )
53
+ batchFunction := project .BatchFunction ()
63
54
64
- res , err := eptest .Run (composition , input )
55
+ expected1 := []string {"-1" , "-2" , "-3" , "-4" , "-5" }
56
+ expected2 := []string {"2" , "4" , "6" , "8" , "10" }
57
+ expected3 := []string {"-1" , "-2" , "-3" , "-4" , "-5" }
58
+ expected4 := []string {"2" , "4" , "6" , "8" , "10" }
59
+
60
+ res , err := batchFunction (input )
65
61
require .NoError (t , err )
66
- require .Equal (t , 1 , res .Width ())
62
+ require .Equal (t , 4 , res .Width ())
67
63
require .Equal (t , input .Len (), res .Len ())
68
- require .Equal (t , expected , res .At (0 ).Strings ())
64
+
65
+ require .Equal (t , expected1 , res .At (0 ).Strings ())
66
+ require .Equal (t , expected2 , res .At (1 ).Strings ())
67
+ require .Equal (t , expected3 , res .At (2 ).Strings ())
68
+ require .Equal (t , expected4 , res .At (3 ).Strings ())
69
69
}
0 commit comments