From: Maik Fischer Date: Tue, 22 Nov 2011 23:10:47 +0000 (+0100) Subject: testcases: t/116-*: reinvent ignore() from Test::Deep X-Git-Tag: 4.2~226^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6bf13b413e8ee1c19ce5d1b2e60d7f8fe61a0f30;p=i3%2Fi3 testcases: t/116-*: reinvent ignore() from Test::Deep --- diff --git a/testcases/t/116-nestedcons.t b/testcases/t/116-nestedcons.t index ada6e0dc..f6d4848d 100644 --- a/testcases/t/116-nestedcons.t +++ b/testcases/t/116-nestedcons.t @@ -29,28 +29,44 @@ my $i3 = i3(get_socket_path()); my $tree = $i3->get_tree->recv; +# a unique value +my $ignore = \""; + my $expected = { fullscreen_mode => 0, - nodes => ignore(), + nodes => $ignore, window => undef, name => 'root', - orientation => ignore(), + orientation => $ignore, type => 0, - id => ignore(), - rect => ignore(), - window_rect => ignore(), - geometry => ignore(), - swallows => ignore(), + id => $ignore, + rect => $ignore, + window_rect => $ignore, + geometry => $ignore, + swallows => $ignore, percent => undef, layout => 'default', - focus => ignore(), + focus => $ignore, focused => JSON::XS::false, urgent => JSON::XS::false, border => 'normal', - 'floating_nodes' => ignore(), + 'floating_nodes' => $ignore, }; -is_deeply($tree, $expected, 'root node OK'); +# a shallow copy is sufficient, since we only ignore values at the root +my $tree_copy = { %$tree }; + +for (keys %$expected) { + my $val = $expected->{$_}; + + # delete unwanted keys, so we can use is_deeply() + if (ref($val) eq 'SCALAR' and $val == $ignore) { + delete $tree_copy->{$_}; + delete $expected->{$_}; + } +} + +is_deeply($tree_copy, $expected, 'root node OK'); my @nodes = @{$tree->{nodes}};