File: undef.t

package info (click to toggle)
libtest-differences-perl 0.72-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 192 kB
  • sloc: perl: 498; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 1,323 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!perl

use strict;
use warnings;
use Test::More qw(no_plan);
use Test::Differences;

TODO: {
    local $TODO = "Should fail";
    eq_or_diff( undef, "", "undef eq ''" );
    eq_or_diff( undef, [], "undef eq []" );
    eq_or_diff( undef, 0, "undef eq 0" );
    eq_or_diff( "",    0, "'' eq 0" );
    eq_or_diff( [ 1, undef ], [ 1, "" ], "undef eq '' in array" );
    eq_or_diff( [ 1,   [ 2, undef ] ], [ 1,   [ 2, "" ] ],        "undef eq '' in deep array" );
    eq_or_diff( [ [1], [ 2, undef ] ], [ [1], [ 2, "" ] ],        "undef eq '' in AoAoS" );
    eq_or_diff( [ [1], [ 2, undef ] ], [ [1], [ 2, "<undef>" ] ], "undef eq <undef> in AoAoS" );
    eq_or_diff( [ 1, undef ], [ 1, ], "arrays of different length are equal" );
    eq_or_diff( { aa => undef }, { aa => '' },        "undef eq '' in hash" );
    eq_or_diff( { aa => undef }, { aa => '<undef>' }, "undef eq <undef> in hash" );
}

my $builder = Test::More->builder;
# The Test::Builder 1.5 way to do it
if ( $builder->can('history') ) {
    is $builder->history->pass_count - $builder->history->todo_count,
       $builder->history->literal_pass_count,
       "All TODO tests failed";
}
# The Test::Builder 0.x way to do it
else {
    eq_or_diff [ map { $_->{actual_ok} } $builder->details ], [ map { 0 } $builder->details ],
      "All TODO tests failed";
}