Permalink
Browse files

Fixing issue 29.

  • Loading branch information...
1 parent ad425e9 commit 3853856635ee520d64817333299a11a076bf380c @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
@@ -579,7 +579,7 @@ private function _toType($value) {
return null;
}
- if (intval($first_character) > 0 && preg_match ('/^[1-9]+[0-9]*$/', $value)) {
+ if ( is_numeric($value) && preg_match ('/^(-|)[1-9]+[0-9]*$/', $value) ){
$intvalue = (int)$value;
if ($intvalue != PHP_INT_MAX)
$value = $intvalue;
View
1 spyc.yaml
@@ -23,6 +23,7 @@ NotTrue: 'y'
NotBoolTrue: 'true'
NotInt: '5'
Float: 5.34
+Negative: -90
SmallFloat: 0.7
NewLine: \n
View
4 tests/ParseTest.php
@@ -67,6 +67,10 @@ public function testMappingsNotNull() {
public function testMappingsFloat() {
$this->assertSame (5.34, $this->yaml['Float']);
}
+
+ public function testMappingsNegative() {
+ $this->assertSame (-90, $this->yaml['Negative']);
+ }
public function testMappingsSmallFloat() {
$this->assertSame (0.7, $this->yaml['SmallFloat']);

0 comments on commit 3853856

Please sign in to comment.