Catching up after the holidays.
[kakapo:kakapo.git] / t / Classes / Attributes.nqp
1 # Copyright (C) 2009, Austin Hastings. See accompanying LICENSE file, or 
2 # http://www.opensource.org/licenses/artistic-license-2.0.php for license.
3
4 sub main() {
5         Kakapo::Test::Class::Attributes.run_tests();
6         Program::exit(0);
7 }
8
9 module Kakapo;
10 sub library_name()              { 'kakapo_test.pbc' }
11
12 class Kakapo::Test::Class::Attributes
13         is Testcase;
14
15 INIT {
16         use(    'P6object');
17         use(    'Matcher::Factory');
18 }
19
20 method Xtest_attribute_accessors() {
21 say("Test accessors");
22         my $obj := Kakapo::Test::Aclass.new();
23
24         $obj.a("apple");
25         $obj.b("banana");
26         
27         say("Attributes set");
28         self.assert_that('test object.a', $obj.a, is("apple"));
29         self.assert_that('test object.b', $obj.b, is("banana"));
30 }
31
32 method test_initializer() {
33         #my $obj := Kakapo::Test::Aclass.new(:a('albatross'), :b('byzantine'), :c('chrysanthemum'));
34         my %named := Hash::new(:a('albatross'), :b('byzantine'));
35         Dumper::DUMP_(%named);
36         %named := Hash::empty();
37         Dumper::DUMP_(%named);
38         %named<a> := 'albatross';
39         %named<b> := 'byzantine';
40         Dumper::DUMP_(%named);
41         my $obj := Parrot::call_method_(Kakapo::Test::Aclass, 'new', Array::empty(), %named);
42
43         self.assert_that('test object.a', $obj.a, is("albatross"));
44         self.assert_that('test object.b', $obj.b, is("byzantine"));
45 }
46
47 module Kakapo::Test::Aclass;
48
49 INIT {
50         use(            'P6object');
51         extends(         'Kakapo::Object');
52         has(            'b a');
53 }