scratch – Blame information for rev 66
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
66 | office | 1 | <?php |
2 | |||
3 | require_once ("../Spyc.php"); |
||
4 | |||
5 | function roundTrip($a) { return Spyc::YAMLLoad(Spyc::YAMLDump(array('x' => $a))); } |
||
6 | |||
7 | |||
8 | class RoundTripTest extends PHPUnit_Framework_TestCase { |
||
9 | |||
10 | protected function setUp() { |
||
11 | } |
||
12 | |||
13 | public function testNull() { |
||
14 | $this->assertEquals (array ('x' => null), roundTrip (null)); |
||
15 | } |
||
16 | |||
17 | public function testY() { |
||
18 | $this->assertEquals (array ('x' => 'y'), roundTrip ('y')); |
||
19 | } |
||
20 | |||
21 | public function testExclam() { |
||
22 | $this->assertEquals (array ('x' => '!yeah'), roundTrip ('!yeah')); |
||
23 | } |
||
24 | |||
25 | public function test5() { |
||
26 | $this->assertEquals (array ('x' => '5'), roundTrip ('5')); |
||
27 | } |
||
28 | |||
29 | public function testSpaces() { |
||
30 | $this->assertEquals (array ('x' => 'x '), roundTrip ('x ')); |
||
31 | } |
||
32 | |||
33 | public function testApostrophes() { |
||
34 | $this->assertEquals (array ('x' => "'biz'"), roundTrip ("'biz'")); |
||
35 | } |
||
36 | |||
37 | public function testNewLines() { |
||
38 | $this->assertEquals (array ('x' => "\n"), roundTrip ("\n")); |
||
39 | } |
||
40 | |||
41 | public function testHashes() { |
||
42 | $this->assertEquals (array ('x' => array ("#color" => '#fff')), roundTrip (array ("#color" => '#fff'))); |
||
43 | } |
||
44 | |||
45 | public function testPreserveString() { |
||
46 | $result1 = roundTrip ('0'); |
||
47 | $result2 = roundTrip ('true'); |
||
48 | $this->assertTrue (is_string ($result1['x'])); |
||
49 | $this->assertTrue (is_string ($result2['x'])); |
||
50 | } |
||
51 | |||
52 | public function testPreserveBool() { |
||
53 | $result = roundTrip (true); |
||
54 | $this->assertTrue (is_bool ($result['x'])); |
||
55 | } |
||
56 | |||
57 | public function testPreserveInteger() { |
||
58 | $result = roundTrip (0); |
||
59 | $this->assertTrue (is_int ($result['x'])); |
||
60 | } |
||
61 | |||
62 | public function testWordWrap() { |
||
63 | $this->assertEquals (array ('x' => "aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), roundTrip ("aaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")); |
||
64 | } |
||
65 | |||
66 | public function testABCD() { |
||
67 | $this->assertEquals (array ('a', 'b', 'c', 'd'), Spyc::YAMLLoad(Spyc::YAMLDump(array('a', 'b', 'c', 'd')))); |
||
68 | } |
||
69 | |||
70 | public function testABCD2() { |
||
71 | $a = array('a', 'b', 'c', 'd'); // Create a simple list |
||
72 | $b = Spyc::YAMLDump($a); // Dump the list as YAML |
||
73 | $c = Spyc::YAMLLoad($b); // Load the dumped YAML |
||
74 | $d = Spyc::YAMLDump($c); // Re-dump the data |
||
75 | $this->assertSame($b, $d); |
||
76 | } |
||
77 | |||
78 | } |