Permalink
Browse files

Fixing issue 26: floats.

  • Loading branch information...
1 parent 022f558 commit 803da0aed79f7551d1449f09a0ea377e9066769f @mustangostang mustangostang committed Mar 20, 2011
Showing with 6 additions and 1 deletion.
  1. +1 −1 spyc.php
  2. +1 −0 spyc.yaml
  3. +4 −0 tests/ParseTest.php
View
2 spyc.php
@@ -598,7 +598,7 @@ private function _toType($value) {
if (is_numeric($value)) {
if ($value === '0') return 0;
- if (trim ($value, 0) === $value)
+ if (rtrim ($value, 0) === $value)
$value = (float)$value;
return $value;
}
View
1 spyc.yaml
@@ -23,6 +23,7 @@ NotTrue: 'y'
NotBoolTrue: 'true'
NotInt: '5'
Float: 5.34
+SmallFloat: 0.7
NewLine: \n
# A sequence
View
4 tests/ParseTest.php
@@ -68,6 +68,10 @@ public function testMappingsFloat() {
$this->assertSame (5.34, $this->yaml['Float']);
}
+ public function testMappingsSmallFloat() {
+ $this->assertSame (0.7, $this->yaml['SmallFloat']);
+ }
+
public function testNewline() {
$this->assertSame ("\n", $this->yaml['NewLine']);
}

0 comments on commit 803da0a

Please sign in to comment.