File: struct.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 (53 lines) | stat: -rw-r--r-- 1,185 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!perl

use strict;
use warnings;

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

use Test::More;
use Test::Differences;

## This mind-bender submitted by Yves Orton <demerphq@hotmail.com>
my ( $ar, $x, $y );
$ar->[0] = \$ar->[1];
$ar->[1] = \$ar->[0];
$x       = \$y;
$y       = \$x;

my @tests = (
    sub { eq_or_diff [ \"a", \"b" ], [ \"a", \"b" ] },
    sub { eq_or_diff $ar, [ $x, $y ] },
);

plan tests => 1 + scalar @tests;

$_->() for @tests;

# submitted by bessarabov, https://github.com/Ovid/Test-Differences/issues/2
my $stderr = capture_error { system (
    $^X, (map { "-I$_" } (@INC)),
    qw(-Mstrict -Mwarnings -MTest::More -MTest::Differences),
    '-e', '
        END { done_testing(); }
        eq_or_diff([[1]], [1])
    '
) };

is(
    $stderr,
'#   Failed test at -e line 3.
# +----+-------+----+----------+
# | Elt|Got    | Elt|Expected  |
# +----+-------+----+----------+
# |   0|[      |   0|[         |
# *   1|  [    *   1|  1       *
# *   2|    1  *    |          |
# *   3|  ]    *    |          |
# |   4|]      |   2|]         |
# +----+-------+----+----------+
# Looks like you failed 1 test of 1.
',
    "got expected error output"
);