예제 #1
0
파일: Number.php 프로젝트: trashtoy/peach2
 /**
  * int = zero / ( digit1-9 *DIGIT )
  * 
  * @param Context $context
  */
 private function handleIntegralPart(Context $context)
 {
     // check zero
     if ($context->current() === "0") {
         if (preg_match("/^0[0-9]\$/", $context->getSequence(2))) {
             $context->throwException("Integral part must not start with 0");
         }
         $this->result .= "0";
         $context->next();
         return;
     }
     // check ( digit1-9 *DIGIT )
     $this->handleFirstDigit($context);
     $this->handleDigitSequence($context);
 }
예제 #2
0
 /**
  * @covers Peach\DF\JsonCodec\Context::getSequence
  * @covers Peach\DF\JsonCodec\Context::encodeIndex
  */
 public function testGetSequence()
 {
     $context = new Context("This is a pen.", new ArrayMap());
     // read "this "
     $context->skip(5);
     $this->assertSame("is a", $context->getSequence(4));
     // read "is a "
     $context->skip(5);
     $this->assertSame("pen.", $context->getSequence(10));
 }