[poe-commits] SF.net SVN: poe: [1981] trunk/poe/tests/10_units/03_base/02_api_ctl.t
Brought to you by:
rcaputo
From: <bs...@us...> - 2006-06-11 19:33:14
|
Revision: 1981 Author: bsmith Date: 2006-06-11 12:32:59 -0700 (Sun, 11 Jun 2006) ViewCVS: http://svn.sourceforge.net/poe/?rev=1981&view=rev Log Message: ----------- New tests for POE::API::Ctl. Added Paths: ----------- trunk/poe/tests/10_units/03_base/02_api_ctl.t Added: trunk/poe/tests/10_units/03_base/02_api_ctl.t =================================================================== --- trunk/poe/tests/10_units/03_base/02_api_ctl.t (rev 0) +++ trunk/poe/tests/10_units/03_base/02_api_ctl.t 2006-06-11 19:32:59 UTC (rev 1981) @@ -0,0 +1,38 @@ +#!perl -w + +use strict; + +use Test::More tests => 9; +use POE::Kernel; + +use_ok('POE::API::Ctl'); + +# should have exported 'poectl' +ok( *poectl{CODE} == *POE::API::Ctl::poectl{CODE}, "poectl exported" ); + +# poectl takes 0, 1 or 2 parameters +my $rv = do { local $SIG{__WARN__} = sub { }; + poectl('one', 'two', 'three', 'four') }; +ok( !defined($rv), "poectl fails when too many args used" ); + +is( poectl('kernel.id'), $poe_kernel->ID, "kernel.id" ); + +my $all = poectl(); +is( ref($all), 'HASH', 'returns a hash of settings' ); + +# pick a key at random +my $key = (keys %$all)[rand keys(%$all)]; +is( poectl($key), $all->{$key}, 'returns a single setting' ); + +# invalid keys +ok( !defined(poectl('this.does.not.exist')), 'non-existent key' ); + +# change something +poectl("testing", "testing"); +is( poectl('testing'), 'testing', 'changes a setting' ); + +# change something locked +poectl('kernel.id', 'shouldnotwork'); +is( poectl('kernel.id'), $poe_kernel->ID, "kernel.id locked" ); + +1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |