File: unknown-values.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 (55 lines) | stat: -rw-r--r-- 3,339 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!perl

use strict;
use warnings;

use lib 't/lib';
use Test::Differences::TestUtils::Capture;

use Test::More;

eval { require Unknown::Values } || plan skip_all => 'Unknown::Values is needed for these tests';

my $stderr = capture_error { system(
    $^X, (map { "-I$_" } (@INC)), 't/script/unknown-values'
) };

my @expected_failures = (
'#   Failed test at t/script/unknown-values line 13.
# +----+------------------------------------------------------------+-----------------------------------------------------------------+
# | Elt|Got                                                         |Expected                                                         |
# +----+------------------------------------------------------------+-----------------------------------------------------------------+
# *   0|got something containing an Unknown::Values::unknown value  |expected something containing an Unknown::Values::unknown value  *
# +----+------------------------------------------------------------+-----------------------------------------------------------------+
', '#   Failed test at t/script/unknown-values line 14.
# +----+------------------------------------------------------------+----------+
# | Elt|Got                                                         |Expected  |
# +----+------------------------------------------------------------+----------+
# *   0|got something containing an Unknown::Values::unknown value  |undef\n   *
# +----+------------------------------------------------------------+----------+
', '#   Failed test at t/script/unknown-values line 16.
# +----+------------------------------------------------------------+-----------------------------------------------------------------+
# | Elt|Got                                                         |Expected                                                         |
# +----+------------------------------------------------------------+-----------------------------------------------------------------+
# *   0|got something containing an Unknown::Values::unknown value  |expected something containing an Unknown::Values::unknown value  *
# +----+------------------------------------------------------------+-----------------------------------------------------------------+
', '#   Failed test at t/script/unknown-values line 17.
# +----+------------------------------------------------------------+----+----------+
# | Elt|Got                                                         | Elt|Expected  |
# +----+------------------------------------------------------------+----+----------+
# *   0|got something containing an Unknown::Values::unknown value  *   0|[\n       *
# |    |                                                            *   1|  1,      *
# |    |                                                            *   2|  undef   *
# |    |                                                            *   3|]         *
# +----+------------------------------------------------------------+----+----------+
# Looks like you failed 4 tests of 4.
'
);
# We might get extra whitespace under 'make test' compared to running 'perl -Ilib t/...'
if($stderr =~ /\n\n/) {
    is($stderr, join("\n", @expected_failures), 'got expected errors');
} else {
    is($stderr, join("", @expected_failures), 'got expected errors');
}

done_testing;