Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bring CURL::F tests up-to-date
  • Loading branch information
lizmat committed Aug 1, 2014
1 parent c0e28b3 commit 26d1dda
Showing 1 changed file with 39 additions and 61 deletions.
100 changes: 39 additions & 61 deletions S22-package-format/local.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 60;
plan 40;

# initializations
my $cwd := $*CWD;
Expand All @@ -17,15 +17,14 @@ my $srcdir := "$base/local-file-src";
my $srcsrc := "$srcdir/$src";
my $cmpext := $*VM.precomp-ext;
my $cmpdir := "$base/local-file-cmp";
my $cmpsrc := "$cmpdir/$src";
my $cmpcmp := "$cmpdir/$module.$cmpext";
my $cmpsrc := "$cmpdir/$src"; # should not exist
my $cmpcmp := "$cmpdir/$src.$cmpext";

# creating dirs / files needed
my $initialized = True; # try to cleanup from here on out
ok mkdir($srcdir), "Could we create '$srcdir'";
ok $srcsrc.IO.spurt($nanoonanoo), "Could we create '$srcsrc'";
ok mkdir($cmpdir), "Could we create $cmpdir";
ok $cmpsrc.IO.spurt($nanoonanoo), "Could we create '$cmpsrc'";

#?rakudo.jvm skip 'cannot do signals in JVM'
#?rakudo.parrot skip 'cannot do signals in parrot'
Expand All @@ -49,77 +48,56 @@ ok $curlf2 !=== $curlf, 'are they different';
isa_ok $curlf.path, IO::Path;
is $curlf.path, IO::Path.new("$cwd/$srcdir"), "is '$srcdir' looking at the right dir";

# checking with/without precomp
my $compunit;
for False, True -> $no-precomp {
my $what = $no-precomp ?? ' with :no-precomp' !! '';

# all candidates
my $candidates = $curlf.candidates(:$no-precomp);
ok $candidates ~~ Positional, "did we get a Positional$what";
is $candidates.elems, 1, "did we get 1 candidate$what";
$compunit = $candidates[0];
isa_ok $compunit, CompUnit;
# all candidates
my $candidates = $curlf.candidates('NanooNanoo');
is $candidates.elems, 1, "did we get 1 candidate";
my $compunit-src = $candidates[0];
isa_ok $compunit-src, CompUnit;

# a specific existing candidate
$candidates = $curlf.candidates('NanooNanoo',:$no-precomp);
ok $candidates ~~ Positional, "did we get a Positional$what";
is $candidates.elems, 1, "did we get 1 candidate$what";
my $second = $candidates[0];
isa_ok $second, CompUnit;
ok $compunit === $second, 'did we get the same CompUnit object';
# a specific existing candidate
$candidates = $curlf.candidates('NanooNanoo');
is $candidates.elems, 1, "did we get 1 candidate";
my $second = $candidates[0];
isa_ok $second, CompUnit;
ok $compunit-src === $second, 'did we get the same CompUnit object';

# a specific non-existing candidate
$candidates = $curlf.candidates('Shazbat',:$no-precomp);
ok $candidates ~~ Positional, "did we get a Positional$what";
is $candidates.elems, 0, "did we get 0 candidates$what";
}
# a specific non-existing candidate
$candidates = $curlf.candidates('Shazbat');
is $candidates.elems, 0, "did we get 0 candidates";

# basic CompUnit sanity
is $compunit.from, 'Perl6', "is the language 'Perl6'";
is $compunit.name, $module, "is the name '$module'";
is $compunit.extension, $srcext, "is the extension '$srcext'";
is $compunit.path, "$cwd/$srcsrc", "is the path '$srcsrc'";
is $compunit.loaded, False, "is the module loaded";
is $compunit.precomped, False, "is the module pre-compiled";

# create precomp file after creating CURLF object, so we sure it reads on-demand
is $compunit-src.from, 'Perl6', "is the language 'Perl6'";
is $compunit-src.name, $module, "is the name '$module'";
is $compunit-src.extension, $srcext, "is the extension '$srcext'";
is $compunit-src.path, "$cwd/$srcsrc", "is the path '$srcsrc'";
is $compunit-src.is-loaded, False, "is the module is-loaded";
is $compunit-src.has-source, True, "do we have the source?";
is $compunit-src.has-precomp, False, "is the module pre-compiled";

# create precomp file after creating CURLF, so we're sure it reads on-demand
$curlf = CompUnitRepo::Local::File.new($cmpdir);
isa_ok $curlf, CompUnitRepo::Local::File;
ok $compunit.precomp($cmpcmp), 'did we pre-compile ok?';

# does it find the precomped version
my $candidates = $curlf.candidates;
ok $candidates ~~ Positional, "did we get a Positional";
is $candidates.elems, 1, "did we get 1 candidate";
$compunit = $candidates[0];
isa_ok $compunit, CompUnit;
is $compunit.from, 'Perl6', "is the language 'Perl6'";
is $compunit.name, $module, "is the name '$module'";
is $compunit.extension, $cmpext, "is the extension '$cmpext'";
is $compunit.path, "$cwd/$cmpcmp", "is the path '$cmpcmp'";
is $compunit.loaded, False, "is the module loaded";
is $compunit.precomped, True, "is the module pre-compiled";
ok $compunit-src.precomp($cmpcmp), 'did we pre-compile ok?';
is $compunit-src.has-precomp, False, "is the module pre-compiled";

# force it to skip pre-comped version
$candidates = $curlf.candidates(:no-precomp);
ok $candidates ~~ Positional, "did we get a Positional";
# does it find the precomped version (without a source being present)
$candidates = $curlf.candidates('NanooNanoo');
is $candidates.elems, 1, "did we get 1 candidate";
$compunit = $candidates[0];
isa_ok $compunit, CompUnit;
is $compunit.from, 'Perl6', "is the language 'Perl6'";
is $compunit.name, $module, "is the name '$module'";
is $compunit.extension, $srcext, "is the extension '$srcext'";
is $compunit.path, "$cwd/$cmpsrc", "is the path '$cmpsrc'";
is $compunit.loaded, False, "is the module loaded";
is $compunit.precomped, False, "is the module pre-compiled";
my $compunit-cmp = $candidates[0];
isa_ok $compunit-cmp, CompUnit;
is $compunit-cmp.from, 'Perl6', "is the language 'Perl6'";
is $compunit-cmp.name, $module, "is the name '$module'";
is $compunit-cmp.extension, $srcext, "is the extension '$srcext'";
is $compunit-cmp.path, "$cwd/$cmpsrc", "is the path '$cmpsrc'";
is $compunit-cmp.is-loaded, False, "is the module is-loaded";
is $compunit-cmp.has-source, False, "don't we have the source?";
is $compunit-cmp.has-precomp, True, "is the module pre-compiled";

# always cleanup
END {
if $initialized {
try unlink $srcsrc;
try rmdir $srcdir;
try unlink $cmpsrc;
try unlink $cmpcmp;
try rmdir $cmpdir;
}
Expand Down

0 comments on commit 26d1dda

Please sign in to comment.