Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 73 lines (60 sloc) 2.773 kb
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
8a1a068 Some initial test refactors and cleanups for basic operators.
pmichaud authored
2 use Test;
3
6d2e28d [t/spec] Add tricky tests (which pass after latest Rakudo patch), unfudg...
colomon authored
4 plan 42;
8a1a068 Some initial test refactors and cleanups for basic operators.
pmichaud authored
5
6 # N.B.: relational ops are in relational.t
7
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
8 # L<S03/Nonchaining binary precedence/Order::Increase, Order::Same, or Order::Decrease>
9 is(+Order::Increase, -1, 'Order::Increase numifies to -1');
10 is(+Order::Same, 0, 'Order::Same numifies to 0');
497b392 [comparison.t] typo spotted by oskie++
masak authored
11 is(+Order::Decrease, 1, 'Order::Decrease numifies to 1');
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
12
8a1a068 Some initial test refactors and cleanups for basic operators.
pmichaud authored
13 #L<S03/Comparison semantics>
14
15 # spaceship comparisons (Num)
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
16 is(1 <=> 1, Order::Same, '1 <=> 1 is same');
17 is(1 <=> 2, Order::Increase, '1 <=> 2 is increase');
18 is(2 <=> 1, Order::Decrease, '2 <=> 1 is decrease');
fa413e2 Solomon Foster Change the "Blue" tests to use an Int instead of a Complex, reflecting t...
colomon authored
19 #?niecza skip 'Cannot parse number: a'
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
20 is('a' <=> '1', Order::Increase, '<=> is in numeric context');
8a1a068 Some initial test refactors and cleanups for basic operators.
pmichaud authored
21
6a6e12a [t/spec] Test for RT 70664: Try <=> with rationals
kyle authored
22 is 0 <=> -1, Order::Decrease, '0 <=> -1 is increase';
23 is -1 <=> 0, Order::Increase, '-1 <=> 0 is decrease';
6d2e28d [t/spec] Add tricky tests (which pass after latest Rakudo patch), unfudg...
colomon authored
24 is 0 <=> -1/2, Order::Decrease, '0 <=> -1/2 is decrease';
6a6e12a [t/spec] Test for RT 70664: Try <=> with rationals
kyle authored
25 is 0 <=> 1/2, Order::Increase, '0 <=> 1/2 is increase';
26 is -1/2 <=> 0, Order::Increase, '-1/2 <=> 0 is decrease';
27 is 1/2 <=> 0, Order::Decrease, '1/2 <=> 0 is decrease';
28 is 1/2 <=> 1/2, Order::Same, '1/2 <=> 1/2 is same';
29 is -1/2 <=> -1/2, Order::Same, '-1/2 <=> -1/2 is same';
30 is 1/2 <=> -1/2, Order::Decrease, '1/2 <=> -1/2 is decrease';
31 is -1/2 <=> 1/2, Order::Increase, '-1/2 <=> 1/2 is increase';
32
8a1a068 Some initial test refactors and cleanups for basic operators.
pmichaud authored
33 # leg comparison (Str)
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
34 is('a' leg 'a', Order::Same, 'a leg a is same');
35 is('a' leg 'b', Order::Increase, 'a leg b is increase');
36 is('b' leg 'a', Order::Decrease, 'b leg a is decrease');
37 is('a' leg 1, Order::Decrease, 'leg is in string context');
0312dc0 [comparison.t] add some tests involving \0
lwall authored
38 is("a" leg "a\0", Order::Increase, 'a leg a\0 is increase');
39 is("a\0" leg "a\0", Order::Same, 'a\0 leg a\0 is same');
40 is("a\0" leg "a", Order::Decrease, 'a\0 leg a is decrease');
8a1a068 Some initial test refactors and cleanups for basic operators.
pmichaud authored
41
42 # cmp comparison
b877b80 [gsoc_spectest] Added more cmp, leg, and <=> tests. Tested the values of...
Auzon authored
43 is('a' cmp 'a', Order::Same, 'a cmp a is same');
44 is('a' cmp 'b', Order::Increase, 'a cmp b is increase');
45 is('b' cmp 'a', Order::Decrease, 'b cmp a is decrease');
46 is(1 cmp 1, Order::Same, '1 cmp 1 is same');
47 is(1 cmp 2, Order::Increase, '1 cmp 2 is increase');
48 is(2 cmp 1, Order::Decrease, '2 cmp 1 is decrease');
49 is('a' cmp 1, Order::Decrease, '"a" cmp 1 is decrease'); # unspecced but P5 behavior
0312dc0 [comparison.t] add some tests involving \0
lwall authored
50 is("a" cmp "a\0", Order::Increase, 'a cmp a\0 is increase');
51 is("a\0" cmp "a\0", Order::Same, 'a\0 cmp a\0 is same');
52 is("a\0" cmp "a", Order::Decrease, 'a\0 cmp a is decrease');
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
53
6d2e28d [t/spec] Add tricky tests (which pass after latest Rakudo patch), unfudg...
colomon authored
54 # compare numerically with non-numeric
55 {
56 class Blue {
fa413e2 Solomon Foster Change the "Blue" tests to use an Int instead of a Complex, reflecting t...
colomon authored
57 method Numeric() { 3; }
6d2e28d [t/spec] Add tricky tests (which pass after latest Rakudo patch), unfudg...
colomon authored
58 }
59 my $a = Blue.new;
60
fa413e2 Solomon Foster Change the "Blue" tests to use an Int instead of a Complex, reflecting t...
colomon authored
61 ok +$a == 3, '+$a == 3 (just checking)';
62 ok $a == 3, '$a == 3';
63 ok $a != 4, '$a != 4';
64 nok $a != 3, 'not true that $a != 3';
6d2e28d [t/spec] Add tricky tests (which pass after latest Rakudo patch), unfudg...
colomon authored
65
66 lives_ok { $a < 5 }, '$a < 5 lives okay';
67 lives_ok { $a <= 5 }, '$a <= 5 lives okay';
68 lives_ok { $a > 5 }, '$a > 5 lives okay';
69 lives_ok { $a >= 5 }, '$a => 5 lives okay';
70 }
6a6e12a [t/spec] Test for RT 70664: Try <=> with rationals
kyle authored
71
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
72 # vim: ft=perl6
Something went wrong with that request. Please try again.