Skip to content

Commit

Permalink
Fix table-whitespace test
Browse files Browse the repository at this point in the history
  • Loading branch information
leonelquinteros committed Mar 27, 2015
1 parent 9528986 commit cb55cb8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
58 changes: 48 additions & 10 deletions toml-test/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions toml-test/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function walk(&$a) {
);
}
}

if(empty($a))
{
$a = new stdClass();
}
}

walk($result);
Expand Down

0 comments on commit cb55cb8

Please sign in to comment.