<commit_before>use v6;
use Test;
plan 15;

# Is there a better reference for the spec for how return return works? 
# There is "return function" but that's a more advanced feature.
#L<S04/"Control Exceptions">

=begin pod

Basic tests for "return"

=end pod

sub bar { return }
ok(!defined(bar()), '... bare return statement returned undef');

sub bar2 { return() }
ok(!defined(bar2()), '... bare return statement w/ parens returned undef');

sub baz { return 10 if 1; }
is(baz(), 10, '... return worked with a statement modifier');

#?rakudo skip 'parsefail on "return if 1"'
sub foobar { return if 1; };
ok(!defined(foobar()), '... bare return worked with a statement modifier');

sub foobar2 { return() if 1; }
ok(!defined(foobar2()), '... bare return worked with a statement modifier');

my $should_ret_empty_list1 = sub { return; 1 };
is @($should_ret_empty_list1(),).elems, 0, "our sub returned an empty list (1)";

sub return_1 { return 1; }
is(return_1(), 1, '... return_1() returned 1 correctly');

#?rakudo skip 'no applicable method'<commit_msg>[t/spec] fudged return.t, all tests should pass again<commit_after>use v6;
use Test;
plan 15;

# Is there a better reference for the spec for how return return works? 
# There is "return function" but that's a more advanced feature.
#L<S04/"Control Exceptions">

=begin pod

Basic tests for "return"

=end pod

sub bar { return }
#?rakudo todo 'bare return is undef'
ok(!defined(bar()), '... bare return statement returned undef');

sub bar2 { return() }
#?rakudo todo 'bare return is undef'
ok(!defined(bar2()), '... bare return statement w/ parens returned undef');

sub baz { return 10 if 1; }
is(baz(), 10, '... return worked with a statement modifier');

#?rakudo skip 'parsefail on "return if 1"'
sub foobar { return if 1; };
ok(!defined(foobar()), '... bare return worked with a statement modifier');

sub foobar2 { return() if 1; }
#?rakudo todo 'bare return is undef'
ok(!defined(foobar2()), '... bare return worked with a statement modifier');

my $should_ret_empty_list1 = sub { return; 1 };
is @($should_ret_empty_list1(),).elems, 0, "our sub returned an empty list (1)";

sub return_1 { return 1; }
is(return_1(), 1, '... return_1() returned 1 correctly');

#?rakudo skip 'no applicable method'
{'fraction_non_alphanumeric': 0.14714980114891738, 'fraction_numerical': 0.024745912505523642, 'mean_word_length': 4.468599033816425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4501970', 'n_tokens_mistral': 780, 'n_tokens_neox': 709, 'n_words': 296}