From 6bf13b413e8ee1c19ce5d1b2e60d7f8fe61a0f30 Mon Sep 17 00:00:00 2001 From: Maik Fischer Date: Wed, 23 Nov 2011 00:10:47 +0100 Subject: [PATCH] testcases: t/116-*: reinvent ignore() from Test::Deep --- testcases/t/116-nestedcons.t | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) 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}}; -- 2.39.5