public function testExceptionThrowingExperiment() { $candidate = function () { }; $exceptionThrowingCandidate = function () { throw new \Exception(); }; $experiment = new Experiment(); $experiment->run($candidate); $experiment->test($exceptionThrowingCandidate); $experiment(); $this->assertNotNull($experiment->getResults()->current()->hasThrownException()); }
public function testNotScalarExperiment() { $control = function ($i) { $o = new \stdClass(); $o->i = $i + $i + $i; return $o; }; $candidate = function ($i) { $o = new \stdClass(); $o->i = $i * 3; return $o; }; $experiment = new Experiment(function ($control, $candidate) { return $control->i === $candidate->i; }); $experiment->run($control); $experiment->test($candidate); $this->assertSame($experiment(1)->i, 3); $this->assertTrue($experiment->getResults()->current()->hasMatched()); }