Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 51fc070843
Fetching contributors…

Cannot retrieve contributors at this time

file 81 lines (59 sloc) 1.496 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
use v6;
use Test;
plan 13;

# L<S04/"The goto statement">

=begin description

Tests for the goto() builtin

We have "phases" to make sure the gotos didn't run wild.

=end description


our $phase;

sub test1_ok { return 1 }
sub test1 {
&test1_ok.nextwith();
return 0;
}
ok(test1(), "&sub.nextwith does");
is(++$phase, 1, "phase completed");

# the same, but with subs declared after the call.

sub test2 {
&test2_ok.nextwith();
return 0;
}
sub test2_ok { return 1 }
ok(test2(), "&sub.nextwith does (forward reference)");
is(++$phase, 2, "phase completed");

ok(test3(), "&sub.nextwith does (real forward reference)");
sub test3 {
&test3_ok.nextwith();
return 0;
}
sub test3_ok { 1 }
is(++$phase, 3, "phase completed");

is(moose(), $?LINE, "regular call to moose() is consistent");
is(foo(), $?LINE, "goto eliminates call stack frames");

sub foo {
&moose.nextwith();
}

sub moose {
$?CALLER::LINE;
}

is(++$phase, 4, "phase completed");

# Simple test case to get support for goto LABEL in pugs
# Source for the syntax: S06 "The leave function"
# > last COUNT;

our $test5 = 1;
eval q{ goto SKIP5; };
$test5 = 0;
SKIP5:
#?pugs todo 'feature'
is($test5, 1, "goto label");

is(++$phase, 5, "phase completed");

# this one tests "goto EXPR" syntax. pugs treats "last EXPR" as "last;" in r14915.

our $test6 = 1;
eval q{ goto 'SK' ~ 'IP6'; };
$test6 = 0;
SKIP6:
#?pugs todo 'feature'
is($test6, 1, "goto expr");

is(++$phase, 6, "phase completed");

# vim: ft=perl6
Something went wrong with that request. Please try again.