Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 115 lines (96 sloc) 3.308 kb
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
1 use v6;
2
3 use Test;
4
fcf1024 [t/spec] More revisions of past tests
kyle authored
5 plan 71;
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
6
7 =begin description
8
9 Enum tests from L<S12/Enums>
10
11 =end description
12
13 #?pugs 999 skip
14 # L<S12/Enums/values are specified as a list>
15 enum day <Sun Mon Tue Wed Thu Fri Sat>;
16
d2c9e73 [t/spec] Add test for RT#63878.
jnthn authored
17 ok day ne "", 'enum itself stringififes';
3cfd6a2 [t/spec] Fudge a test that is failing in Rakudo.
jnthn authored
18 #?rakudo skip 'regression'
a8b77bc [spec] test .WHAT and .perl on actual enums, masak++
moritz authored
19 ok day.WHAT, 'enum.WHAT returned a value';
20 ok day.perl, 'enum.perl returned a value';
21
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
22 sub test_stuff($x) {
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are no...
jnthn authored
23 #?rakudo 1 skip '.does for enum value - XXX is this really valid test? asked TimToady...'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
24 ok $x.does(day::Tue), "basic enum mixing worked ($x-2)";
25 is $x.day, 2, "automatically created accessor worked ($x)";
26 is day::Tue, 2, "enum provided a correct mapping ($x)";
27 ok $x ~~ day, "smartmatch worked correctly ($x-1)";
28 ok $x ~~ Tue, "smartmatch worked correctly ($x-2)";
29 ok $x ~~ day::Tue, "smartmatch worked correctly ($x-3)";
30 ok $x !~~ Wed, "smartmatch worked correctly ($x-4)";
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are no...
jnthn authored
31 #?rakudo 1 skip '.does for enum value - XXX is this really valid test? asked TimToady...'
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
32 ok $x.does(Tue), ".does worked correctly ($x-1)";
33 ok $x.does(day), ".does worked correctly ($x-2)";
34 #?rakudo skip 'EnumValue($x)'
35 ok Tue($x), "Tue() worked correctly ($x)";
36 ok $x.Tue, ".Tue() worked correctly ($x)";
37 #?rakudo skip 'unknown bug'
38 ok $x.Tue.WHAT, '$obj.Tue.WHAT returns a true valuee';
39 ok $x.Tue.perl, '$obj.Tue.perl returns a true valuee';
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
40 }
41
42 {
43 my $x = 1;
44 is $x, 1, "basic sanity (1)";
45 # L<S12/Enums/has the right semantics mixed in:>
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
46 ok $x does day(Tue), "basic enum mixing worked (1-1)";
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
47 test_stuff($x);
48 }
49
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
50 #?DOES 15
51 #?rakudo skip 'does day<tue> - but is this even valid?'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
52 {
53 my $x = 2;
54 is $x, 2, "basic sanity (2)";
55 # L<S12/Enums/or pseudo-hash form:>
56 ok $x does day<Tue>, "basic enum mixing worked (2-1)";
57 test_stuff($x);
58 }
59
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
60 #?rakudo skip 'does day::Tue'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
61 {
62 my $x = 3;
63 is $x, 3, "basic sanity (3)";
64 # L<S12/Enums/is the same as>
65 ok $x does day::Tue, "basic enum mixing worked (3-1)";
66 test_stuff($x);
67 }
68
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
69 #?DOES 16
70 #?rakudo skip 'does &day::("Tue")'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
71 {
72 my $x = 4;
73 is $x, 4, "basic sanity (4)";
74 # L<S12/Enums/which is short for something like:>
75 ok $x does day, "basic enum mixing worked (4-0)";
76 ok $x.day = &day::("Tue"), "basic enum mixing worked (4-1)";
77 test_stuff($x);
78 }
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
79
80 # used to be Rakudo regression, RT #64098
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same with e...
moritz authored
81 #?rakudo skip 'augment'
82 #?DOES 2
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
83 {
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
84 augment class Object {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
85 method f { 'inObject' };
86 }
87
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
88 augment class Bool {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
89 method f { 'inBool' };
90 }
91 is True.f, 'inBool', 'method on short name pick up the one from the enum';
92 is Bool::True.f, 'inBool', 'method on long name pick up the one from the enum';
93 }
94
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same with e...
moritz authored
95 ok True.perl ~~/^ 'Bool::True'/, 'True.perl';
96 ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
97
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
98 {
99 enum Negation << :isnt<isnt> :arent<arent> :amnot<amnot> :aint<aint> >>;
100 my Negation $foo;
101 #?rakudo todo 'Null PMC Access in invoke()'
102 lives_ok { $foo = Negation::isnt }, 'simple assignment from enum';
fcf1024 [t/spec] More revisions of past tests
kyle authored
103 #?rakudo skip 'Null PMC Access in invoke()'
104 is $foo, Negation::isnt, 'assignment from enum works';
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
105 }
106
9feb346 [t/spec] Test for RT #66886
kyle authored
107 # RT #66886
108 {
109 enum RT66886 <b>;
110 #?rakudo todo 'RT #66886'
8bf9bb9 fix RT #66886 test, thanks to TimToady++
kyle authored
111 eval_dies_ok 'RT66886::c', 'accessing non-value of enum dies proper-like';
9feb346 [t/spec] Test for RT #66886
kyle authored
112 }
113
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
114 # vim: ft=perl6
Something went wrong with that request. Please try again.