Changeset 3465
- Timestamp:
- 05/19/05 22:22:58 (4 years ago)
- svk:copy_cache_prev:
- 5016
- Files:
-
- 2 modified
-
src/Pugs/Eval.hs (modified) (1 diff)
-
t/oo/magical_vars.t (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Eval.hs
r3443 r3465 239 239 getMagical "$?MODULE" = constSym "main" 240 240 getMagical "$?OS" = constSym $ getConfig "osname" 241 getMagical "$?CLASS" = constSym =<< asks envPackage 242 getMagical "$?PACKAGE" = constSym =<< asks envPackage 241 243 getMagical _ = return Nothing 242 244 -
t/oo/magical_vars.t
r3304 r3465 4 4 use Test; 5 5 6 plan 9;6 plan 11; 7 7 8 8 class Foo { 9 9 method get_self() { $?SELF } 10 method get_class() { eval '$?CLASS' } 10 method get_class() { $?CLASS } 11 method get_package() { $?PACKAGE } 11 12 method dummy() { 42 } 12 13 } … … 14 15 role Bar { 15 16 method get_self() { $?SELF } 16 method get_class() { eval '$?CLASS' } 17 method get_role() { eval '$?ROLE' } 17 method get_class() { $?CLASS } 18 method get_role() { $?ROLE } 19 method get_package() { $?PACKAGE } 18 20 method dummy() { 42 } 19 21 } … … 24 26 my $foo_obj = Foo.new; 25 27 my $class = $foo_obj.get_class; 28 my $package = $foo_obj.get_package; 29 is( $package, 'Foo', '$?PACKAGE should be the package name' ); 26 30 27 is $class ~~ Foo, 'the thing returned by $?CLASS in our class smartmatches against our class';31 ok( $class ~~ Foo, 'the thing returned by $?CLASS in our class smartmatches against our class' ); 28 32 my $fourty_two; 29 33 lives_ok { $fourty_two = $class.new.dummy }, 30 'the class returned by $?CLASS in our class wa yreally our class (1)';34 'the class returned by $?CLASS in our class was really our class (1)'; 31 35 is $fourty_two, 42, 'the class returned by $?CLASS in our class way really our class (2)'; 32 36 } … … 42 46 my $bar = SimpleClass.new; 43 47 my $class = $bar.get_class; 48 my $package = $bar.get_package; 49 50 is( $package, 'SimpleClass', '$?PACKAGE should be the package name' ); 44 51 45 52 is $class ~~ SimpleClass, 'the thing returned by $?CLASS in our role smartmatches against our class';
