コード例 #1
0
ファイル: WireTest.php プロジェクト: hamdrew/adventofcode
 /**
  * @test
  * @covers ::getSignal
  * @covers \Hamdrew\AdventOfCode\Day7\CircuitComponent::getSignal
  * @covers \Hamdrew\AdventOfCode\Day7\CircuitComponent::setSignal
  */
 public function returnsCachedSignal()
 {
     $signal = 123;
     $source = \Mockery::mock('\\Hamdrew\\AdventOfCode\\Day7\\CircuitComponent')->shouldReceive('getSignal')->andReturn($signal)->once()->getMock();
     $wire = new Wire('test', $source);
     $wire->getSignal();
     $this->assertSame($signal, $wire->getSignal());
 }
コード例 #2
0
ファイル: GateNot.php プロジェクト: hamdrew/adventofcode
 /**
  * @inheritDoc
  */
 public function getSignal()
 {
     $signal = parent::getSignal();
     if (is_null($signal)) {
         $input = $this->source->getSignal();
         if (!is_null($input)) {
             $signal = SixteenBitMask::mask(~$input);
             $this->setSignal($signal);
         }
     }
     return $signal;
 }
コード例 #3
0
ファイル: WireTest.php プロジェクト: ashleyhindle/advent2015
 public function testCanSetAndGetSignal()
 {
     $wire = new Wire('a');
     $wire->setSignal(123);
     $this->assertEquals(123, $wire->getSignal());
 }