Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[t/spec] avoid autohreading through ok()

git-svn-id: http://svn.pugscode.org/pugs@24963 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit e97f6d58e28c7bb0235ec341d44f1a5d094328b5 1 parent 5a496fa
moritz authored
View
67 S03-junctions/misc.t
@@ -10,6 +10,9 @@ Misc. Junction tests
=end pod
+# avoid auto-threading on ok()
+sub jok(Object $condition, $msg?) { ok ?($condition), $msg };
+
# L<S03/Junctive operators>
# L<S09/Junctions>
{
@@ -20,53 +23,53 @@ Misc. Junction tests
my $c = '';
# make sure they all match to an empty string
- ok('' eq ($a & $b & $c), 'junction of ($a & $b & $c) matches an empty string');
- ok('' eq all($a, $b, $c), 'junction of all($a, $b, $c) matches an empty string');
+ jok('' eq ($a & $b & $c), 'junction of ($a & $b & $c) matches an empty string');
+ jok('' eq all($a, $b, $c), 'junction of all($a, $b, $c) matches an empty string');
# give $a a value
$a = 'a';
# make sure that at least one of them matches 'a'
- ok('a' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one "a"');
- ok('a' eq any($b, $c, $a), 'junction of any($b, $c, $a) matches at least one "a"');
+ jok('a' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one "a"');
+ jok('a' eq any($b, $c, $a), 'junction of any($b, $c, $a) matches at least one "a"');
- ok('' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one empty string');
- ok('' eq any($b, $c, $a), 'junction of any($b, $c, $a) matches at least one empty string');
+ jok('' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one empty string');
+ jok('' eq any($b, $c, $a), 'junction of any($b, $c, $a) matches at least one empty string');
# make sure that ~only~ one of them matches 'a'
- ok('a' eq ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
- ok('a' eq one($b, $c, $a), 'junction of one($b, $c, $a) matches at ~only~ one "a"');
+ jok('a' eq ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
+ jok('a' eq one($b, $c, $a), 'junction of one($b, $c, $a) matches at ~only~ one "a"');
# give $b a value
$b = 'a';
# now this will fail
- ok('a' ne ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at more than one "a"');
+ jok('a' ne ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at more than one "a"');
# change $b and give $c a value
$b = 'b';
$c = 'c';
- ok('a' eq ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
- ok('b' eq ($a ^ $b ^ $c), 'junction of ($a ^ $b ^ $c) matches at ~only~ one "b"');
- ok('c' eq ($c ^ $a ^ $b), 'junction of ($c ^ $a ^ $b) matches at ~only~ one "c"');
+ jok('a' eq ($b ^ $c ^ $a), 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
+ jok('b' eq ($a ^ $b ^ $c), 'junction of ($a ^ $b ^ $c) matches at ~only~ one "b"');
+ jok('c' eq ($c ^ $a ^ $b), 'junction of ($c ^ $a ^ $b) matches at ~only~ one "c"');
- ok('a' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one "a"');
- ok('b' eq ($a | $b | $c), 'junction of ($a | $b | $c) matches at least one "b"');
- ok('c' eq ($c | $a | $b), 'junction of ($c | $a | $b) matches at least one "c"');
+ jok('a' eq ($b | $c | $a), 'junction of ($b | $c | $a) matches at least one "a"');
+ jok('b' eq ($a | $b | $c), 'junction of ($a | $b | $c) matches at least one "b"');
+ jok('c' eq ($c | $a | $b), 'junction of ($c | $a | $b) matches at least one "c"');
ok(not(('a' eq ($b | $c | $a)) === Bool::False), 'junctional comparison doesn not mistakenly return both true and false');
ok(not(('b' eq ($a | $b | $c)) === Bool::False), 'junctional comparison doesn not mistakenly return both true and false');
ok(not(('c' eq ($c | $a | $b)) === Bool::False), 'junctional comparison doesn not mistakenly return both true and false');
# test junction to junction
- ok(('a' | 'b' | 'c') eq ($a & $b & $c), 'junction ("a" | "b" | "c") matches junction ($a & $b & $c)');
- ok(('a' & 'b' & 'c') eq ($a | $b | $c), 'junction ("a" & "b" & "c") matches junction ($a | $b | $c)');
+ jok(('a' | 'b' | 'c') eq ($a & $b & $c), 'junction ("a" | "b" | "c") matches junction ($a & $b & $c)');
+ jok(('a' & 'b' & 'c') eq ($a | $b | $c), 'junction ("a" & "b" & "c") matches junction ($a | $b | $c)');
# mix around variables and literals
- ok(($a & 'b' & 'c') eq ('a' | $b | $c), 'junction ($a & "b" & "c") matches junction ("a" | $b | $c)');
- ok(($a & 'b' & $c) eq ('a' | $b | 'c'), 'junction ($a & "b" & $c) matches junction ("a" | $b | "c")');
+ jok(($a & 'b' & 'c') eq ('a' | $b | $c), 'junction ($a & "b" & "c") matches junction ("a" | $b | $c)');
+ jok(($a & 'b' & $c) eq ('a' | $b | 'c'), 'junction ($a & "b" & $c) matches junction ("a" | $b | "c")');
}
@@ -78,22 +81,22 @@ Misc. Junction tests
my $c = '';
my $all_of_them = $a & $b & $c;
- ok('' eq $all_of_them, 'junction variable of ($a & $b & $c) matches and empty string');
+ jok('' eq $all_of_them, 'junction variable of ($a & $b & $c) matches and empty string');
$a = 'a';
my $any_of_them = $b | $c | $a;
- ok('a' eq $any_of_them, 'junction variable of ($b | $c | $a) matches at least one "a"');
- ok('' eq $any_of_them, 'junction variable of ($b | $c | $a) matches at least one empty string');
+ jok('a' eq $any_of_them, 'junction variable of ($b | $c | $a) matches at least one "a"');
+ jok('' eq $any_of_them, 'junction variable of ($b | $c | $a) matches at least one empty string');
my $one_of_them = $b ^ $c ^ $a;
- ok('a' eq $one_of_them, 'junction variable of ($b ^ $c ^ $a) matches at ~only~ one "a"');
+ jok('a' eq $one_of_them, 'junction variable of ($b ^ $c ^ $a) matches at ~only~ one "a"');
$b = 'a';
{
my $one_of_them = $b ^ $c ^ $a;
- ok('a' ne $one_of_them, 'junction variable of ($b ^ $c ^ $a) matches at more than one "a"');
+ jok('a' ne $one_of_them, 'junction variable of ($b ^ $c ^ $a) matches at more than one "a"');
}
$b = 'b';
@@ -101,16 +104,16 @@ Misc. Junction tests
{
my $one_of_them = $b ^ $c ^ $a;
- ok('a' eq $one_of_them, 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
- ok('b' eq $one_of_them, 'junction of ($a ^ $b ^ $c) matches at ~only~ one "b"');
- ok('c' eq $one_of_them, 'junction of ($c ^ $a ^ $b) matches at ~only~ one "c"');
+ jok('a' eq $one_of_them, 'junction of ($b ^ $c ^ $a) matches at ~only~ one "a"');
+ jok('b' eq $one_of_them, 'junction of ($a ^ $b ^ $c) matches at ~only~ one "b"');
+ jok('c' eq $one_of_them, 'junction of ($c ^ $a ^ $b) matches at ~only~ one "c"');
}
{
my $any_of_them = $b | $c | $a;
- ok('a' eq $any_of_them, 'junction of ($b | $c | $a) matches at least one "a"');
- ok('b' eq $any_of_them, 'junction of ($a | $b | $c) matches at least one "b"');
- ok('c' eq $any_of_them, 'junction of ($c | $a | $b) matches at least one "c"');
+ jok('a' eq $any_of_them, 'junction of ($b | $c | $a) matches at least one "a"');
+ jok('b' eq $any_of_them, 'junction of ($a | $b | $c) matches at least one "b"');
+ jok('c' eq $any_of_them, 'junction of ($c | $a | $b) matches at least one "c"');
}
}
@@ -310,10 +313,10 @@ ok(!(?(1&0) != ?(1&&0)), 'boolean context');
{
my @array = <1 2 3 4 5 6 7 8>;
- ok( all(@array) == one(@array), "all(@x) == one(@x) tests uniqueness(+ve)" );
+ jok( all(@array) == one(@array), "all(@x) == one(@x) tests uniqueness(+ve)" );
push @array, 6;
- ok( !( all(@array) == one(@array) ), "all(@x) == one(@x) tests uniqueness(-ve)" );
+ jok( !( all(@array) == one(@array) ), "all(@x) == one(@x) tests uniqueness(-ve)" );
}
View
64 S03-operators/misc.t
@@ -55,15 +55,15 @@ is("text " ~ "stitching", "text stitching", 'concatenation with ~ operator');
is(2 || 3, 2, "|| returns first true value");
ok(!(defined( 0 || undef)), "|| returns last false value of list?");
-is(2 ?| 3, True, "boolean or (?|) returns True or False");
-is(0 ?| undef, False, "boolean or (?|) returns True or False");
+is(?(2 ?| 3), True, "boolean or (?|) returns True or False");
+is(?(0 ?| undef), False, "boolean or (?|) returns True or False");
# L<S03/Junctive operators/They thread through operations>
-ok((all((4|5|6) + 3) == one(7|8|9)), "all elements in junction are incremented");
-ok((any(1..6) == one(1|2|3|4|5|6)), "any elements will match via junction");
+ok(?((all((4|5|6) + 3) == one(7|8|9))), "all elements in junction are incremented");
+ok(?((any(1..6) == one(1|2|3|4|5|6))), "any elements will match via junction");
-ok( 7 > any(4..12), "any test against scalar" );
+ok( ?(7 > any(4..12)), "any test against scalar" );
my @oldval = (5, 8, 12);
@@ -73,12 +73,12 @@ my @newval2 = (15, 7, 20); # some less some greater
my @newval3 = (3, 1, 4); # all less
my @newval4 = (1,2,40);
-ok( any(@newval4) > any(@oldval), "any test array against any array" );
-ok( any(@newval4) > all(@oldval), "any test array against all array" );
-ok( all(@newval2) > any(@oldval), "all test array against any array" );
-ok( all(@newval1) > all(@oldval), "all test array against all array" );
+ok( ?(any(@newval4) > any(@oldval)), "any test array against any array" );
+ok( ?(any(@newval4) > all(@oldval)), "any test array against all array" );
+ok( ?(all(@newval2) > any(@oldval)), "all test array against any array" );
+ok( ?(all(@newval1) > all(@oldval)), "all test array against all array" );
-ok(42 > 12 & 20 & 32, "test the all infix operator");
+ok(?(42 > 12 & 20 & 32), "test the all infix operator");
# L<S03/Hyper operators/hyper operator distributes over them as lists>
@@ -90,35 +90,35 @@ ok(42 > 12 & 20 & 32, "test the all infix operator");
{ # L<S03/Changes to Perl 5 operators/ "?| is a logical OR">
# work with pure Bool's
- ok( False?|False == False, '?| works with Bools');
- ok( False?|True == True, '?| works with Bools');
- ok( True ?|False == True, '?| works with Bools');
- ok( True ?|True == True, '?| works with Bools');
+ ok( ?(False?|False == False), '?| works with Bools');
+ ok( ?(False?|True == True), '?| works with Bools');
+ ok( ?(True ?|False == True), '?| works with Bools');
+ ok( ?(True ?|True == True), '?| works with Bools');
- ok( '' ?| 0 == False, '?| works');
- ok( 1 ?| 0 == True, '?| works');
+ ok( ?('' ?| 0 == False), '?| works');
+ ok( ?(1 ?| 0 == True), '?| works');
}
{ # L<S03/Changes to Perl 5 operators/ "?& is a logical AND">
# work with pure Bool's
- ok( False?&False == False, '?& works with Bools');
- ok( False?&True == False, '?& works with Bools');
- ok( True ?&False == False, '?& works with Bools');
- ok( True ?&True == True, '?& works with Bools');
-
- ok( '' ?& 'yes' == False, '?& works');
- ok( 1 ?& False == False, '?& works');
- ok( 42 ?& 42 == True, '?& works');
+ ok( ?(False?&False == False), '?& works with Bools');
+ ok( ?(False?&True == False), '?& works with Bools');
+ ok( ?(True ?&False == False), '?& works with Bools');
+ ok( ?(True ?&True == True), '?& works with Bools');
+
+ ok( ?('' ?& 'yes' == False), '?& works');
+ ok( ?(1 ?& False == False), '?& works');
+ ok( ?(42 ?& 42 == True), '?& works');
}
{ ## L<S03/Changes to Perl 5 operators/ "?^ is a logical XOR">
# work with pure Bool's
- ok( False?^False == False, '?^ works with Bools');
- ok( False?^True == True, '?^ works with Bools');
- ok( True ?^False == True, '?^ works with Bools');
- ok( True ?^True == False, '?^ works with Bools');
-
- ok( '' ?^'' == False, '?^ works');
- ok( undef?^ 1 == True, '?^ works');
- ok( -1 ?^undef == True, '?^ works');
+ ok( ?(False?^False == False), '?^ works with Bools');
+ ok( ?(False?^True == True), '?^ works with Bools');
+ ok( ?(True ?^False == True), '?^ works with Bools');
+ ok( ?(True ?^True == False), '?^ works with Bools');
+
+ ok( ?('' ?^'' == False), '?^ works');
+ ok( ?(undef?^ 1 == True), '?^ works');
+ ok( ?(-1 ?^undef == True), '?^ works');
}
View
6 integration/99problems-21-to-30.t
@@ -46,11 +46,11 @@ plan 15;
# of course the following is wrong, but it also confuses test output!
#ok all(@rand) ~~ none(@letters), '... and they should be in the letters';
- ok all(@rand) ~~ any(@letters), '... and they should be in the letters';
+ ok ?(all(@rand) ~~ any(@letters)), '... and they should be in the letters';
@rand = <a b c d e f g h>.pick(3);
is @rand.elems, 3, 'pick() should return the correct number of items';
- ok all(@rand) ~~ any(@letters), '... and they should be in the letters';
+ ok ?(all(@rand) ~~ any(@letters)), '... and they should be in the letters';
}
{
@@ -83,7 +83,7 @@ plan 15;
my @numbers = lotto(6, 49);
is @numbers.elems, 6, 'lotto() should return the correct number of numbers';
- ok all(@numbers) ~~ any(1..49), '... and they should be in the correct range';
+ ok ?(all(@numbers) ~~ any(1..49)), '... and they should be in the correct range';
my %unique = map { ($_ => 1) }, @numbers;
say %unique.perl;
is %unique.keys.elems, 6, '... and they should all be unique numbers';
Please sign in to comment.
Something went wrong with that request. Please try again.