ThinkPHP/Library/Vendor/spyc/tests/RoundTripTest.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

require_once ("../Spyc.php");

function roundTrip($a) { return Spyc::YAMLLoad(Spyc::YAMLDump(array('x' => $a))); }


class RoundTripTest extends PHPUnit_Framework_TestCase {

    protected function setUp() {
    }

    public function testNull() {
      $this->assertEquals (array ('x' => null), roundTrip (null));
    }

    public function testY() {
      $this->assertEquals (array ('x' => 'y'), roundTrip ('y'));
    }
    
    public function testExclam() {
      $this->assertEquals (array ('x' => '!yeah'), roundTrip ('!yeah'));
    }

    public function test5() {
      $this->assertEquals (array ('x' => '5'), roundTrip ('5'));
    }

    public function testSpaces() {
      $this->assertEquals (array ('x' => 'x '), roundTrip ('x '));
    }
    
    public function testApostrophes() {
      $this->assertEquals (array ('x' => "'biz'"), roundTrip ("'biz'"));
    }

    public function testNewLines() {
      $this->assertEquals (array ('x' => "\n"), roundTrip ("\n"));
    }

    public function testHashes() {
      $this->assertEquals (array ('x' => array ("#color" => '#fff')), roundTrip (array ("#color" => '#fff')));
    }

    public function testPreserveString() {
      $result1 = roundTrip ('0');
      $result2 = roundTrip ('true');
      $this->assertTrue (is_string ($result1['x']));
      $this->assertTrue (is_string ($result2['x']));
    }

    public function testPreserveBool() {
      $result = roundTrip (true);
      $this->assertTrue (is_bool ($result['x']));
    }

    public function testPreserveInteger() {
      $result = roundTrip (0);
      $this->assertTrue (is_int ($result['x']));
    }
后面还有 18 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。