Skip to content
Browse files

Rename packages/Test.pm to packages/PackageTest.pm.

  • Loading branch information...
1 parent 4423b3e commit 46de3cf6fd7821488d76b890ac142eca05b0d7dc @colomon colomon committed
Showing with 49 additions and 8 deletions.
  1. +1 −1 S06-currying/mixed.t
  2. +7 −7 S10-packages/scope.t
  3. +41 −0 packages/PackageTest.pm
View
2 S06-currying/mixed.t
@@ -46,7 +46,7 @@ ok(!(try { &foo.assuming(f => 3) }), "can't curry nonexistent named param");
# L<S06/Currying/The result of a use statement>
#?niecza todo
eval_lives_ok q'
- (use t::packages::Test) // {}).assuming(arg1 => "foo");
+ (use t::packages::PackageTest) // {}).assuming(arg1 => "foo");
die "not working" unless
dummy_sub_with_params(arg2 => "bar") } eq "[foo] [bar]",
', "(use ...).assuming works";
View
14 S10-packages/scope.t
@@ -25,7 +25,7 @@ plan 23;
}
}
-use t::spec::packages::Test;
+use t::spec::packages::PackageTest;
# test that all the functions are in the right place
@@ -47,8 +47,8 @@ is(Test3::pkg, ::Test3::, 'eval\'ed package $?PACKAGE');
cmp_ok(Test3::pkg, &infix:<===>, ::Test3::, 'eval\'ed package type object');
# this one came from t/packages/Test.pm
-is(t::spec::packages::Test::ns, "t::packages::Test", "loaded package");
-cmp_ok(t::spec::packages::Test::pkg, &infix:<===>, ::t::packages::Test::, 'loaded package $?PACKAGE object');
+is(t::spec::packages::PackageTest::ns, "t::packages::PackageTest", "loaded package");
+cmp_ok(t::spec::packages::PackageTest::pkg, &infix:<===>, ::t::packages::PackageTest::, 'loaded package $?PACKAGE object');
my $x;
lives_ok { $x = test_export() }, "export was imported successfully";
is($x, "party island", "exported OK");
@@ -61,7 +61,7 @@ my $pkg;
#?pugs todo 'feature'
dies_ok { $pkg = Our::Package::pkg },
"Can't see `our' packages out of scope";
-lives_ok { $pkg = t::spec::packages::Test::get_our_pkg() },
+lives_ok { $pkg = t::spec::packages::PackageTest::get_our_pkg() },
"Package in scope can see `our' package declarations";
is($pkg, Our::Package, 'correct $?PACKAGE');
#?pugs todo 'feature'
@@ -69,12 +69,12 @@ ok(!($pkg === ::Our::Package),
'not the same as global type object');
# oh no, how do we get to that object, then?
-# perhaps %t::spec::packages::Test::<Our::Package> ?
+# perhaps %t::spec::packages::PackageTest::<Our::Package> ?
#?pugs todo 'feature'
-dies_ok { $pkg = t::spec::packages::Test::cant_see_pkg() },
+dies_ok { $pkg = t::spec::packages::PackageTest::cant_see_pkg() },
"can't see package declared out of scope";
-lives_ok { $pkg = t::spec::packages::Test::my_pkg() },
+lives_ok { $pkg = t::spec::packages::PackageTest::my_pkg() },
"can see package declared in same scope";
is($pkg, ::My::Package::, 'correct $?PACKAGE');
ok($pkg !=== ::*My::Package::, 'not the same as global type object');
View
41 packages/PackageTest.pm
@@ -0,0 +1,41 @@
+# The semicolon form of "package" would be illegal in the
+# middle of a Perl 6 file.
+# At the top, it would mean the rest of the file was Perl 5 code.
+# So we use "package" with a block:
+
+package t::spec::packages::PackageTest {
+
+sub ns { "t::spec::packages::PackageTest" }
+
+sub pkg { $?PACKAGE }
+
+sub test_export is export { "party island" }
+
+sub get_our_pkg {
+ Our::Package::pkg();
+}
+
+our package Our::Package {
+
+ sub pkg { $?PACKAGE }
+
+}
+
+sub cant_see_pkg {
+ return My::Package::pkg();
+}
+
+{
+ sub my_pkg {
+ return My::Package::pkg();
+ }
+
+ my package My::Package {
+ sub pkg { $?PACKAGE }
+ }
+
+}
+
+sub dummy_sub_with_params($arg1, $arg2) is export { "[$arg1] [$arg2]" }
+
+}

0 comments on commit 46de3cf

Please sign in to comment.
Something went wrong with that request. Please try again.