Skip to content

Commit

Permalink
Improve toml-test response interface
Browse files Browse the repository at this point in the history
  • Loading branch information
leonelquinteros committed Mar 27, 2015
1 parent 3b57a3c commit bcad78f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
21 changes: 13 additions & 8 deletions toml-test/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require('../src/Toml.php');

$toml = '[naughty..naughty]';
$toml = 'thevoid = [[[[[]]]]]';

$result = Toml::parse($toml);

Expand All @@ -14,7 +14,7 @@
function walk(&$a) {
foreach($a as $i => $v)
{
if(is_array($v))
if(is_array($v) && array_values($v) !== $v)
{
walk($a[$i]);
}
Expand All @@ -38,17 +38,22 @@ function walk(&$a) {
$t = 'integer';
}

// Parse array type
if($t == 'array')
{
walk($v);
}
else
{
$v = "$v";
}

$a[$i] = array(
'type' => $t,
'value' => "$v",
'value' => $v,
);
}
}

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

walk($result);
Expand Down
19 changes: 12 additions & 7 deletions toml-test/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
function walk(&$a) {
foreach($a as $i => $v)
{
if(is_array($v))
if(is_array($v) && array_values($v) !== $v)
{
walk($a[$i]);
}
Expand All @@ -39,17 +39,22 @@ function walk(&$a) {
$t = 'integer';
}

// Parse array type
if($t == 'array')
{
walk($v);
}
else
{
$v = "$v";
}

$a[$i] = array(
'type' => $t,
'value' => "$v",
'value' => $v,
);
}
}

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

walk($result);
Expand Down

0 comments on commit bcad78f

Please sign in to comment.