Skip to content

Commit

Permalink
Merge pull request #44 from tmtysk/master
Browse files Browse the repository at this point in the history
Anchor and Alias test.
  • Loading branch information
mustangostang committed May 14, 2016
2 parents 22b3be9 + 02246af commit dfd9aad
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"require": {
"php": ">=5.3.1"
},
"require-dev": {
"phpunit/phpunit": "3.*"
},
"autoload": {
"files": [ "Spyc.php" ]
},
Expand Down
59 changes: 32 additions & 27 deletions tests/IndentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,64 @@ class IndentTest extends PHPUnit_Framework_TestCase {
protected $Y;

protected function setUp() {
$this->Y = Spyc::YAMLLoad("indent_1.yaml");
$this->Y = Spyc::YAMLLoad("indent_1.yaml");
}

public function testIndent_1() {
$this->assertEquals (array ('child_1' => 2, 'child_2' => 0, 'child_3' => 1), $this->Y['root']);
$this->assertEquals (array ('child_1' => 2, 'child_2' => 0, 'child_3' => 1), $this->Y['root']);
}

public function testIndent_2() {
$this->assertEquals (array ('child_1' => 1, 'child_2' => 2), $this->Y['root2']);
$this->assertEquals (array ('child_1' => 1, 'child_2' => 2), $this->Y['root2']);
}

public function testIndent_3() {
$this->assertEquals (array (array ('resolutions' => array (1024 => 768, 1920 => 1200), 'producer' => 'Nec')), $this->Y['display']);
$this->assertEquals (array (array ('resolutions' => array (1024 => 768, 1920 => 1200), 'producer' => 'Nec')), $this->Y['display']);
}

public function testIndent_4() {
$this->assertEquals (array (
array ('resolutions' => array (1024 => 768)),
array ('resolutions' => array (1920 => 1200)),
$this->assertEquals (array (
array ('resolutions' => array (1024 => 768)),
array ('resolutions' => array (1920 => 1200)),
), $this->Y['displays']);
}

public function testIndent_5() {
$this->assertEquals (array (array (
'row' => 0,
'col' => 0,
'headsets_affected' => array (
array (
'ports' => array (0),
'side' => 'left',
$this->assertEquals (array (array (
'row' => 0,
'col' => 0,
'headsets_affected' => array (
array (
'ports' => array (0),
'side' => 'left',
)
),
'switch_function' => array (
'ics_ptt' => true
)
),
'switch_function' => array (
'ics_ptt' => true
)
)), $this->Y['nested_hashes_and_seqs']);
)), $this->Y['nested_hashes_and_seqs']);
}

public function testIndent_6() {
$this->assertEquals (array (
'h' => array (
array ('a' => 'b', 'a1' => 'b1'),
array ('c' => 'd')
)
), $this->Y['easier_nest']);
$this->assertEquals (array (
'h' => array (
array ('a' => 'b', 'a1' => 'b1'),
array ('c' => 'd')
)
), $this->Y['easier_nest']);
}

public function testIndent_space() {
$this->assertEquals ("By four\n spaces", $this->Y['one_space']);
$this->assertEquals ("By four\n spaces", $this->Y['one_space']);
}

public function testListAndComment() {
$this->assertEquals (array ('one', 'two', 'three'), $this->Y['list_and_comment']);
$this->assertEquals (array ('one', 'two', 'three'), $this->Y['list_and_comment']);
}

public function testAnchorAndAlias() {
$this->assertEquals (array ('database' => 'rails_dev', 'adapter' => 'mysql', 'host' => 'localhost'), $this->Y['development']);
$this->assertEquals (array (1 => 'abc'), $this->Y['zzz']);
}

}
7 changes: 6 additions & 1 deletion tests/indent_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ kai:
kai_list_of_items:
- -item
- '-item'
-item
-item

&foo bar:
1: "abc"

zzz: *foo

0 comments on commit dfd9aad

Please sign in to comment.