Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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