Skip to content

Commit

Permalink
Spec $*ARGFILES in MAIN in 6.d to be fed by $*IN
Browse files Browse the repository at this point in the history
- Even when @*ARGS has stuff
- Rakudo impl: rakudo/rakudo@84d45f07fb
  • Loading branch information
zoffixznet committed Jul 29, 2018
1 parent 7d24325 commit 88499ac
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion MISC/misc-6.d.t
@@ -1,11 +1,13 @@
use v6.d.PREVIEW;
use lib $?FILE.IO.parent(2).add: 'packages';
use Test;
use Test::Util;

# This file is for various 6.d-specific tests that require the use of `v6.d.PREVIEW` pragma.
# They might be rearranged into other files in the future, but for now, keeping them in this
# file avoids creating a ton of `-6.d.t` files for the sake of single tests.

plan 1;
plan 2;

subtest ':sym<> colonpair on subroutine names is reserved' => {
plan 6;
Expand All @@ -21,4 +23,60 @@ subtest ':sym<> colonpair on subroutine names is reserved' => {
':sym«...»:foo<bar>';
}

subtest '$*ARGFILES is set to $*IN inside sub MAIN' => {
plan 5;
my @args = <THE FILES CONTENT>.map: {make-temp-file :$^content}

is_run
use v6.c;
sub MAIN(*@args) {
.say for lines;
}
,
"blah\nbleh\nbloh", :@args, {
:err(''), :0status, :out("THE\nFILES\nCONTENT\n"),
}, 'inside MAIN in 6.c language (with @*ARGS content)';

is_run
use v6.c;
sub MAIN(*@args) {
.say for lines;
}
,
"blah\nbleh\nbloh", {
:err(''), :0status, :out("blah\nbleh\nbloh\n"),
}, 'inside MAIN in 6.c language (without @*ARGS content)';

is_run
use v6.d.PREVIEW;
.say for lines;
sub MAIN(*@args) {
.say for lines;
}
,
"blah\nbleh\nbloh", :@args, {
:err(''), :0status, :out("THE\nFILES\nCONTENT\nblah\nbleh\nbloh\n"),
}, 'MAIN is an only sub';

is_run
use v6.d.PREVIEW;
.say for lines;
multi MAIN($, $, $) {
.say for lines;
}
multi MAIN(|) { die }
,
"blah\nbleh\nbloh", :@args, {
:err(''), :0status, :out("THE\nFILES\nCONTENT\nblah\nbleh\nbloh\n"),
}, 'MAIN is a multi sub';

is_run
use v6.d.PREVIEW;
.say for lines;
,
"blah\nbleh\nbloh", :@args, {
:err(''), :0status, :out("THE\nFILES\nCONTENT\n"),
}, 'no MAIN';
}

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit 88499ac

Please sign in to comment.