Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Expand test 53 to test the inspection of the name,methods and attribu…
…tes of a knowhow.
  • Loading branch information
pmurias committed Jul 12, 2013
1 parent 55b72b0 commit 5669b32
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion t/nqp/53-knowhow.t
Expand Up @@ -8,7 +8,7 @@ knowhow Foo {
method get_bbq() { $!bbq }
}

plan(3);
plan(12);

ok(Foo.lol eq "yay, methods", "method calls on knowhow type object");

Expand All @@ -17,3 +17,25 @@ ok($x.lol eq "yay, methods", "method calls on knowhow instance");

$x.set_bbq("wurst");
ok($x.get_bbq eq "wurst", "attributes on knowhow instance");
ok(Foo.HOW.name(Foo), "getting the name using the HOW works correctly");

my $attrs := Foo.HOW.attributes(Foo);
ok($attrs[0].name eq '$!bbq',"we can get the attributes");

my $foo_attr := nqp::knowhowattr().new(:name('$!foo'));
ok($foo_attr.name eq '$!foo',"created attribute has correct name");

knowhow Bar {
has $!foo;
has $!bar;
method argh() {
}
}

my $methods := Foo.HOW.methods(Foo);
ok(nqp::existskey($methods,'lol'),'lol method exists in Foo.HOW.methods');
ok(nqp::existskey($methods,'new'),'new method exists in Foo.HOW.methods');
ok(nqp::existskey($methods,'set_bbq'),'set_bbq method exists in Foo.HOW.methods');
ok(nqp::existskey($methods,'get_bbq'),'get_bbq method exists in Foo.HOW.methods');
ok(!nqp::existskey($methods,'argh'),"argh doesn't exist in Foo.HOW.methods");
ok(nqp::existskey(Bar.HOW.methods(Bar),'argh'),'different knowhows have seperate method sets');

0 comments on commit 5669b32

Please sign in to comment.