- Timestamp:
- 10/25/08 11:19:58 (3 months ago)
- Location:
- t
- Files:
-
- 1 modified
- 1 moved
-
oo/methods/class.t (modified) (1 diff)
-
spec/S12-attributes/class2.t (moved) (moved from t/oo/attributes/class.t) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
t/oo/methods/class.t
r20490 r22749 24 24 # NOTE: 25 25 # this dies for the wrong reason actually 26 #?pugs todo 'class methods' 26 27 dies_ok { 27 28 $val = $foo.bar(42); 28 }, '... class methods should not work for instances' , :todo<feature>;29 }, '... class methods should not work for instances'; 29 30 } -
t/spec/S12-attributes/class2.t
r21719 r22749 12 12 #L<S12/Class methods/metaclass method always delegated> 13 13 14 plan 1 7;14 plan 14; 15 15 16 ok eval('class Foo { our $.bar = 23; our $.yada is rw = 13; }; 1'), 'class attributes are parsed'; 16 class Foo { 17 our $.bar = 23; 18 our $.yada is rw = 13; 19 } 17 20 18 21 my $test = 0; 19 ok eval('$test = Foo.bar'), 'accessors for class attributes work';22 ok $test = Foo.bar, 'accessors for class attributes work'; 20 23 is $test, 23, 'class attributes really work'; 21 24 22 ok eval('class Baz is Foo {}; 1'), 'inheriting class attributes parsed';25 class Baz is Foo {}; 23 26 24 27 my $test2 = 0; 25 ok eval('$test2 = Baz.bar'), 'inherited class attribute accessors work';28 lives_ok { $test2 = Baz.bar }, 'inherited class attribute accessors work'; 26 29 is $test2, 23, 'inherited class attributes really work'; 27 30 28 31 my $test3 = 0; 29 ok eval('Baz.yada = 42; $test3 = Baz.yada'), 'inherited rw class attribute accessors work';32 lives_ok { Baz.yada = 42; $test3 = Baz.yada }, 'inherited rw class attribute accessors work'; 30 33 is $test3, 42, 'inherited rw class attributes really work'; 31 34 32 ok eval('class Quux is Foo { has $.bar = 17; }; 1'), 33 'overriding with instance method allowed'; 35 class Quux is Foo { has $.bar = 17; }; 36 34 37 my $test4 = 0; 35 ok eval('$test4 = Quux.new()'), 38 #?pugs 99 todo 'class attributes' 39 lives_ok { $test4 = Quux.new() }, 36 40 'Can instantiate with overridden instance method'; 37 41 is $test4.bar, 17, 'Instance call gets instance attribute, not class attribute'; 38 42 my $test5 = 0; 39 ok eval('$test5 = Quux.bar'), 'class attribute still accessible via class name', :todo<feature>;40 is $test5, 23, 'class attribute really works, even when overridden' , :todo<feature>;43 lives_ok {$test5 = Quux.bar}, 'class attribute still accessible via class name'; 44 is $test5, 23, 'class attribute really works, even when overridden'; 41 45 my $test6 = 0; 42 ok eval('$test6 = Quux.^bar'), 'class attribute accessible via ^name', :todo<feature>;43 is $test6, 23, 'class attribute via ^name really works' , :todo<feature>;46 lives_ok { $test6 = Quux.^bar}, 'class attribute accessible via ^name'; 47 is $test6, 23, 'class attribute via ^name really works'; 44 48 my $test7 = 0; 45 ok eval('$test7 = $test4.^bar'),49 lives_ok {$test7 = $test4.^bar}, 46 50 'class attribute accessible via ^name called on instance', :todo<feature>; 47 51 is $test7, 23, 'class attribute via $obj.^name really works', :todo<feature>; 52 53 # vim: ft=perl6
