Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Final (hopefully!) batch of Order updates.

  • Loading branch information...
commit bb7b41817806a6cc322f8c15257908eff3839f2b 1 parent ddf434c
@jnthn jnthn authored
View
6 S03-operators/buf.t
@@ -29,8 +29,8 @@ nok $b lt $a, 'lt -';
ok $b gt $a, 'gt +';
nok $b gt $b, 'gt -';
nok $a gt $b, 'gt -';
-is $a cmp $a, 0, 'cmp (same)';
-is $a cmp $b,-1, 'cmp (smaller)';
-is $b cmp $a, 1, 'cmp (larger)';
+is $a cmp $a, Order::Same, 'cmp (same)';
+is $a cmp $b, Order::Increase, 'cmp (smaller)';
+is $b cmp $a, Order::Decrease, 'cmp (larger)';
is_deeply Buf.new(1, 2, 3) ~ Buf.new(4, 5), Buf.new(1, 2, 3, 4, 5), '~ concatenates';
View
52 S03-operators/comparison-simple.t
@@ -8,37 +8,37 @@ plan 25;
#L<S03/Comparison semantics>
# spaceship comparisons (Num)
-is(1 <=> 1, 0, '1 <=> 1 is same');
-is(1 <=> 2, -1, '1 <=> 2 is increase');
-is(2 <=> 1, 1, '2 <=> 1 is decrease');
+is(1 <=> 1, Order::Same, '1 <=> 1 is same');
+is(1 <=> 2, Order::Increase, '1 <=> 2 is increase');
+is(2 <=> 1, Order::Decrease, '2 <=> 1 is decrease');
#?niecza skip 'System.FormatException: Unknown char: a'
-is('a' <=> '1', -1, '<=> is in numeric context');
-
-is 0 <=> -1, 1, '0 <=> -1 is increase';
-is -1 <=> 0, -1, '-1 <=> 0 is decrease';
-is 0 <=> -1/2, 1, '0 <=> -1/2 is increase';
-is 0 <=> 1/2, -1, '0 <=> 1/2 is increase';
-is -1/2 <=> 0, -1, '-1/2 <=> 0 is decrease';
-is 1/2 <=> 0, 1, '1/2 <=> 0 is decrease';
-is 1/2 <=> 1/2, 0, '1/2 <=> 1/2 is same';
-is -1/2 <=> -1/2, 0, '-1/2 <=> -1/2 is same';
-is 1/2 <=> -1/2, 1, '1/2 <=> -1/2 is decrease';
-is -1/2 <=> 1/2, -1, '-1/2 <=> 1/2 is increase';
+is('a' <=> '1', Order::Increase, '<=> is in numeric context');
+
+is 0 <=> -1, Order::Decrease, '0 <=> -1 is increase';
+is -1 <=> 0, Order::Increase, '-1 <=> 0 is decrease';
+is 0 <=> -1/2, Order::Decrease, '0 <=> -1/2 is increase';
+is 0 <=> 1/2, Order::Increase, '0 <=> 1/2 is increase';
+is -1/2 <=> 0, Order::Increase, '-1/2 <=> 0 is decrease';
+is 1/2 <=> 0, Order::Decrease, '1/2 <=> 0 is decrease';
+is 1/2 <=> 1/2, Order::Same, '1/2 <=> 1/2 is same';
+is -1/2 <=> -1/2, Order::Same, '-1/2 <=> -1/2 is same';
+is 1/2 <=> -1/2, Order::Decrease, '1/2 <=> -1/2 is decrease';
+is -1/2 <=> 1/2, Order::Increase, '-1/2 <=> 1/2 is increase';
# leg comparison (Str)
-is('a' leg 'a', 0, 'a leg a is same');
-is('a' leg 'b', -1, 'a leg b is increase');
-is('b' leg 'a', 1, 'b leg a is decrease');
-is('a' leg 1, 1, 'leg is in string context');
+is('a' leg 'a', Order::Same, 'a leg a is same');
+is('a' leg 'b', Order::Increase, 'a leg b is increase');
+is('b' leg 'a', Order::Decrease, 'b leg a is decrease');
+is('a' leg 1, Order::Decrease, 'leg is in string context');
# cmp comparison
-is('a' cmp 'a', 0, 'a cmp a is same');
-is('a' cmp 'b', -1, 'a cmp b is increase');
-is('b' cmp 'a', 1, 'b cmp a is decrease');
-is(1 cmp 1, 0, '1 cmp 1 is same');
-is(1 cmp 2, -1, '1 cmp 2 is increase');
-is(2 cmp 1, 1, '2 cmp 1 is decrease');
-is('a' cmp 1, 1, '"a" cmp 1 is decrease'); # unspecced but P5 behavior
+is('a' cmp 'a', Order::Same, 'a cmp a is same');
+is('a' cmp 'b', Order::Increase, 'a cmp b is increase');
+is('b' cmp 'a', Order::Decrease, 'b cmp a is decrease');
+is(1 cmp 1, Order::Same, '1 cmp 1 is same');
+is(1 cmp 2, Order::Increase, '1 cmp 2 is increase');
+is(2 cmp 1, Order::Decrease, '2 cmp 1 is decrease');
+is('a' cmp 1, Order::Decrease, '"a" cmp 1 is decrease'); # unspecced but P5 behavior
done;
View
2  S03-operators/names.t
@@ -8,7 +8,7 @@ is infix:<+>(3, 8), 11, 'Can refer to infix:<+>';
is &infix:<->(3, 8), -5, 'Can refer to &infix:<->';
is infix:<->(3, 8), -5, 'Can refer to infix:<->';
-is &infix:<cmp>(3, 4), -1, 'Can refer to &infix:<cmp>';
+is &infix:<cmp>(3, 4), Order::Increase, 'Can refer to &infix:<cmp>';
#?niecza todo
ok ~&infix:<+> ~~ /infix/, 'String value of &infix:<+> contains "infix"';
View
4 S03-operators/spaceship-and-containers.t
@@ -8,11 +8,11 @@ plan 6;
my %h = ("a" => 1, "b" => 2);
ok(%h{"a"} < %h{"b"}, 'comparing hash values');
ok(%h{"a"} <= %h{"b"}, 'comparing hash values');
-is(%h{"a"} <=> %h{"b"}, -1, 'comparing hash values');
+is(%h{"a"} <=> %h{"b"}, Order::Increase, 'comparing hash values');
my @a = (1, 2);
ok(@a[0] < @a[1], 'comparing array values');
ok(@a[0] <= @a[1], 'comparing array values');
-is(@a[0] <=> @a[1], -1, 'comparing array values');
+is(@a[0] <=> @a[1], Order::Increase, 'comparing array values');
# vim: ft=perl6
View
10 S03-operators/spaceship.t
@@ -9,22 +9,22 @@ plan 5;
my %ball = map {; $_ => 1 }, 1..12;
is(
(%ball{12}) <=> (%ball{11}),
- 0,
+ Order::Same,
'parens with spaceship parse incorrectly',
);
my $result_1 = ([+] %ball{10..12}) <=> ([+] %ball{1..3});
-is($result_1, 0, 'When spaceship terms are non-trivial members it parses incorrectly');
+is($result_1, Order::Same, 'When spaceship terms are non-trivial members it parses incorrectly');
my $result_2 = ([+] %ball{11,12}) <=> ([+] %ball{1,2});
-is($result_2, 0, 'When spaceship terms are non-trivial members it parses incorrectly');
+is($result_2, Order::Same, 'When spaceship terms are non-trivial members it parses incorrectly');
#?rakudo skip 'unspecced: does infix:«<=>» numify its arguments?'
{
my $result_3 = ([0] <=> [0,1]);
-is($result_3, -1, 'When spaceship terms are non-trivial members it parses incorrectly');
+is($result_3, Order::Increase, 'When spaceship terms are non-trivial members it parses incorrectly');
}
%ball{12} = 0.5;
-is(%ball{12} <=> %ball{11}, -1, 'When spaceship terms are non-integral numbers it parses incorrectly');
+is(%ball{12} <=> %ball{11}, Order::Increase, 'When spaceship terms are non-integral numbers it parses incorrectly');
# vim: ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.