Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add tests for ${^CALLER}

  • Loading branch information...
commit 4f8999c643280703947c93c8f3bc83453f16359c 1 parent e380c57
Stevan Little authored
View
8 t/200-meta/003-localized-vars-in-class.t
@@ -11,18 +11,23 @@ is(undef, ${^SELF}, '... no value for ${^SELF} in main script');
is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script');
is(undef, ${^META}, '... no value for ${^META} in main script');
+is(undef, ${^CALLER}, '... no value for ${^CALLER} in main script');
class Foo {
is(mop::get_meta('Foo'), ${^META}, '... got the metaclass as expected (in the class body)');
is(mop::get_meta('Foo'), ${^CLASS}, '... got the metaclass as expected (in the class body)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in class body');
+ is(undef, ${^CALLER}, '... no value for ${^CALLER} in class body');
method bar {
is($class, 'Foo', '... got the value for $class we expected');
is($self, ${^SELF}, '... got the invocant as expected');
is(mop::get_meta('Foo'), ${^CLASS}, '... got the metaclass as expected (in the method)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in method');
+ is($self, ${^CALLER}->[0], '... got the right values in ${^CALLER}');
+ is('bar', ${^CALLER}->[1], '... got the right values in ${^CALLER}');
+ is(mop::get_meta('Foo'), ${^CALLER}->[2], '... got the right values in ${^CALLER}');
}
}
@@ -30,6 +35,7 @@ is(undef, ${^SELF}, '... no value for ${^SELF} in main script (after class crea
is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script (after class creation)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script (after class creation)');
is(undef, ${^META}, '... no value for ${^META} in main script (after class creation)');
+is(undef, ${^CALLER}, '... no value for ${^CALLER} in main script (after class creation)');
my $Foo = mop::get_meta('Foo');
@@ -41,6 +47,7 @@ $Foo->add_method(
is($self, ${^SELF}, '... got the invocant as expected');
is($Foo, ${^CLASS}, '... got the metaclass as expected (in the method)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in method');
+ is(undef, ${^CALLER}, '... no value for ${^CALLER} in method installed via add_method');
}
)
);
@@ -57,5 +64,6 @@ is(undef, ${^SELF}, '... no value for ${^SELF} in main script (after method exe
is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script (after method execution)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script (after method execution)');
is(undef, ${^META}, '... no value for ${^META} in main script (after method execution)');
+is(undef, ${^CALLER}, '... no value for ${^CALLER} in main script (after method execution)');
done_testing;
View
22 t/200-meta/004-localized-vars-in-roles.t
@@ -11,25 +11,31 @@ is(undef, ${^SELF}, '... no value for ${^SELF} in main script');
is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script');
is(undef, ${^META}, '... no value for ${^META} in main script');
+is(undef, ${^CALLER}, '... no value for ${^CALLER} in main script');
role Foo {
- is(mop::get_meta('Foo'), ${^META}, '... got the metaclass as expected (in the class body)');
- is(mop::get_meta('Foo'), ${^ROLE}, '... got the metaclass as expected (in the class body)');
- is(undef, ${^CLASS}, '... no value for ${^CLASS} in class body');
+ is(mop::get_meta('Foo'), ${^META}, '... got the metaclass as expected (in the role body)');
+ is(mop::get_meta('Foo'), ${^ROLE}, '... got the metaclass as expected (in the role body)');
+ is(undef, ${^CLASS}, '... no value for ${^CLASS} in role body');
+ is(undef, ${^CALLER}, '... no value for ${^CALLER} in role body');
method bar {
is($class, 'Foo', '... got the value for $class we expected');
is($self, ${^SELF}, '... got the invocant as expected');
is(mop::get_meta('Bar'), ${^CLASS}, '... got the metaclass as expected (in the method)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in method');
+ is($self, ${^CALLER}->[0], '... got the right values in ${^CALLER}');
+ is('bar', ${^CALLER}->[1], '... got the right values in ${^CALLER}');
+ is(mop::get_meta('Foo'), ${^CALLER}->[2], '... got the right values in ${^CALLER}');
}
}
-is(undef, ${^SELF}, '... no value for ${^SELF} in main script (after class creation)');
-is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script (after class creation)');
-is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script (after class creation)');
-is(undef, ${^META}, '... no value for ${^META} in main script (after class creation)');
+is(undef, ${^SELF}, '... no value for ${^SELF} in main script (after role creation)');
+is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script (after role creation)');
+is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script (after role creation)');
+is(undef, ${^META}, '... no value for ${^META} in main script (after role creation)');
+is(undef, ${^CALLER}, '... no value for ${^CALLER} in main script (after role creation)');
my $Foo = mop::get_meta('Foo');
@@ -41,6 +47,7 @@ $Foo->add_method(
is($self, ${^SELF}, '... got the invocant as expected');
is(mop::get_meta('Bar'), ${^CLASS}, '... got the metaclass as expected (in the method)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in method');
+ is(undef, ${^CALLER}, '... no value for ${^CALLER} in method installed via add_method');
}
)
);
@@ -60,5 +67,6 @@ is(undef, ${^SELF}, '... no value for ${^SELF} in main script (after method exe
is(undef, ${^CLASS}, '... no value for ${^CLASS} in main script (after method execution)');
is(undef, ${^ROLE}, '... no value for ${^ROLE} in main script (after method execution)');
is(undef, ${^META}, '... no value for ${^META} in main script (after method execution)');
+is(undef, ${^CALLER}, '... no value for ${^CALLER} in main script (after method execution)');
done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.