diff _test/Test/Class/Meta.pm @ 90:dc1da0389db7

Small improvements in the abstract object class Added support for a class data, documentation Additional tests for the new functionality
author wizard
date Mon, 26 Apr 2010 03:10:03 +0400
parents
children 76515373dac0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/_test/Test/Class/Meta.pm	Mon Apr 26 03:10:03 2010 +0400
@@ -0,0 +1,57 @@
+use strict;
+
+package Test::Class::Meta;
+use base qw(IMPL::Test::Unit);
+
+__PACKAGE__->PassThroughArgs;
+
+use IMPL::Test qw(test failed);
+
+test defineFooClassData => sub {
+	Foo->class_data(info => {});	
+};
+
+test updateFooClassData => sub {
+	Foo->class_data('info')->{data} = 'Foo' ;
+};
+
+test getFooClassData => sub {
+	failed "Wrong class data", "Expected: Foo", "Got: ".Foo->class_data('info')->{data}  unless Foo->class_data('info')->{data} eq 'Foo';
+};
+
+test getBazClassData => sub {
+	failed "Wrong class data", "Expected: Foo", "Got: ".Baz->class_data('info')->{data}  unless Baz->class_data('info')->{data} eq 'Foo';
+};
+
+test updateBarClassData => sub {
+	Bar->class_data('info')->{data} = 'Bar';
+};
+
+test getBarClassData => sub {
+	failed "Wrong class data", "Expected: Bar", "Got: ".Bar->class_data('info')->{data}  unless Bar->class_data('info')->{data} eq 'Bar';
+};
+
+test validatetFooClassData => sub {
+	failed "Wrong class data", "Expected: Foo", "Got: ".Foo->class_data('info')->{data}  unless Foo->class_data('info')->{data} eq 'Foo';
+};
+
+test validateBazClassData => sub {
+	failed "Wrong class data", "Expected: Foo", "Got: ".Baz->class_data('info')->{data}  unless Baz->class_data('info')->{data} eq 'Foo';
+};
+
+test getwrongBazClassData => sub {
+	failed "Wrong class data", "Expected: undef", "Got: ".Foo->class_data( 'info2' ) if Foo->class_data( 'info2' );
+};
+
+
+
+package Foo;
+use base qw(IMPL::Class::Meta);
+
+package Bar;
+use base qw(Foo);
+
+package Baz;
+use base qw(Foo);
+
+1;