コード例 #1
0
ファイル: DivTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertEquals($f->div(2), 0.5);
     $this->assertEquals($f->div(3, 2), 1.5);
     $this->assertEquals($f->div(10, 2, 5), 1);
 }
コード例 #2
0
ファイル: PartialTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $getName = $f->partial($f->get, 'name');
     $this->assertEquals('Alice', $getName(['name' => 'Alice']));
     $this->assertEquals(['Bob', null], $f->map($getName, [['name' => 'Bob'], null]));
 }
コード例 #3
0
ファイル: OddTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertTrue($f->odd(1));
     $this->assertFalse($f->odd(2));
     $this->assertSame([true, false, true], $f->map($f->odd, [1, 2, 3]));
 }
コード例 #4
0
ファイル: MulTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertEquals(1, $f->mul());
     $this->assertEquals(6, $f->mul(2, 3));
     $this->assertEquals(-6, $f->mul(2, 3, -1));
 }
コード例 #5
0
ファイル: MapTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertSame([4, 7], $f->map($f->add, [1, 2], [3, 5]));
     $this->assertSame([2, 3], $f->map($f->inc, [1, 2]));
 }
コード例 #6
0
ファイル: map.php プロジェクト: zweifisch/f
<?php

$setup = function () {
    return [100000, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \f\F::getInstance()];
};
run('map', $setup, function ($args) {
    list($n, $array, $f) = $args;
    for ($i = 0; $i < $n; $i++) {
        $f->map($f->inc, $array);
    }
});
run('array_map', $setup, function ($args) {
    list($n, $array, $f) = $args;
    for ($i = 0; $i < $n; $i++) {
        array_map($f->inc, $array);
    }
});
コード例 #7
0
ファイル: FirstTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertSame(false, $f->first([]));
     $this->assertSame(1, $f->first([1, 2]));
 }
コード例 #8
0
ファイル: LastTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertSame(false, $f->last([]));
     $this->assertEquals(2, $f->last([1, 2]));
 }
コード例 #9
0
ファイル: SomeTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertEquals($f->some($f->even, [1, 2, 3]), 2);
     $this->assertNull($f->some($f->even, [1, 5, 3]));
 }
コード例 #10
0
ファイル: KeysTest.php プロジェクト: zweifisch/f
 function test()
 {
     $f = F::getInstance();
     $this->assertEquals(['key'], $f->keys(['key' => 'value']));
 }