Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (37 sloc) 1.414 kb
be85ac8c » Auzon
2008-06-26 [gsoc_spectest] t/packages -> t/spec/S10-packages/*.t and t/spec/pack…
1 use v6;
2
2ff19446 » szabgab
2009-04-27 some more smartlinks
3 # L<S11/Runtime Importation>
4
be85ac8c » Auzon
2008-06-26 [gsoc_spectest] t/packages -> t/spec/S10-packages/*.t and t/spec/pack…
5 use Test;
6
7 plan 18;
8
9 my @tests = (
10 "t::spec::packages::RequireAndUse1", { $^a == 42 },
11 "t::spec::packages::RequireAndUse2", { $^a != 23 },
12 "t::spec::packages::RequireAndUse3", { $^a != 23 },
13 );
14
15 for @tests -> $mod, $expected_ret {
16
17 my @strings = (
18 "use $mod",
19 "require '{ $mod.split("::").join("/") ~ ".pm" }'",
20 );
21
22 for @strings -> $str {
23 diag $str;
06ae9097 » FROGGS
2014-01-01 eval => EVAL in S10 to S12
24 my $retval = try { EVAL $str };
be85ac8c » Auzon
2008-06-26 [gsoc_spectest] t/packages -> t/spec/S10-packages/*.t and t/spec/pack…
25
26 ok defined($retval) && $retval != -1 && $expected_ret($retval),
27 "require or use's return value was correct ({$str})";
28 # XXX: Keys of %*INC not yet fully decided (module name? module object?),
29 # IIRC.
30 ok defined(%*INC{$mod}) && %*INC{$mod} != -1 && $expected_ret(%*INC{$mod}),
31 "\%*INC was updated correctly ({$str})";
32 }
33 }
34
35 our $loaded = 0;
36 our $imported = 0;
37
06ae9097 » FROGGS
2014-01-01 eval => EVAL in S10 to S12
38 EVAL q{use t::spec::packages::LoadCounter; 1} orelse die "error loading package: $!";
be85ac8c » Auzon
2008-06-26 [gsoc_spectest] t/packages -> t/spec/S10-packages/*.t and t/spec/pack…
39 is($loaded, 1, "use loads a module");
40 is($imported, 1, "use calls &import");
41
06ae9097 » FROGGS
2014-01-01 eval => EVAL in S10 to S12
42 EVAL q{use t::spec::packages::LoadCounter; 1} orelse die "error loading package: $!";
be85ac8c » Auzon
2008-06-26 [gsoc_spectest] t/packages -> t/spec/S10-packages/*.t and t/spec/pack…
43 is($loaded, 1, "a second use doesn't load the module again");
44 is($imported, 2, "a second use does call &import again");
45
06ae9097 » FROGGS
2014-01-01 eval => EVAL in S10 to S12
46 EVAL q{no t::spec::packages::LoadCounter; 1} orelse die "error no'ing package: $!";
be85ac8c » Auzon
2008-06-26 [gsoc_spectest] t/packages -> t/spec/S10-packages/*.t and t/spec/pack…
47 is($loaded, 1, "&no doesn't load the module again");
48 is($imported, 1, "&no calls &unimport");
49
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
50
51 # vim: ft=perl6
Something went wrong with that request. Please try again.