Exemple #1
0
 /**
  * This method tests a set of choices.
  */
 public function testChoice()
 {
     //$this->markTestIncomplete();
     $p0 = IInt32\Type::make(0);
     $e0 = 0;
     $p1 = IInt32\Type::make(1);
     $e1 = 1;
     Control\Type::choice($p0)->when($p0, function (IInt32\Type $x) use($e0) {
         $this->assertSame($e0, $x->unbox());
     })->otherwise(function (IInt32\Type $x) use($e1) {
         $this->assertSame($e1, $x->unbox());
     })->end();
     Control\Type::choice($p0)->when($p1, function (IInt32\Type $x) use($e1) {
         $this->assertSame($e1, $x->unbox());
     })->when($p0, function (IInt32\Type $x) use($e0) {
         $this->assertSame($e0, $x->unbox());
     })->end();
     Control\Type::choice($p0)->when($p1, function (IInt32\Type $x) use($e1) {
         $this->assertSame($e1, $x->unbox());
     })->otherwise(function (IInt32\Type $x) use($e0) {
         $this->assertSame($e0, $x->unbox());
     })->end();
 }
Exemple #2
0
 /**
  * This method returns a choice block.
  *
  * @access public
  * @static
  * @param Core\Equality\Type $x                             the object to be evaluated
  * @return Control\Choice\Type                              the choice monad
  */
 public static function choice(Core\Equality\Type $x) : Control\Choice\Type
 {
     return Control\Type::choice($x);
 }