tokuhirom's Blog

Test::Power 0.09 supports ArrayRef and HashRef

Hi, I released Test::Power 0.09 today. Test::Power is a library for testing. It taps the calucuration progress in the test code, and dump it if the test case was failed.

In this version, Test::Power shows the progress in the ->[] operator and ->{} operator.

Here is an example.

This is a test code using Test::Power.

use strict;
use warnings;
use utf8;
use Test::More;

use Test::Power;

my $a = +{ a => [ 3, { c => 4 } ] };
expect { $a->{a}->[1]->{c} eq 6 };

done_testing;

If you are using Test::More. It's hard to debug in this case. You need to add note or diag for the calucuration progress. But, Test::Power do it automatically. Here is an output.

✖  L9 : expect { $a->{a}->[1]->{c} eq 6 };
#   Failed test 'L9 : expect { $a->{a}->[1]->{c} eq 6 };'
#   at t/02_itself.t line 9.
# $a->{'a'}->[1]->{'c'}
#    => 4
# $a->{'a'}->[1]
#    => {'c' => 4}
# $a->{'a'}
#    => [3,{'c' => 4}]
# $a
#    => {'a' => [3,{'c' => 4}]}

Enjoy testing!