Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 136 lines (109 sloc) 3.392 kB
f46eb61 set svn properties on all .t files below t/
moritz authored
1 use v6;
2 use Test;
3
4081a4a [t/spec] fix and extend %h1 eqv %h2 tests
moritz authored
4 plan 45;
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
36 # Reference types
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)";
01ef6c2 [t/spec] fudge eqv.t for rakudo
moritz authored
43 #?rakudo todo 'captures and infix:<eqv>'
f46eb61 set svn properties on all .t files below t/
moritz authored
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
49 {
50 my $a = \3;
51 my $b = \3;
52
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
53 ok ($a eqv $a), "eqv on scalar references (1-1)";
54 ok ($b eqv $b), "eqv on scalar references (1-2)";
55 ok ($a eqv $b), "eqv on scalar references (1-3)";
56 #?rakudo skip 'infix:<!eqv>, captures and infix:<eqv>'
57 ok (\$a !eqv \$b), "eqv on scalar references (1-4)";
f46eb61 set svn properties on all .t files below t/
moritz authored
58 }
59
01ef6c2 [t/spec] fudge eqv.t for rakudo
moritz authored
60 #?
f46eb61 set svn properties on all .t files below t/
moritz authored
61 {
62 my $a = { 3 };
63 my $b = { 3 };
64
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
65 ok ($a eqv $a), "eqv on sub references (1-1)";
66 ok ($b eqv $b), "eqv on sub references (1-2)";
67 #?rakudo todo 'eqv on sub-refs'
68 ok ($a eqv $b), "eqv on sub references (1-3)";
69 ok !($a eqv { 5 }), 'eqv on sub references (1-4)';
f46eb61 set svn properties on all .t files below t/
moritz authored
70 }
71
72 {
73 ok (&say eqv &say), "eqv on sub references (2-1)";
74 ok (&map eqv &map), "eqv on sub references (2-2)";
75 ok !(&say eqv &map), "eqv on sub references (2-3)";
76 }
77
78 {
79 my $num = 3;
80 my $a = \$num;
81 my $b = \$num;
82
83 ok ($a eqv $a), "eqv on scalar references (2-1)";
84 ok ($b eqv $b), "eqv on scalar references (2-2)";
85 ok ($a eqv $b), "eqv on scalar references (2-3)";
86 }
87
88 {
89 ok !([1,2,3] eqv [4,5,6]), "eqv on anonymous array references (1)";
0d22a8e [t/spec] correct and extend eqv.t
moritz authored
90 ok ([1,2,3] eqv [1,2,3]), "eqv on anonymous array references (2)";
91 ok ([] eqv []), "eqv on anonymous array references (3)";
f46eb61 set svn properties on all .t files below t/
moritz authored
92 }
93
94 {
4081a4a [t/spec] fix and extend %h1 eqv %h2 tests
moritz authored
95 ok !({a => 1} eqv {a => 2}), "eqv on anonymous hash references (-)";
96 ok ({a => 1} eqv {a => 1}), "eqv on anonymous hash references (+)";
97 ok ({a => 2, b => 1} eqv { b => 1, a => 2}), 'order really does not matter';
98 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
99 }
100
01ef6c2 [t/spec] fudge eqv.t for rakudo
moritz authored
101 #?rakudo skip 'captures'
f46eb61 set svn properties on all .t files below t/
moritz authored
102 {
103 ok !(\3 eqv \4), "eqv on anonymous scalar references (1)";
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
104 # XXX the following seems bogus nowadays
f46eb61 set svn properties on all .t files below t/
moritz authored
105 #?pugs 2 todo 'bug'
106 ok !(\3 eqv \3), "eqv on anonymous scalar references (2)";
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
107 ok !(\Mu eqv \Mu), "eqv on anonymous scalar references (3)";
f46eb61 set svn properties on all .t files below t/
moritz authored
108 }
109
110 # Chained eqv (not specced, but obvious)
111 {
112 ok (3 eqv 3 eqv 3), "chained eqv (1)";
113 ok !(3 eqv 3 eqv 4), "chained eqv (2)";
114 }
115
116 # Subparam binding doesn't affect eqv test
117 {
118 my $foo;
119 my $test = -> $arg { $foo eqv $arg };
120
121 $foo = 3;
122 ok $test($foo), "subparam binding doesn't affect eqv (1)";
123 ok $test(3), "subparam binding doesn't affect eqv (2)";
124
125 ok !$test(4), "subparam binding doesn't affect eqv (3)";
126 my $bar = 4;
127 ok !$test($bar), "subparam binding doesn't affect eqv (4)";
128 }
129
9a58617 [gsoc_spectest] reorganization and a few more tests for ===, eqv, and…
Auzon authored
130 {
131 is(1 eqv 1, Bool::True, 'eqv returns Bool::True when true');
132 is(0 eqv 1, Bool::False, 'eqv returns Bool::False when false');
133 }
d7f4d0b [t/spec] a few more fixed smartlinks; down to 56 broken
moritz authored
134
135 # vim: ft=perl6
Something went wrong with that request. Please try again.