Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 149 lines (120 sloc) 3.845 kB
f46eb61 set svn properties on all .t files below t/
moritz authored
1 use v6;
2 use Test;
3
b814b4d @moritz [eqv.t] tests for RT #75322
moritz authored
4 plan 53;
f46eb61 set svn properties on all .t files below t/
moritz authored
5
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
6 # L<S03/Comparison semantics/Binary eqv tests equality much like === does>
d7f4d0b [t/spec] a few more fixed smartlinks; down to 56 broken
moritz authored
7 # L<S32::Basics/Any/"=item eqv">
f46eb61 set svn properties on all .t files below t/
moritz authored
8
9 # eqv on values
10 {
11 ok (1 eqv 1), "eqv on values (1)";
12 ok (0 eqv 0), "eqv on values (2)";
13 ok !(0 eqv 1), "eqv on values (3)";
14 }
15
16 # Value types
17 {
18 my $a = 1;
19 my $b = 1;
20
21 ok $a eqv $a, "eqv on value types (1-1)";
22 ok $b eqv $b, "eqv on value types (1-2)";
23 ok $a eqv $b, "eqv on value types (1-3)";
24 }
25
26
27 {
28 my $a = 1;
29 my $b = 2;
30
31 ok ($a eqv $a), "eqv on value types (2-1)";
32 ok ($b eqv $b), "eqv on value types (2-2)";
33 ok !($a eqv $b), "eqv on value types (2-3)";
34 }
35
baed277 [t/spec] Tweak some fudge reasons.
jnthn authored
36 #?rakudo skip 'binding NYI'
f46eb61 set svn properties on all .t files below t/
moritz authored
37 {
38 my @a = (1,2,3);
39 my @b = (1,2,3);
40
41 ok (\@a eqv \@a), "eqv on array references (1)";
42 ok (\@b eqv \@b), "eqv on array references (2)";
43 ok !(\@a eqv \@b), "eqv on array references (3)";
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
44 @a := @b;
45 ok \@a eqv \@b, '\@array of two bound arrays are eqv';
f46eb61 set svn properties on all .t files below t/
moritz authored
46 }
47
48 {
49 my $a = \3;
50 my $b = \3;
51
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
52 ok ($a eqv $a), "eqv on scalar references (1-1)";
53 ok ($b eqv $b), "eqv on scalar references (1-2)";
54 ok ($a eqv $b), "eqv on scalar references (1-3)";
baed277 [t/spec] Tweak some fudge reasons.
jnthn authored
55 #?rakudo skip 'infix:<!eqv>'
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
56 ok (\$a !eqv \$b), "eqv on scalar references (1-4)";
f46eb61 set svn properties on all .t files below t/
moritz authored
57 }
58
01ef6c2 [t/spec] fudge eqv.t for rakudo
moritz authored
59 #?
f46eb61 set svn properties on all .t files below t/
moritz authored
60 {
61 my $a = { 3 };
62 my $b = { 3 };
63
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
64 ok ($a eqv $a), "eqv on sub references (1-1)";
65 ok ($b eqv $b), "eqv on sub references (1-2)";
66 #?rakudo todo 'eqv on sub-refs'
67 ok ($a eqv $b), "eqv on sub references (1-3)";
68 ok !($a eqv { 5 }), 'eqv on sub references (1-4)';
f46eb61 set svn properties on all .t files below t/
moritz authored
69 }
70
71 {
72 ok (&say eqv &say), "eqv on sub references (2-1)";
73 ok (&map eqv &map), "eqv on sub references (2-2)";
74 ok !(&say eqv &map), "eqv on sub references (2-3)";
75 }
76
77 {
1571369 test for RT #72872, Mu eqv Mu
moritz authored
78 my $num = 3; my $a = \$num;
f46eb61 set svn properties on all .t files below t/
moritz authored
79 my $b = \$num;
80
81 ok ($a eqv $a), "eqv on scalar references (2-1)";
82 ok ($b eqv $b), "eqv on scalar references (2-2)";
83 ok ($a eqv $b), "eqv on scalar references (2-3)";
84 }
85
86 {
87 ok !([1,2,3] eqv [4,5,6]), "eqv on anonymous array references (1)";
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
88 ok ([1,2,3] eqv [1,2,3]), "eqv on anonymous array references (2)";
89 ok ([] eqv []), "eqv on anonymous array references (3)";
f46eb61 set svn properties on all .t files below t/
moritz authored
90 }
91
92 {
4081a4a [t/spec] fix and extend %h1 eqv %h2 tests
moritz authored
93 ok !({a => 1} eqv {a => 2}), "eqv on anonymous hash references (-)";
94 ok ({a => 1} eqv {a => 1}), "eqv on anonymous hash references (+)";
95 ok ({a => 2, b => 1} eqv { b => 1, a => 2}), 'order really does not matter';
96 ok !({a => 1} eqv {a => 1, b => 2}), 'hashes: different number of pairs';
f46eb61 set svn properties on all .t files below t/
moritz authored
97 }
98
01ef6c2 [t/spec] fudge eqv.t for rakudo
moritz authored
99 #?rakudo skip 'captures'
f46eb61 set svn properties on all .t files below t/
moritz authored
100 {
101 ok !(\3 eqv \4), "eqv on anonymous scalar references (1)";
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
102 # XXX the following seems bogus nowadays
f46eb61 set svn properties on all .t files below t/
moritz authored
103 #?pugs 2 todo 'bug'
104 ok !(\3 eqv \3), "eqv on anonymous scalar references (2)";
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
105 ok !(\Mu eqv \Mu), "eqv on anonymous scalar references (3)";
f46eb61 set svn properties on all .t files below t/
moritz authored
106 }
107
108 # Chained eqv (not specced, but obvious)
109 {
110 ok (3 eqv 3 eqv 3), "chained eqv (1)";
111 ok !(3 eqv 3 eqv 4), "chained eqv (2)";
112 }
113
114 # Subparam binding doesn't affect eqv test
115 {
116 my $foo;
117 my $test = -> $arg { $foo eqv $arg };
118
119 $foo = 3;
120 ok $test($foo), "subparam binding doesn't affect eqv (1)";
121 ok $test(3), "subparam binding doesn't affect eqv (2)";
122
123 ok !$test(4), "subparam binding doesn't affect eqv (3)";
124 my $bar = 4;
125 ok !$test($bar), "subparam binding doesn't affect eqv (4)";
126 }
127
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
128 {
129 is(1 eqv 1, Bool::True, 'eqv returns Bool::True when true');
130 is(0 eqv 1, Bool::False, 'eqv returns Bool::False when false');
131 }
d7f4d0b [t/spec] a few more fixed smartlinks; down to 56 broken
moritz authored
132
1571369 test for RT #72872, Mu eqv Mu
moritz authored
133 {
134 is Mu eqv Mu, Bool::True, 'Mu eqv Mu';
135 is Any eqv Any, Bool::True, 'Any eqv Any';
136 is Any eqv Mu, Bool::False, 'Any !eqv Mu';
137 }
138
b814b4d @moritz [eqv.t] tests for RT #75322
moritz authored
139 # RT #75322 - Rakudo used to be confused when lists began with ()
140 {
141 nok ((), "x") eqv ((), 9), 'list starting with () - 1';
142 nok ((), (), 1) eqv ((), 9), 'list starting with () - 1';
143 nok ((), (), (), 1) eqv ((), (), ""), 'list starting with () - 1';
144 nok ((), (), (), 1) eqv ((), 4), 'list starting with () - 1';
145 ok ((), ()) eqv ((), ()), '((), ())';
146 }
147
d7f4d0b [t/spec] a few more fixed smartlinks; down to 56 broken
moritz authored
148 # vim: ft=perl6
Something went wrong with that request. Please try again.