1<?php 2 3namespace spec\Prophecy\Argument\Token; 4 5use PhpSpec\ObjectBehavior; 6use Prophecy\Argument; 7 8class ApproximateValueTokenSpec extends ObjectBehavior 9{ 10 function let() 11 { 12 $this->beConstructedWith(10.12345678, 4); 13 } 14 15 function it_is_initializable() 16 { 17 $this->shouldHaveType('Prophecy\Argument\Token\ApproximateValueToken'); 18 } 19 20 function it_implements_TokenInterface() 21 { 22 $this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface'); 23 } 24 25 function it_is_not_last() 26 { 27 $this->shouldNotBeLast(); 28 } 29 30 function it_scores_10_if_rounded_argument_matches_rounded_value() 31 { 32 $this->scoreArgument(10.12345)->shouldReturn(10); 33 } 34 35 function it_does_not_score_if_rounded_argument_does_not_match_rounded_value() 36 { 37 $this->scoreArgument(10.1234)->shouldReturn(false); 38 } 39 40 function it_uses_a_default_precision_of_zero() 41 { 42 $this->beConstructedWith(10.7); 43 $this->scoreArgument(11.4)->shouldReturn(10); 44 } 45 46 function it_does_not_score_if_rounded_argument_is_not_numeric() 47 { 48 $this->scoreArgument('hello')->shouldReturn(false); 49 } 50 51 function it_has_simple_string_representation() 52 { 53 $this->__toString()->shouldBe('≅10.1235'); 54 } 55} 56