Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created May 29, 2017 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/92317fbdfec783ea8a6187bb38bdc4b7 to your computer and use it in GitHub Desktop.
Save zoffixznet/92317fbdfec783ea8a6187bb38bdc4b7 to your computer and use it in GitHub Desktop.
use Test;
plan 1;
subtest '.say method' => {
plan 5*5;
my $file = make-temp-file;
sub test-output (Capture \in, Str:D \out, Str :$nl-out) {
$file.open(:w).close; # clear file
with $nl-out {
with $file.open(:w, :$nl-out) { .say: |in; .close }
is-deeply $file.slurp, out ~ $nl-out,
in.perl ~ ' :nl-out(' ~ $nl-out.perl ~ ')';
}
else {
with $file.open(:w) { .say: |in; .close }
is-deeply $file.slurp, out, in.perl;
}
}
for Str, '', 'foos', '♥', "\n" -> $nl-out {
test-output :$nl-out, \( ), "";
test-output :$nl-out, \('foo' ), "foo";
test-output :$nl-out, \(<a b c>), "(a b c)";
test-output :$nl-out, \(1, 2, 3), "(a b c)";
test-output :$nl-out, \(
(Mu, my class Foo42 {}, my class { method gist { 'I ♥ Perl 6' } },
1, 2, [3, 5, ('foos',).Seq], %(<meow bar>), :42bar.Pair)
}, '((Mu) (Foo) I ♥ Perl 6 1 2 [3 5 (foos)] {meow => bar} bar => 42)';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment