Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add tests for advent day #13
  • Loading branch information
lizmat committed Dec 21, 2014
1 parent d91bcc4 commit e7857a4
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions integration/advent2014-day13.t
@@ -0,0 +1,76 @@
use Test;

plan 13;

my $said;
sub say(*@a) { $said = @a>>.gist.join } # don't care about the new line

{
my $a = 42;
say 'value = $a';
is $said, q/value = $a/;
say "value = $a";
is $said, q/value = 42/
}

{
my @a = ^10;
say 'value = @a';
is $said, q/value = @a/;
say "value = @a";
is $said, q/value = @a/;
}

{
my @a = ^10;
say "value = @a[]";
is $said, q/value = 0 1 2 3 4 5 6 7 8 9/;
}

{
my %h = a => 42, b => 666;
say "value = %h{}";
ok $said eq q/value = a 42 b 666/|q/value = b 666 a42/;
}

{
my @a;
my %h = a => 42, b => 666;
# a slice, but not a Zen slice:
say "value = %h{@a}";
is $said, q/value = /;
}

{
my %h = a => 42, b => 666;
say "value = %h{*}";
ok $said eq q/value = 42 666/|q/value = 666 42/;
}

{
sub a { 42 }
say "value = &a()";
is $said, q/value = 42/;
}

{
my %h = a => 42, b => 666;
say "value = %h.keys()";
ok $said eq q/value = a b/|q/value = b a/;
}

{
say "6 * 7 = { 6 * 7 }";
is $said, q/6 * 7 = 42/;
}

{
class A {
method Str { "foo" }
method gist { "bar" }
}
say "value = { A }";
is $said, q/value = foo/;
say "value = ", A;
is $said, q/value = bar/;
}

0 comments on commit e7857a4

Please sign in to comment.