Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 170 lines (139 sloc) 4.484 kb
f46eb61 set svn properties on all .t files below t/
moritz authored
1 use v6;
2 use Test;
3
52a1f79 @colomon Add test for Nieczabug #142, !(4 eqv 4.0)
colomon 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'
f3f35ac @coke niecza fudging
coke authored
37 #?niecza skip 'Cannot use value like Capture as a number'
f46eb61 set svn properties on all .t files below t/
moritz authored
38 {
39 my @a = (1,2,3);
40 my @b = (1,2,3);
41
42 ok (\@a eqv \@a), "eqv on array references (1)";
43 ok (\@b eqv \@b), "eqv on array references (2)";
d4cb58c @coke pugs fudge
coke authored
44 #?pugs todo
f46eb61 set svn properties on all .t files below t/
moritz authored
45 ok !(\@a eqv \@b), "eqv on array references (3)";
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
46 @a := @b;
47 ok \@a eqv \@b, '\@array of two bound arrays are eqv';
f46eb61 set svn properties on all .t files below t/
moritz authored
48 }
49
f3f35ac @coke niecza fudging
coke authored
50 #?niecza skip 'Cannot use value like Capture as a number'
f46eb61 set svn properties on all .t files below t/
moritz authored
51 {
52 my $a = \3;
53 my $b = \3;
54
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
55 ok ($a eqv $a), "eqv on scalar references (1-1)";
56 ok ($b eqv $b), "eqv on scalar references (1-2)";
57 ok ($a eqv $b), "eqv on scalar references (1-3)";
baed277 [t/spec] Tweak some fudge reasons.
jnthn authored
58 #?rakudo skip 'infix:<!eqv>'
d4cb58c @coke pugs fudge
coke authored
59 #?pugs todo
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
60 ok (\$a !eqv \$b), "eqv on scalar references (1-4)";
f46eb61 set svn properties on all .t files below t/
moritz authored
61 }
62
f3f35ac @coke niecza fudging
coke authored
63 #?niecza skip 'Cannot use value like Block as a number'
f46eb61 set svn properties on all .t files below t/
moritz authored
64 {
65 my $a = { 3 };
66 my $b = { 3 };
67
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
68 ok ($a eqv $a), "eqv on sub references (1-1)";
69 ok ($b eqv $b), "eqv on sub references (1-2)";
5a51d4d @moritz correct an eqv test
moritz authored
70 # it's impossible to compare blocks for equivalence in general,
71 # and they have associations to different source locations
72 # (line number, column)
73 nok ($a eqv $b), "eqv on sub references (1-3)";
74 nok ($a eqv { 5 }), 'eqv on sub references (1-4)';
f46eb61 set svn properties on all .t files below t/
moritz authored
75 }
76
f3f35ac @coke niecza fudging
coke authored
77 #?niecza skip 'Cannot use value like Sub as a number'
f46eb61 set svn properties on all .t files below t/
moritz authored
78 {
79 ok (&say eqv &say), "eqv on sub references (2-1)";
80 ok (&map eqv &map), "eqv on sub references (2-2)";
81 ok !(&say eqv &map), "eqv on sub references (2-3)";
82 }
83
f3f35ac @coke niecza fudging
coke authored
84 #?niecza skip 'Cannot use value like Capture as a number'
f46eb61 set svn properties on all .t files below t/
moritz authored
85 {
1571369 test for RT #72872, Mu eqv Mu
moritz authored
86 my $num = 3; my $a = \$num;
f46eb61 set svn properties on all .t files below t/
moritz authored
87 my $b = \$num;
88
89 ok ($a eqv $a), "eqv on scalar references (2-1)";
90 ok ($b eqv $b), "eqv on scalar references (2-2)";
91 ok ($a eqv $b), "eqv on scalar references (2-3)";
92 }
93
94 {
5a51d4d @moritz correct an eqv test
moritz authored
95 nok ([1,2,3] eqv [4,5,6]), "eqv on anonymous array references (1)";
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
96 ok ([1,2,3] eqv [1,2,3]), "eqv on anonymous array references (2)";
97 ok ([] eqv []), "eqv on anonymous array references (3)";
f46eb61 set svn properties on all .t files below t/
moritz authored
98 }
99
100 {
4bdf17e @coke Convert niecza faux-todo to real todo.
coke authored
101 #?niecza todo
4081a4a [t/spec] fix and extend %h1 eqv %h2 tests
moritz authored
102 ok !({a => 1} eqv {a => 2}), "eqv on anonymous hash references (-)";
d4cb58c @coke pugs fudge
coke authored
103 #?pugs todo
4081a4a [t/spec] fix and extend %h1 eqv %h2 tests
moritz authored
104 ok ({a => 1} eqv {a => 1}), "eqv on anonymous hash references (+)";
d4cb58c @coke pugs fudge
coke authored
105 #?pugs todo
4081a4a [t/spec] fix and extend %h1 eqv %h2 tests
moritz authored
106 ok ({a => 2, b => 1} eqv { b => 1, a => 2}), 'order really does not matter';
107 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
108 }
109
01ef6c2 [t/spec] fudge eqv.t for rakudo
moritz authored
110 #?rakudo skip 'captures'
f3f35ac @coke niecza fudging
coke authored
111 #?niecza skip 'Cannot use value like Capture as a number'
f46eb61 set svn properties on all .t files below t/
moritz authored
112 {
113 ok !(\3 eqv \4), "eqv on anonymous scalar references (1)";
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
114 # XXX the following seems bogus nowadays
ebb9ec5 @coke pugs unfudge
coke authored
115 #?pugs 2 todo
f46eb61 set svn properties on all .t files below t/
moritz authored
116 ok !(\3 eqv \3), "eqv on anonymous scalar references (2)";
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
117 ok !(\Mu eqv \Mu), "eqv on anonymous scalar references (3)";
f46eb61 set svn properties on all .t files below t/
moritz authored
118 }
119
120 # Chained eqv (not specced, but obvious)
121 {
122 ok (3 eqv 3 eqv 3), "chained eqv (1)";
123 ok !(3 eqv 3 eqv 4), "chained eqv (2)";
124 }
125
126 # Subparam binding doesn't affect eqv test
127 {
128 my $foo;
129 my $test = -> $arg { $foo eqv $arg };
130
131 $foo = 3;
132 ok $test($foo), "subparam binding doesn't affect eqv (1)";
133 ok $test(3), "subparam binding doesn't affect eqv (2)";
134
135 ok !$test(4), "subparam binding doesn't affect eqv (3)";
136 my $bar = 4;
137 ok !$test($bar), "subparam binding doesn't affect eqv (4)";
138 }
139
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
140 {
141 is(1 eqv 1, Bool::True, 'eqv returns Bool::True when true');
142 is(0 eqv 1, Bool::False, 'eqv returns Bool::False when false');
143 }
d7f4d0b [t/spec] a few more fixed smartlinks; down to 56 broken
moritz authored
144
1571369 test for RT #72872, Mu eqv Mu
moritz authored
145 {
146 is Any eqv Any, Bool::True, 'Any eqv Any';
ca66c90 @colomon Instead of testing Mu eqv Mu and Mu !eqv Any, test that infix:<eqv> a…
colomon authored
147 }
148
93b57c2 @coke pugs un/fudge
coke authored
149 #?pugs skip "autothreaded?"
ca66c90 @colomon Instead of testing Mu eqv Mu and Mu !eqv Any, test that infix:<eqv> a…
colomon authored
150 {
151 ok 'a' eqv any <a b c>, "eqv autothreads correctly";
1571369 test for RT #72872, Mu eqv Mu
moritz authored
152 }
153
b814b4d @moritz [eqv.t] tests for RT #75322
moritz authored
154 # RT #75322 - Rakudo used to be confused when lists began with ()
155 {
d4cb58c @coke pugs fudge
coke authored
156 #?niecza todo
b814b4d @moritz [eqv.t] tests for RT #75322
moritz authored
157 nok ((), "x") eqv ((), 9), 'list starting with () - 1';
158 nok ((), (), 1) eqv ((), 9), 'list starting with () - 1';
159 nok ((), (), (), 1) eqv ((), (), ""), 'list starting with () - 1';
160 nok ((), (), (), 1) eqv ((), 4), 'list starting with () - 1';
161 ok ((), ()) eqv ((), ()), '((), ())';
162 }
163
52a1f79 @colomon Add test for Nieczabug #142, !(4 eqv 4.0)
colomon authored
164 # Nieczabug #142
165 {
166 nok 4 eqv 4.0, "Values should be eqv only if they are the same type";
167 }
168
d7f4d0b [t/spec] a few more fixed smartlinks; down to 56 broken
moritz authored
169 # vim: ft=perl6
Something went wrong with that request. Please try again.