Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add tests for RT #126049, remove faulty test that didn't catch it.
Add tests for RT #126049. Remove faulty test. String comparison on arrays with empty elements leads to tears... or bugs, at least.
  • Loading branch information
thundergnat committed Sep 23, 2015
1 parent d35c69e commit 4841832
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions S06-advanced/return.t
Expand Up @@ -15,7 +15,7 @@ See also t/blocks/return.t, which overlaps in scope.
# reference for the spec for 'return', but I couldn't find
# one either.

plan 81;
plan 87;

# These test the returning of values from a subroutine.
# We test each data-type with 4 different styles of return.
Expand Down Expand Up @@ -45,12 +45,36 @@ plan 81;
# ok(EVAL('sub ret { return }; 1'), "return without value parses ok");

sub bare_return { return };
sub implicit_bare_return { }; # RT #126049

ok(! bare_return(), "A bare return is a false value");
ok(! implicit_bare_return(), "An implicit bare return is a false value");

my @l = <some values>;
@l = bare_return();
is( @l, [], "A bare return is an empty list in array/list context");

#?rakudo todo 'RT #126049'
{
@l = bare_return();
is-deeply( @l, [], "A bare return is an empty list in array/list context");

@l = <some values>;
@l = implicit_bare_return();
is-deeply( @l, [], "An implicit bare return is an empty list in array/list context");
}

sub empty_list { return () };
sub implicit_empty_list { () };

ok(! empty_list(), "A bare return is a false value");
ok(! implicit_empty_list(), "An implicit bare return is a false value");

@l = <some values>;
@l = empty_list();
is-deeply( @l, [], "A returned empty list is an empty list in array/list context");

@l = <some values>;
@l = implicit_empty_list();
is-deeply( @l, [], "An implicit returned empty list is an empty list in array/list context");

my $s = "hello";
$s = bare_return();
Expand Down

0 comments on commit 4841832

Please sign in to comment.