⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 01_object-accessor-subclassed.t

📁 source of perl for linux application,
💻 T
字号:
BEGIN { chdir 't' if -d 't' };use strict;use lib '../lib';use Test::More 'no_plan';use Data::Dumper;my $Class   = 'Object::Accessor';my $MyClass = 'My::Class';my $Acc     = 'foo';use_ok($Class);### establish another package that subclasses our own{   package My::Class;    use base 'Object::Accessor';}    my $Object  = $MyClass->new;### check the object{   ok( $Object,                "Object created" );    isa_ok( $Object,            $MyClass );    isa_ok( $Object,            $Class );}    ### create an accessor {   ok( $Object->mk_accessors( $Acc ),                                "Accessor '$Acc' created" );    ok( $Object->can( $Acc ),   "   Object can '$Acc'" );    ok( $Object->$Acc(1),       "   Objects '$Acc' set" );    ok( $Object->$Acc(),        "   Objects '$Acc' retrieved" );}        ### check if we do the right thing when we call an accessor that's### not a defined function in the base class, and not an accessors ### in the object either{   my $sub = eval { $MyClass->can( $$ ); };    ok( !$sub,                  "No sub from non-existing function" );    ok( !$@,                    "   Code handled it gracefully" );}    ### check if a method called on a class, that's not actually there### doesn't get confused as an object call;{   eval { $MyClass->$$ };    ok( $@,                     "Calling '$$' on '$MyClass' dies" );    like( $@, qr/from somewhere else/,                                "   Dies with an informative message" );}                                

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -