Skip to content

Commit

Permalink
[t/spec] More tests for import; also comment on one that I can't see …
Browse files Browse the repository at this point in the history
…any justification for in the spec. If nobody else can either, suggest we kill it.

git-svn-id: http://svn.pugscode.org/pugs@26001 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
jnthn committed Mar 25, 2009
1 parent 95d20df commit 6ebdecc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 3 additions & 0 deletions S10-packages/import.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ plan 1;
#?pugs emit exit;
#?pugs emit }

# I don't understand what this test is actually trying to test for, and don't
# see any reference in S10.

is(eval("use t::spec::packages::Import 'foo'; 123;"), 123, "import doesn't get called if it doesn't exist");
30 changes: 30 additions & 0 deletions S11-modules/import-tag.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use v6;
use Test;

plan 12;

# L<S11/"Compile-time Importation"/>

{
use t::spec::packages::S11-modules::Foo :others;

dies_ok { foo() }, 'foo() not imported - not tagged :others';

ok( &bar, 'Foo::bar is defined (explicitly :DEFAULT and :others)' );
is( bar(), 'Foo::bar', 'Foo::bar is the sub we expect' );

ok( &baz, 'Foo::baz is defined (:MANDATORY)' );
is( baz(), 'Foo::baz', 'Foo::baz is the sub we expect' );

dies_ok { bop() }, 'bop() not imported';

ok( &qux, 'Foo::qux is defined (explicitly :others)' );
is( qux(), 'Foo::qux', 'Foo::qux is the sub we expect' );

dies_ok { waz() }, 'waz() not imported';

ok( &gaz, 'Foo::gaz multi is defined (implicitly :others)' );
is( gaz(), 'Foo::gaz1', 'Foo::gaz is the sub we expect' );
is( gaz(1), 'Foo::gaz2', 'Foo::gaz($x) is the sub we expect' );

}
13 changes: 11 additions & 2 deletions S11-modules/import.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 9;
plan 15;

# L<S11/"Compile-time Importation"/>

Expand All @@ -12,15 +12,24 @@ plan 9;
ok( &foo, 'Foo::foo is defined (explicitly :DEFAULT)' );
is( foo(), 'Foo::foo', 'Foo::foo is the sub we expect' );

ok( &bar, 'Foo::bar is defined (explicitly :DEFAULT and :others)' );
is( bar(), 'Foo::bar', 'Foo::bar is the sub we expect' );

ok( &baz, 'Foo::baz is defined (:MANDATORY)' );
is( baz(), 'Foo::baz', 'Foo::baz is the sub we expect' );

ok( &bop, 'Foo::bop is defined (implicitly :DEFAULT)' );
is( bop(), 'Foo::bop', 'Foo::bop is the sub we expect' );

multi waz($x) { 'Foo::wazhere' }
ok( &waz, 'Foo::waz multi is defined (implicitly :DEFAULT)' );
is( waz(), 'Foo::waz', 'Foo::waz is the sub we expect' );
is( waz(1), 'Foo::wazhere', 'Foo::waz imported does not wipe out our other waz multis' );

dies_ok { qux() }, 'qux() not imported';
dies_ok { gaz() }, 'gaz() not imported';
}

#?rakudo skip 'Importation is currently not lexical'
#?rakudo todo 'Importation is currently not lexical'
ok( ! &foo,
'Foo::foo is undefined in outer scope' );

0 comments on commit 6ebdecc

Please sign in to comment.