From cb55cb81e744be8df6e0708b44a54a38e6448d26 Mon Sep 17 00:00:00 2001 From: Leonel Quinteros Date: Fri, 27 Mar 2015 20:11:59 -0300 Subject: [PATCH] Fix table-whitespace test --- toml-test/debug.php | 58 +++++++++++++++++++++++++++++++++++++-------- toml-test/test.php | 5 ++++ 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/toml-test/debug.php b/toml-test/debug.php index e3e452b..da97630 100644 --- a/toml-test/debug.php +++ b/toml-test/debug.php @@ -2,19 +2,57 @@ require('../src/Toml.php'); -$toml = "oneline = '''This string has a ' quote character.''' -firstnl = ''' -This string has a ' quote character.''' -multiline = ''' -This string -has ' a quote character -and more than -one newline -in it.''' -"; +$toml = '["valid key"]'; $result = Toml::parse($toml); +print_r($result); +echo json_encode($result); +echo "\n"; + +// Format response values into test suite object +function walk(&$a) { + foreach($a as $i => $v) + { + if(is_array($v)) + { + walk($a[$i]); + } + else + { + // Get type + $t = gettype($v); + + // Parse type name + $t = str_replace(array('boolean', 'double'), array('bool', 'float'), $t); + + // Check date type + if(Toml::isISODate($v)) + { + $t = 'datetime'; + } + + // Fix double vs integer type + if($t == 'float' && $v == intval($v)) + { + $t = 'integer'; + } + + $a[$i] = array( + 'type' => $t, + 'value' => "$v", + ); + } + } + + if(empty($a)) + { + $a = new stdClass(); + } +} + +walk($result); + print_r($result); echo json_encode($result); diff --git a/toml-test/test.php b/toml-test/test.php index 88dcaea..f1b2863 100755 --- a/toml-test/test.php +++ b/toml-test/test.php @@ -45,6 +45,11 @@ function walk(&$a) { ); } } + + if(empty($a)) + { + $a = new stdClass(); + } } walk($result);