Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 131 lines (116 sloc) 4.721 kb
ff2f9de @sorear Prototype of the Array class
authored
1 # vim: ft=perl6
2 use Test;
9f1bf0e @sorear Implement &sort
authored
3 use MONKEY_TYPING;
ff2f9de @sorear Prototype of the Array class
authored
4
ca4d6f1 @sorear Implement use of submethod BUILD
authored
5 {
6 my class Bt {
7 has $!pie;
8 method get_pie() { $!pie }
9 submethod BUILD(:$x) { $!pie = $x }
10 }
11 is Bt.new(x => 5).get_pie, 5, "BUILD basically works";
12 my class SubBT is Bt {
13 has $!pie2;
14 method get_pie2() { $!pie2 }
15 submethod BUILD(:$y) { $!pie2 = $y }
16 }
17 is SubBT.new(x => 5, y => 2).get_pie, 5, "superclass' BUILD in subclass";
18 is SubBT.new(x => 5, y => 2).get_pie2, 2, "subclass' BUILD in subclass";
904bb14 @sorear Fix binding to existing @vars
authored
19
20 my @l;
21 @l := [1,2,3];
22 is +[@l], 3, 'binding to existing list vars works';
ca4d6f1 @sorear Implement use of submethod BUILD
authored
23 }
24
44f7995 @sorear Steal ... and ...^ from Rakudo
authored
25 is [ 1,2,3 ... 10 ], [1..10];
26 is [ 1,2,4 ... 256 ], [map 2 ** *, 0..8];
27 is [ 1,1,*+* ...^ *>100 ], [1,1,2,3,5,8,13,21,34,55,89];
28
e51f7a9 @sorear [remove-CURLEX] Reimplementation of STD is_name
authored
29 eval_lives_ok q[
30 class F2855::G7136 { ... }
31 class F2855::G7136 { }
32 ], "can stub then define nested classes";
33
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
34 {
21aca01 @sorear Make for-loops work in blasts
authored
35 my @l = gather for 1,2 { take $_ };
36 is ~@l, "1 2", "gather for works";
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
37
2c21c29 @sorear Rewrite stash handling
authored
38 eval_dies_ok 'class { has $!foo; has $!foo; }',
39 "double attribute declaration caught";
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
40
2c21c29 @sorear Rewrite stash handling
authored
41 eval_dies_ok 'class { method abar {}; method abar {}; }',
42 "double method declaration caught";
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
43
44 # <chain> isn't tested here. It's not possible to do the same AST
45 # reconstruction tricks. However if <right> etc work, and chained
46 # comparisons work, it's pretty likely to work combinationally.
47 sub infix:<@a> { "a(@_.Str())" }
48 sub infix:<@b> is assoc<right> { "b(@_.Str())" }
49 sub infix:<@c> is assoc<list> { "c(@_.Str())" }
c835aaa @sorear Fixup assoc/tighter/equiv/looser tests; now fully working
authored
50 sub infix:<@d> is assoc<list> { "d(@_.Str())" } #OK not used
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
51 sub infix:<@e> is assoc<non> { "e(@_.Str())" }
52 sub infix:<@f> is assoc<left> { "f(@_.Str())" }
53
54 is (1 @a 2), 'a(1 2)', 'basic operator function';
55 is (1 @a 2 @a 3), 'a(a(1 2) 3)', 'operators default to left assoc';
56 is (1 @f 2 @f 3), 'f(f(1 2) 3)', 'explicit assoc<left> works too';
c835aaa @sorear Fixup assoc/tighter/equiv/looser tests; now fully working
authored
57 is (1 @f 2 @a 3), 'a(f(1 2) 3)', 'mixed <left> at same prec works (1)';
58 is (1 @a 2 @f 3), 'f(a(1 2) 3)', 'mixed <left> at same prec works (2)';
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
59 is (1 @b 2 @b 3), 'b(1 b(2 3))', 'assoc<right> overrides';
60 is (1 @c 2 @c 3), 'c(1 2 3)', 'assoc<list> takes all 3 at once';
61 eval_dies_ok q[1 @c 2 @d 3], 'mixed <list> at same prec dies';
62 eval_dies_ok q[1 @e 2 @e 3], '<non> dies with 3';
63 is (1 @e 2), 'e(1 2)', '<non> with 2 works';
64
c835aaa @sorear Fixup assoc/tighter/equiv/looser tests; now fully working
authored
65 sub infix:<@g> is tighter<@a> { "g(@_.Str())" } #OK not used
66 sub infix:<@h> is looser<@a> { "h(@_.Str())" } #OK not used
67 sub infix:<@i> is tighter(&infix:<@a>) { "i(@_.Str())" } #OK not used
68 sub infix:<@j> is looser(&infix:<@a>) { "j(@_.Str())" } #OK not used
69 sub infix:<@k> is tighter<@h> { "k(@_.Str())" } #OK not used
70 sub infix:<@l> is looser<@g> { "l(@_.Str())" } #OK not used
71 sub infix:<@m> is equiv<@a> { "m(@_.Str())" } #OK not used
72 sub infix:<@n> is equiv(&infix:<@a>) { "n(@_.Str())" } #OK not used
73 sub infix:<@o> is equiv<@g> { "o(@_.Str())" } #OK not used
74 sub infix:<@p> is equiv<@h> { "p(@_.Str())" } #OK not used
75 sub infix:<@q> is equiv<@b> { "q(@_.Str())" } #OK not used
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
76
77 my @cmptests = (
78 'a', 'g', 1, 0, 'tighter<> works',
79 'h', 'a', 1, 0, 'looser<> works',
80 'a', 'i', 1, 0, 'tighter<> works with code object',
81 'j', 'a', 1, 0, 'looser<> works with code object',
82 'h', 'k', 1, 0, 'tighter of a looser works',
83 'l', 'g', 1, 0, 'looser of a tighter works',
84 'k', 'a', 1, 0, 'tighter of a looser is still looser',
85 'a', 'l', 1, 0, 'looser of a tighter is still tighter',
86 'm', 'a', 0, 0, 'equiv works',
87 'n', 'a', 0, 0, 'equiv works with code object',
88 'o', 'g', 0, 0, 'equiv of tighter works',
89 'p', 'h', 0, 0, 'equiv of looser works',
90 'q', 'q', 1, 1, 'equiv also copies associativity',
91 );
c835aaa @sorear Fixup assoc/tighter/equiv/looser tests; now fully working
authored
92 sub ckb($res is copy) { #OK not used
93 $res ~~ s:g /<.alpha>//; #::
94 $res eq '((1 2) 3)' ?? 0 !! 1;
95 }
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
96 my @frags;
c835aaa @sorear Fixup assoc/tighter/equiv/looser tests; now fully working
authored
97 for @cmptests -> $lt, $gt, $right_br_ord, $right_br_opp, $msg {
98 push @frags, "is ckb(1 @$lt 2 @$gt 3), $right_br_ord, '$msg (1)';\n";
99 push @frags, "is ckb(1 @$gt 2 @$lt 3), $right_br_opp, '$msg (2)';\n";
dff3b35 @sorear 36 new tests for tighter/looser/equiv. tighter+looser is not tested,…
authored
100 }
101 eval @frags.join;
102 }
103
0fa6f23 @sorear Fix Foo::Bar regression
authored
104 #is $?ORIG.substr(0,5), '# vim', '$?ORIG works';
105
106 # {
107 # {
108 # our $x = 5; #OK
109 # }
110 # ok $::x == 5, '$::x finds our variable';
111 #
112 # package Fao { our $y = 6; } #OK
113 # ok $::Fao::y == 6, '$::Fao::y works as $Fao::y';
114 #
115 # { class Mao { } }
116 # ok ::Mao.new.defined, 'can use classes via ::Mao';
117 # }
118 #
119 # {
120 # my $x = 7; #OK
121 # ok $::x == 7, '$::x can find lexicals';
122 # class A3 {
123 # method moo { 42 }
124 # class B4 {
125 # ok ::A3.moo, '::A3 can find outer classes';
126 # }
127 # }
128 # }
ae2e557 @sorear Implement control operators next, redo, last, return
authored
129
025e408 @pmurias [Test.pm6] remove &done-testing and &done_testing
pmurias authored
130 done;
Something went wrong with that request. Please try again.