Skip to content

Instantly share code, notes, and snippets.

@autarch
Created June 6, 2023 19:22
Show Gist options
  • Save autarch/f58e33197717d578f59a0f2a6808344d to your computer and use it in GitHub Desktop.
Save autarch/f58e33197717d578f59a0f2a6808344d to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Test2::V0;
my $input = {
foo => 42,
bar => 84,
baz => [ 'array', 'of', 'strings' ],
};
is(
$input,
hash {
field foo => 42;
field bar => 84;
field baz => array {
item 0 => 'array';
item 1 => 'with';
item 2 => 'strings';
end();
};
end();
},
);
# ----
# Output from running this code:
#
# not ok 1
# Failed test at ./p.pl line 26.
# +----------+-----------------------+----+---------+--------+
# | PATH | GOT | OP | CHECK | LNs |
# +----------+-----------------------+----+---------+--------+
# | | HASH(0x563ef1c7cc50) | | <HASH> | 14, 25 |
# | {baz} | ARRAY(0x563ef1c7cc38) | | <ARRAY> | 23 |
# | {baz}[1] | of | eq | with | 20 |
# +----------+-----------------------+----+---------+--------+
# Tests were run but no plan was declared and done_testing() was not seen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment