diff Lib/IMPL/Test.pm @ 0:03e58a454b20

Создан репозитарий
author Sergey
date Tue, 14 Jul 2009 12:54:37 +0400
parents
children 2e546a5175dd
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Test.pm	Tue Jul 14 12:54:37 2009 +0400
@@ -0,0 +1,32 @@
+package IMPL::Test;
+use strict;
+use warnings;
+
+require Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT_OK = qw(&test &shared);
+
+require IMPL::Test::Unit;
+use IMPL::Class::Member;
+
+sub test($$) {
+    my ($name,$code) = @_;
+    my $class = caller;
+    
+    $class->set_meta(
+        new IMPL::Test::Unit::TestInfo( $name, $code )
+    );
+}
+
+sub shared($) {
+    my ($propInfo) = @_;
+    
+    my $class = caller;
+    
+    die new IMPL::Exception("Only properties could be declared as shared",$propInfo->Name) unless eval {$propInfo->isa('IMPL::Class::PropertyInfo')};
+    die new IMPL::Exception("You can't mark the readonly property as shared",$propInfo->Name) unless $propInfo->canSet;
+    die new IMPL::Exception("Only public properties could be declared as shared",$propInfo->Name) unless $propInfo->Access == IMPL::Class::Member::MOD_PUBLIC;
+    
+    $class->set_meta(new IMPL::Test::Unit::SharedData($propInfo->Name));
+}
+1;