Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 116 lines (94 sloc) 3.342 kb
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
1 use v6;
2
db4bde7 [t/spec] add 'use MONKEY_TYPING' where appropriate
lwall authored
3 use MONKEY_TYPING;
4
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
5 use Test;
6
7
8 =begin description
9
b8d99dd [t/spec] fix more smartlinks
moritz authored
10 Enum tests from L<S12/Enumerations>
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
11
12 =end description
13
14 #?pugs 999 skip
b7c9e84 [t/spec] delete some outdated tests in S12-enums/thorough.t and fix smar...
moritz authored
15 # L<S12/Enumerations/keys are specified as a parenthesized list>
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
16 enum day <Sun Mon Tue Wed Thu Fri Sat>;
17
d2c9e73 [t/spec] Add test for RT#63878.
jnthn authored
18 ok day ne "", 'enum itself stringififes';
3cfd6a2 [t/spec] Fudge a test that is failing in Rakudo.
jnthn authored
19 #?rakudo skip 'regression'
a8b77bc [spec] test .WHAT and .perl on actual enums, masak++
moritz authored
20 ok day.WHAT, 'enum.WHAT returned a value';
21 ok day.perl, 'enum.perl returned a value';
22
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
23 sub test_stuff($x) {
43b5fc8 [t/spec] .does(Enum::Value) is on shakey ground, since the values are no...
jnthn authored
24 #?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
25 ok $x.does(day::Tue), "basic enum mixing worked ($x-2)";
26 is $x.day, 2, "automatically created accessor worked ($x)";
27 is day::Tue, 2, "enum provided a correct mapping ($x)";
28 ok $x ~~ day, "smartmatch worked correctly ($x-1)";
29 ok $x ~~ Tue, "smartmatch worked correctly ($x-2)";
30 ok $x ~~ day::Tue, "smartmatch worked correctly ($x-3)";
31 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
32 #?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
33 ok $x.does(Tue), ".does worked correctly ($x-1)";
34 ok $x.does(day), ".does worked correctly ($x-2)";
35 #?rakudo skip 'EnumValue($x)'
36 ok Tue($x), "Tue() worked correctly ($x)";
37 ok $x.Tue, ".Tue() worked correctly ($x)";
38 #?rakudo skip 'unknown bug'
39 ok $x.Tue.WHAT, '$obj.Tue.WHAT returns a true valuee';
40 ok $x.Tue.perl, '$obj.Tue.perl returns a true valuee';
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
41 }
42
43 {
44 my $x = 1;
45 is $x, 1, "basic sanity (1)";
b7c9e84 [t/spec] delete some outdated tests in S12-enums/thorough.t and fix smar...
moritz authored
46 # L<S12/Enumerations/on the right side of a but or does.>
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
47 ok $x does day(Tue), "basic enum mixing worked (1-1)";
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
48 test_stuff($x);
49 }
50
51
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
52 #?rakudo skip 'does day::Tue'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
53 {
54 my $x = 3;
55 is $x, 3, "basic sanity (3)";
56 ok $x does day::Tue, "basic enum mixing worked (3-1)";
57 test_stuff($x);
58 }
59
7810f3e [t/spec] Tweak and mostly fudge S12-enums/thorough.t.
jnthn authored
60 #?DOES 16
61 #?rakudo skip 'does &day::("Tue")'
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
62 {
63 my $x = 4;
64 is $x, 4, "basic sanity (4)";
b7c9e84 [t/spec] delete some outdated tests in S12-enums/thorough.t and fix smar...
moritz authored
65 # L<S12/Enumerations/Mixing in the full enumeration type produces a
66 # read-write attribute>
40a9f6b [spec] moved oo/enum.t to spec/
moritz authored
67 ok $x does day, "basic enum mixing worked (4-0)";
68 ok $x.day = &day::("Tue"), "basic enum mixing worked (4-1)";
69 test_stuff($x);
70 }
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
71
72 # 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
73 #?rakudo skip 'augment'
74 #?DOES 2
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
75 {
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
76 augment class Mu {
77 method f { 'inMu' };
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
78 }
79
4b71fc9 [t/spec] fix an "is also" that is giving STD fits
lwall authored
80 augment class Bool {
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
81 method f { 'inBool' };
82 }
83 is True.f, 'inBool', 'method on short name pick up the one from the enum';
84 is Bool::True.f, 'inBool', 'method on long name pick up the one from the enum';
85 }
86
df3f661 [t/spec] fudge an "augment" test for rakudo; try to test the same with e...
moritz authored
87 ok True.perl ~~/^ 'Bool::True'/, 'True.perl';
88 ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
89
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
90 {
91 enum Negation << :isnt<isnt> :arent<arent> :amnot<amnot> :aint<aint> >>;
92 my Negation $foo;
93 #?rakudo todo 'Null PMC Access in invoke()'
94 lives_ok { $foo = Negation::isnt }, 'simple assignment from enum';
fcf1024 [t/spec] More revisions of past tests
kyle authored
95 #?rakudo skip 'Null PMC Access in invoke()'
96 is $foo, Negation::isnt, 'assignment from enum works';
caf2d4b [t/spec] Another Null PMC test inspired by IRC
kyle authored
97 }
98
9feb346 [t/spec] Test for RT #66886
kyle authored
99 # RT #66886
100 {
101 enum RT66886 <b>;
8bf9bb9 fix RT #66886 test, thanks to TimToady++
kyle authored
102 eval_dies_ok 'RT66886::c', 'accessing non-value of enum dies proper-like';
9feb346 [t/spec] Test for RT #66886
kyle authored
103 }
104
1223acd [t/spec] Test for RT 65658
kyle authored
105 # RT #65658
106 {
107 enum RT65658 <Todo Bug Feature Ticket>;
108 #?rakudo 2 skip 'RT 65658'
109 is RT65658(2), RT65658::Feature, 'can index enum by number';
110 is RT65658((Todo + 3.2).Int), RT65658::Ticket, 'enum and math and index';
111 }
112
e76dd4c Moritz Lenz s/done_testing/done/ as per recent S24 changes
moritz authored
113 done;
1223acd [t/spec] Test for RT 65658
kyle authored
114
43a7b3d [t/spec] RT #64098, methods on enums
moritz authored
115 # vim: ft=perl6
Something went wrong with that request. Please try again.