Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fudge tests for JVM: Failures not handled as expected
Had to duplicate code in order to fudge for JVM.
Please revert if there is a better way to do the fudging.
  • Loading branch information
usev6 committed Nov 21, 2015
1 parent 9817537 commit 9e99d8c
Showing 1 changed file with 71 additions and 10 deletions.
81 changes: 71 additions & 10 deletions S04-statements/with.t
Expand Up @@ -104,8 +104,7 @@ for
(),(),
Str,Slip,
Nil,Slip,
Int,Slip,
oops,Slip
Int,Slip

-> $with, $expected {

Expand All @@ -115,14 +114,23 @@ for
ok $foo ~~ $expected, "\$_: with on { $with // $with.^name }";
}

## had to factor this out of the above for loop, in order to fudge for JVM
## TODO re-integrate test in above for loop once it passes on JVM
#?rakudo.jvm todo '$foo is not "$()", but Failure'
for oops,Slip -> $with, $expected {
my $foo is default(Nil) = do with $with {
$_;
}
ok $foo ~~ $expected, "\$_ with on { $with // $with.^name }";
}

for
1,1,
0,0,
(),(),
Str,Slip,
Nil,Slip,
Int,Slip,
oops,Slip
Int,Slip

-> $with, $expected {

Expand All @@ -132,14 +140,23 @@ for
ok $foo ~~ $expected, "\$pos: with on { $with // $with.^name }";
}

## had to factor this out of the above for loop, in order to fudge for JVM
## TODO re-integrate test in above for loop once it passes on JVM
#?rakudo.jvm todo '$foo is not "$()", but Failure'
for oops,Slip -> $with, $expected {
my $foo is default(Nil) = do with $with -> $pos {
$pos;
}
ok $foo ~~ $expected, "\$pos: with on { $with // $with.^name }";
}

for
1,Slip,
0,Slip,
(),Slip,
Str,Str,
Nil,Nil,
Int,Int,
oops,Failure
Int,Int

-> $without, $expected {

Expand All @@ -150,14 +167,24 @@ for
ok $foo ~~ $expected, "\$_: without on { $without // $without.^name }";
}

## had to factor this out of the above for loop, in order to fudge for JVM
## TODO re-integrate test in above for loop once it passes on JVM
#?rakudo.jvm todo '$foo is not a Failure, but "$()"'
for oops,Failure -> $without, $expected {
my $foo is default(Nil) = do
without $without {
$_;
}
ok $foo ~~ $expected, "\$_: without on { $without // $without.^name }";
}

for
1,Slip,
0,Slip,
(),Slip,
Str,Str,
Nil,Nil,
Int,Int,
oops,Failure
Int,Int

-> $without, $expected {

Expand All @@ -168,6 +195,17 @@ for
ok $foo ~~ $expected, "\$pos: without on { $without // $without.^name }";
}

## had to factor this out of the above for loop, in order to fudge for JVM
## TODO re-integrate test in above for loop once it passes on JVM
#?rakudo.jvm todo '$foo is not a Failure, but "$()"'
for oops,Failure -> $without, $expected {
my $foo is default(Nil) = do
without $without -> $pos {
$pos;
}
ok $foo ~~ $expected, "\$pos: without on { $without // $without.^name }";
}

throws-like 'without 1 {...} else {...}', X::Comp, "else is not valid on without";
throws-like 'without 1 {...} orwith 2 {...}', X::Comp, "orwith is not valid on without";
throws-like 'without 1 {...} elsif 2 {...}', X::Comp, "elsif is not valid on without";
Expand Down Expand Up @@ -208,8 +246,7 @@ for
0, 1,1,
0,Str,Str,
0,Nil,Nil,
0,Int,Int,
0,oops,Failure
0,Int,Int

-> $if, $orwith, $expected {

Expand All @@ -227,4 +264,28 @@ for
ok $foo ~~ $expected, "\$_: if on { $if // $if.^name }, orwith on { $orwith // $orwith.^name }";
}

## had to factor this out of the above for loop, in order to fudge for JVM
## TODO re-integrate test in above for loop once it passes on JVM
#?rakudo.jvm skip 'Failure from oops is thrown'
{
for
0,oops,Failure

-> $if, $orwith, $expected {

$_ = 43;
my $foo is default(Nil) = 42;
if $if {
$foo = $if;
}
orwith $orwith {
$foo = $_;
}
else {
$foo = $_;
}
ok $foo ~~ $expected, "\$_: if on { $if // $if.^name }, orwith on { $orwith // $orwith.^name }";
}
}

# vim: ft=perl6

0 comments on commit 9e99d8c

Please sign in to comment.