Skip to content

Commit

Permalink
Fixing issue 34: exclamations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mustangostang committed Mar 22, 2011
1 parent 3853856 commit d9bdb08
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spyc.php
Expand Up @@ -301,7 +301,7 @@ private function _dumpNode($key, $value, $indent, $previous_key = -1, $first_key
// do some folding here, for blocks
if (is_string ($value) && ((strpos($value,"\n") !== false || strpos($value,": ") !== false || strpos($value,"- ") !== false ||
strpos($value,"*") !== false || strpos($value,"#") !== false || strpos($value,"<") !== false || strpos($value,">") !== false || strpos ($value, ' ') !== false ||
strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false ||
strpos($value,"[") !== false || strpos($value,"]") !== false || strpos($value,"{") !== false || strpos($value,"}") !== false) || strpos($value,"&") !== false || strpos($value, "!") === 0 ||
substr ($value, -1, 1) == ':')
) {
$value = $this->_doLiteralBlock($value,$indent);
Expand Down
13 changes: 13 additions & 0 deletions tests/DumpTest.php
Expand Up @@ -53,6 +53,19 @@ public function testDumpAmpersands() {
$awaiting = "---\nsome: '&foo'\n";
$this->assertEquals ($awaiting, $dump);
}

public function testDumpExclamations() {
$dump = Spyc::YAMLDump(array ('some' => '!foo'));
$awaiting = "---\nsome: '!foo'\n";
$this->assertEquals ($awaiting, $dump);
}

public function testDumpExclamations2() {
$dump = Spyc::YAMLDump(array ('some' => 'foo!'));
$awaiting = "---\nsome: foo!\n";
$this->assertEquals ($awaiting, $dump);
}


public function testDumpNumericHashes() {
$dump = Spyc::YAMLDump(array ("titel"=> array("0" => "", 1 => "Dr.", 5 => "Prof.", 6 => "Prof. Dr.")));
Expand Down
4 changes: 4 additions & 0 deletions tests/RoundTripTest.php
Expand Up @@ -17,6 +17,10 @@ public function testNull() {
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'));
Expand Down

0 comments on commit d9bdb08

Please sign in to comment.