Permalink
Browse files

remove more wrong uses of True and False as 0 and 1 (still more left)…

…; make good use of nok() function
  • Loading branch information...
1 parent 44e9d50 commit ea847c7f91f8d3aac63df6e12edfc4ce4ac0db15 @moritz moritz committed Sep 22, 2010
Showing with 30 additions and 30 deletions.
  1. +1 −1 S02-builtin_data_types/hash.t
  2. +14 −14 S03-metaops/reduce.t
  3. +8 −8 S03-operators/assign.t
  4. +4 −4 S03-operators/precedence.t
  5. +1 −1 S03-operators/so.t
  6. +2 −2 S03-series/basic.t
@@ -122,7 +122,7 @@ is(@values1[2], 3, 'got the right values');
my %hash8;
ok(%hash8.does(Hash), '%hash8 does Hash');
%hash8 = (:one, :key<value>, :three(3));
-is(%hash8{'one'}, 1, 'colonpair :one');
+ok(%hash8{'one'} === True, 'colonpair :one');
is(%hash8{'key'}, 'value', 'colonpair :key<value>');
is(%hash8{'three'}, 3, 'colonpair :three(3)');
View
@@ -40,14 +40,14 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
}
{
- ok ( [<] 1, 2, 3, 4), "[<] works (1)";
- ok (not [<] 1, 3, 2, 4), "[<] works (2)";
- ok ( [>] 4, 3, 2, 1), "[>] works (1)";
- ok (not [>] 4, 2, 3, 1), "[>] works (2)";
- ok ( [==] 4, 4, 4), "[==] works (1)";
- ok (not [==] 4, 5, 4), "[==] works (2)";
- ok ( [!=] 4, 5, 6), "[!=] works (1)";
- ok (not [!=] 4, 4, 4), "[!=] works (2)";
+ ok ([<] 1, 2, 3, 4), "[<] works (1)";
+ nok ([<] 1, 3, 2, 4), "[<] works (2)";
+ ok ([>] 4, 3, 2, 1), "[>] works (1)";
+ nok ([>] 4, 2, 3, 1), "[>] works (2)";
+ ok ([==] 4, 4, 4), "[==] works (1)";
+ nok ([==] 4, 5, 4), "[==] works (2)";
+ ok ([!=] 4, 5, 6), "[!=] works (1)";
+ nok ([!=] 4, 4, 4), "[!=] works (2)";
}
{
@@ -74,11 +74,11 @@ L<"http://groups.google.de/group/perl.perl6.language/msg/bd9eb275d5da2eda">
my $a = [1, 2];
my $b = [1, 2];
- ok ( [===] 1, 1, 1, 1), '[===] with literals';
- ok ( [===] $a, $a, $a), '[===] with vars (positive)';
- ok (not [===] $a, $a, [1, 2]), '[===] with vars (negative)';
- ok ( [!===] $a, $b, $a), '[!===] basic sanity (positive)';
- ok (not [!===] $a, $b, $b), '[!===] basic sanity (negative)';
+ ok ([===] 1, 1, 1, 1), '[===] with literals';
+ ok ([===] $a, $a, $a), '[===] with vars (positive)';
+ nok ([===] $a, $a, [1, 2]), '[===] with vars (negative)';
+ ok ([!===] $a, $b, $a), '[!===] basic sanity (positive)';
+ nok ([!===] $a, $b, $b), '[!===] basic sanity (negative)';
}
{
@@ -194,7 +194,7 @@ is( ([~] 'washcloth'), 'washcloth', "[~] 'washcloth' returns 'washcloth'");
is( ([\~] 'towel'), 'towel', "[\~] 'towel' returns 'towel'");
ok( ([\~] 'towel') ~~ Iterable, "[\~] 'towel' returns something Iterable");
is( ([<] 42), Bool::True, "[<] 42 returns true");
-is( ~([\<] 42), "1", "[\<] 42 returns '1'");
+is( ~([\<] 42), ~True, "[\<] 42 returns '1'");
ok( ([\<] 42) ~~ Iterable, "[\<] 42 returns something Iterable");
is( ([\*] 1..*).[^10].join(', '), '1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800',
@@ -422,27 +422,27 @@ my @p;
{
my $x = 42;
@p = $x ?|= 24, 25;
- is($x, 1, '?|= operator');
- is(@p[0],1, "?|= operator parses as item assignment 1");
+ is($x, True, '?|= operator');
+ is(@p[0], True, "?|= operator parses as item assignment 1");
is(@p[1],25, "?|= operator parses as item assignment 2");
}
#?pugs eval 'parsefail'
{
my $x = 42;
@p = $x ?&= 24, 25;
- is($x, 1, '?&= operator');
- is(@p[0],1, "?&= operator parses as item assignment 1");
- is(@p[1],25, "?&= operator parses as item assignment 2");
+ is($x, True, '?&= operator');
+ is(@p[0], True, "?&= operator parses as item assignment 1");
+ is(@p[1], 25, "?&= operator parses as item assignment 2");
}
#?pugs eval 'parsefail'
{
my $x = 0;
@p = $x ?^= 42, 43;
- is($x, 1, '?^= operator');
- is(@p[0],1, "?^= operator parses as item assignment 1");
- is(@p[1],43, "?^= operator parses as item assignment 2");
+ is($x, True, '?^= operator');
+ is(@p[0], True, "?^= operator parses as item assignment 1");
+ is(@p[1], 43, "?^= operator parses as item assignment 2");
}
#?pugs eval 'parsefail'
@@ -40,7 +40,7 @@ isa_ok(~2**4, Str, "~4**4 is a string");
# symbolic unary
is(!0 * 2, 2, "unary ! binds tighter than *");
-is(!(0 * 2), 1, "beh");
+ok(!(0 * 2), "beh");
is(?2*2, 2, "binary -> numify causes reinterpretation as, binds tighter than *");
# multiplicative
@@ -135,7 +135,7 @@ is((1 && 0 ?? 2 !! 3), 3, "&& binds tighter than ??");
# loose unary
my $x;
-is((so $x = 42), 1, "item assignment is tighter than true");
+is((so $x = 42), True, "item assignment is tighter than true");
# comma
@@ -218,9 +218,9 @@ eval_dies_ok '1, 2 Z 3, 4 X 5, 6',
my $r;
sub foo($x) { $r = $x }
foo 3 != 3;
- is($r, 0, 'sanity 3 != 3');
+ is($r, False, 'sanity 3 != 3');
foo 3 !=3;
- is($r, 0, 'ensure 3 !=3 gives same result as 3 != 3');
+ is($r, False, 'ensure 3 !=3 gives same result as 3 != 3');
}
# vim: ft=perl6
View
@@ -24,4 +24,4 @@ is (so($b) + 1), ((so $b) + 1), 'so($b) is (so $b)';
ok (so my $x = 5), 'so + declaration';
is $x, 5, 'assignment after so worked';
-???
+# vim: ft=perl6
View
@@ -92,10 +92,10 @@ is (4, 2, 1, 2, 4 ... 16).join(', '), '4, 2, 1, 2, 4, 8, 16', 'geometric series
# some tests taken from Spec
-is (False, &prefix:<!> ... *).[^10].join(', '), "0, 1, 0, 1, 0, 1, 0, 1, 0, 1", "alternating False and True";
+is (False, &prefix:<!> ... *).[^6].join(', '), (False, True, False, True, False, True).join(', '), "alternating False and True";
is (False, &prefix:<!> ... *).[^10].grep(Bool).elems, 10, "alternating False and True is always Bool";
is (1,2,&[+] ... 8).join(', ') , "1, 2, 3, 5, 8" , "Using &[+] works";
-is (False, { !$_ } ... *).[^10].join(', '), "0, 1, 0, 1, 0, 1, 0, 1, 0, 1", "alternating False and True";
+is (False, { !$_ } ... *).[^6].join(', '), (False, True, False, True, False, True).join(', '), "alternating False and True";
is (False, { !$_ } ... *).[^10].grep(Bool).elems, 10, "alternating False and True is always Bool";
# L<S03/List infix precedence/'"asymptotically approaching" is not the same as "equals"'>

0 comments on commit ea847c7

Please sign in to comment.