コード例 #1
0
ファイル: Multiple.php プロジェクト: Grummfy/Central
 public function case_default_value()
 {
     $this->given($foobar = new LUT\Map(['f', 'o', 'o', 'b', 'a', 'r']), $baz = new LUT\Map(['b', 'a', 'z']), $multiple = new LUT\Multiple(LUT\Multiple::MIT_NEED_ANY | LUT\Multiple::MIT_KEYS_ASSOC), $multiple->attachIterator($foobar, 'one', '!'), $multiple->attachIterator($baz, 'two', '?'))->when($result = iterator_to_array($multiple, false))->then->array($result)->isEqualTo([['one' => 'f', 'two' => 'b'], ['one' => 'o', 'two' => 'a'], ['one' => 'o', 'two' => 'z'], ['one' => 'b', 'two' => '?'], ['one' => 'a', 'two' => '?'], ['one' => 'r', 'two' => '?']]);
 }
コード例 #2
0
ファイル: Demultiplexer.php プロジェクト: Grummfy/Central
 public function case_associative_keys()
 {
     $this->given($counter = new LUT\Counter(0, 10, 1), $multiple = new LUT\Multiple(LUT\Multiple::MIT_NEED_ANY | LUT\Multiple::MIT_KEYS_ASSOC), $multiple->attachIterator($counter, 'one'), $multiple->attachIterator(clone $counter, 'two'), $demultiplexer = new LUT\Demultiplexer($multiple, function ($current) {
         return $current['one'] * $current['two'];
     }))->when($result = iterator_to_array($demultiplexer, false))->then->array($result)->isEqualTo([0, 1, 4, 9, 16, 25, 36, 49, 64, 81]);
 }