ACIL FM
Dark
Refresh
Current DIR:
/home/.cpan/build/AppConfig-1.71-0/t
/
home
.cpan
build
AppConfig-1.71-0
t
Upload
Zip Selected
Delete Selected
Pilih semua
Nama
Ukuran
Permission
Aksi
97-pod.t
289 B
chmod
View
DL
Edit
Rename
Delete
99_author.t
1.48 MB
chmod
View
DL
Edit
Rename
Delete
appconfig.t
1.84 MB
chmod
View
DL
Edit
Rename
Delete
args.t
2.32 MB
chmod
View
DL
Edit
Rename
Delete
block.t
2.14 MB
chmod
View
DL
Edit
Rename
Delete
cgi.t
1.94 MB
chmod
View
DL
Edit
Rename
Delete
compact.t
3.02 MB
chmod
View
DL
Edit
Rename
Delete
const.t
1.23 MB
chmod
View
DL
Edit
Rename
Delete
default.t
2.7 MB
chmod
View
DL
Edit
Rename
Delete
file.t
8.04 MB
chmod
View
DL
Edit
Rename
Delete
flag.t
2.13 MB
chmod
View
DL
Edit
Rename
Delete
getopt.t
2.15 MB
chmod
View
DL
Edit
Rename
Delete
multi.t
2.98 MB
chmod
View
DL
Edit
Rename
Delete
novars.t
2.18 MB
chmod
View
DL
Edit
Rename
Delete
state.t
4.71 MB
chmod
View
DL
Edit
Rename
Delete
sys.t
1.68 MB
chmod
View
DL
Edit
Rename
Delete
Edit file: /home/.cpan/build/AppConfig-1.71-0/t/state.t
#!/usr/bin/perl -w #======================================================================== # # t/state.t # # AppConfig::State test file. # # Written by Andy Wardley <abw@cre.canon.co.uk> # # Copyright (C) 1998 Canon Research Centre Europe Ltd. # All Rights Reserved. # # This is free software; you can redistribute it and/or modify it # under the same terms as Perl itself. # #======================================================================== use strict; use vars qw($loaded); BEGIN { $| = 1; print "1..45\n"; } END { ok(0) unless $loaded; } my $ok_count = 1; sub ok { shift or print "not "; print "ok $ok_count\n"; ++$ok_count; } use AppConfig qw(:argcount); use AppConfig::State; $loaded = 1; ok(1); #------------------------------------------------------------------------ # define variables and handler subs # my $default = "<default>"; my $none = "<none>"; my $user = 'abw'; my $age = 29; my $verbose = 0; my $errors = 0; # user validation routine sub check_user { my $var = shift; my $val = shift; return ($val eq $user); } # verbose action routine sub verbose { my $state = shift; my $var = shift; my $val = shift; # set global $verbose so we can test that this sub was called $verbose = $val; # ok return 1; } sub error { my $format = shift; my @args = @_; $errors++; } #------------------------------------------------------------------------ # define a new AppConfig::State object # my $state = AppConfig::State->new({ ERROR => \&error, GLOBAL => { DEFAULT => $default, ARGCOUNT => ARGCOUNT_ONE, }, }, 'verbose', { DEFAULT => 0, ACTION => \&verbose, ARGCOUNT => ARGCOUNT_NONE, }, 'user', { ALIAS => 'name|uid', VALIDATE => \&check_user, DEFAULT => $none, }, 'age', { VALIDATE => '\d+', }); # $state->_dump(); #------------------------------------------------------------------------ # check and manipulate variables # #2: check state got defined ok( defined $state ); #3 - #5: check default values ok( $state->verbose() == 0 ); ok( $state->user() eq $none ); ok( $state->age() eq $default ); #6 - #8: check ARGCOUNT got set explicitly or by default ok( $state->_argcount('verbose') == 0 ); ok( $state->_argcount('user') == 1 ); ok( $state->_argcount('age') == 1 ); #9 - #11: set values ok( $state->verbose(1) ); ok( $state->user($user) ); ok( $state->age($age) ); #12 - #14: read them back to check values got set correctly ok( $state->verbose() == 1 ); ok( $state->user() eq $user ); ok( $state->age() == $age ); #15: test that the verbose ACTION was called and $verbose set ok( $verbose == 1 ); #16 - #19: test the VALIDATE patterns/subs by attempting to set invalid values ok( ! $state->age('old') ); ok( $state->age() == $age ); ok( ! $state->user('dud') ); ok( $state->user() eq $user ); #20: check that the error handler correctly updated $errors ok( $errors == 2 ); #21 - #22: access variables via alias ok( $state->name() eq $user ); ok( $state->uid() eq $user ); #23 - #25: test case insensitivity ok( $state->USER() eq $user ); ok( $state->NAME() eq $user ); ok( $state->UID() eq $user ); #26 - #27: explicitly test get() and set() methods ok( $state->set('verbose', 100) ); ok( $state->get('verbose') == 100 ); #------------------------------------------------------------------------ # define a different AppConfig::State object # my $newstate = AppConfig::State->new({ CASE => 1, CREATE => '^define_', PEDANTIC => 1, ERROR => \&error, }); #28: check state got defined ok( defined $newstate ); #29 - #30: test CASE sensitivity $errors = 0; ok( ! $newstate->Foo() ); ok( $errors ); #31 - #32: test PEDANTIC mode is/isn't set in states ok( ! $state->_pedantic() ); ok( $newstate->_pedantic() ); #33 - #34: test auto-creation of define_ variable ok( $newstate->define_user($user) ); ok( $newstate->define_user() eq $user ); #------------------------------------------------------------------------ # define a third AppConfig::State object to test compact format # my $thirdstate = AppConfig::State->new("foo|bar|baz=s"); #35: check state got defined ok( defined $thirdstate ); $thirdstate->define("tom|dick|harry=i@"); $thirdstate->define("red|green|blue=s"); #36 - #42: check set()/get() for foo and aliases ok( $thirdstate->foo(5) ); ok( $thirdstate->foo() == 5 ); ok( $thirdstate->bar(6) ); ok( $thirdstate->bar() == 6 ); ok( $thirdstate->baz(7) ); ok( $thirdstate->baz() == 7 ); ok( $thirdstate->foo() == 7 ); #43 - #45: check ARGCOUNT for all vars ok( $thirdstate->_args('foo') eq '=s' ); ok( $thirdstate->_args('tom') eq '=i@' ); ok( $thirdstate->_args('red') eq '=s' );
Simpan
Batal
Isi Zip:
Unzip
Create
Buat Folder
Buat File
Terminal / Execute
Run
Chmod Bulk
All File
All Folder
All File dan Folder
Apply