public function testItApplyTheCallableOnEachItem()
 {
     $transducer = Fp\filtering(is_even_makker());
     $squared = Fp\transduce($transducer, Fp\appending(), range(1, 6));
     $this->assertEquals([2, 4, 6], $squared);
 }
 public function testItEnumerateItems()
 {
     $transducer = Fp\enumerating();
     $transformed = Fp\transduce($transducer, Fp\appending(), range(1, 3));
     $this->assertEquals([[0, 1], [1, 2], [2, 3]], $transformed);
 }
Exemple #3
0
 public function testItApplyTheCallableOnEachItem()
 {
     $transducer = Fp\mapping(square_makker());
     $squared = Fp\transduce($transducer, Fp\appending(), range(1, 2));
     $this->assertEquals([1, 4], $squared);
 }
Exemple #4
0
 public function testIsAReducer()
 {
     $transducer = Fp\first(equal_three_makker());
     $this->assertInstanceOf('Fp\\Reducer\\Reducer', $transducer(Fp\appending()));
 }
 public function testCompositionWithMapFilterWithArityOfOne()
 {
     $transduced = Fp\transduce(Fp\compose(Fp\map(square_makker()), Fp\filter(is_even_makker())), Fp\appending(), [1, 2, 3, 4, 5, 6]);
     $this->assertEquals([4, 16, 36], $transduced);
 }
 public function testPartialFinalBatch()
 {
     $transducer = Fp\batching(3);
     $transformed = Fp\transduce($transducer, Fp\appending(), range(1, 5));
     $this->assertEquals([[1, 2, 3], [4, 5]], $transformed);
 }
 public function testMappingAndBatching()
 {
     $transformed = Fp\transduce(Fp\compose(Fp\mapping(square_makker()), Fp\batching(3)), Fp\appending(), range(1, 6));
     $this->assertEquals([[1, 4, 9], [16, 25, 36]], $transformed);
 }
 public function testTransducing()
 {
     $transduced = $this->collection->transduce(Fp\compose(Fp\map(square_makker()), Fp\filter(is_even_makker())), Fp\appending())->values();
     $this->assertEquals([4, 16], $transduced);
 }