Commits

Herbert Breunung  committed cb20e8b

more app util tests

  • Participants
  • Parent commits 97d86e6

Comments (0)

Files changed (6)

File t/200-app-util.t

+#!usr/bin/perl
+
+# making local lib favoured
+BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
+
+use Test::More tests => 26  ;
+#use Text::Exception;
+use Test::NoWarnings;
+
+use Wx;
+use Kephra::App::Util qw(is_widget is_panel is_sizer is_color is_font create_color lounch_browser);
+
+# testing the function that gives references to the helper functions
+my $testcolor = Kephra::App::Util::get('is_color');
+my @chref = Kephra::App::Util::get('is_color', 'create_color');
+is( $testcolor, \&Kephra::App::Util::is_color, 'get a helper function reference');
+is_deeply( \@chref, [ \&Kephra::App::Util::is_color, \&Kephra::App::Util::create_color ], 
+    'get several helper references');
+is_deeply( \@chref, [ \&is_color, \&create_color ], 'import via Exporter works too');
+my $color = $chref[1];
+
+
+my $text  = Wx::StaticText->new( undef, -1, '');
+my $btn   = Wx::Button->new( undef, -1, '');
+my $panel = Wx::Panel->new( undef );
+my $sizer = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
+
+
+# object type checker
+is( is_widget(0),      0, 'can detect that a number is not widget');
+is( is_widget([]),     0, 'can detect that ref is not a widget');
+is( is_widget($sizer), 0, 'can detect that sizer is not a widget');
+is( is_widget($text),  1, 'can detect what is a widget');
+is( is_widget($panel), 1, 'panel are widgets too');
+
+is( is_panel(0),       0, 'can detect what is not a panel');
+is( is_panel({}),      0, 'can detect that a ref is not a panel');
+is( is_panel($sizer),  0, 'can detect that sizer is not a panel');
+is( is_panel($panel),  1, 'can detect what is a panel');
+
+is( is_sizer(3),       0, 'can detect that number are no sizer');
+is( is_sizer(sub{}),   0, 'can detect that ref are no sizer');
+is( is_sizer($panel),  0, 'can detect that panel are no sizer');
+is( is_sizer($sizer),  1, 'can detect what is a sizer');
+
+
+
+# color helper
+my $white = Wx::Colour->new(255, 255, 255);
+is( is_color(0),                     0, 'can detect what is not a color object');
+is( is_color($white),                1, 'can detect what is a color object');
+is( $testcolor->($white),            1, 'refernce works too');
+is( is_color( $color->(0,0,255) ),   1, 'R,G,B input layout works ');
+is( is_color( $color->("0,0,255") ), 1, '"R,G,B" input layout works');
+is( is_color( $color->("#0000FF") ), 1, '"#RRGGBB" input layout works');
+is( is_color( $color->("0000ff") ),  1, '"RRGGBB" input layout works');
+is( is_color( $color->("blue") ),    1, '"colorname" input layout works');
+is( is_color( $color->("WHEAT") ),   1, '"colorname" input layout works with db names');
+
+exit(0);
+

File t/200-apputil.t

-#!usr/bin/perl
-
-# making local lib favoured
-BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
-
-use Test::More tests => 12  ;
-#use Text::Exception;
-use Test::NoWarnings;
-
-use Wx;
-use Kephra::App::Util;
-
-# testing the function that gives references to the helper functions
-my $testcolor = Kephra::App::Util::get('is_color');
-my @chref = Kephra::App::Util::get('is_color', 'create_color');
-is( $testcolor, \&Kephra::App::Util::is_color, 'get a helper function reference');
-is_deeply( \@chref, [ \&Kephra::App::Util::is_color, \&Kephra::App::Util::create_color ], 
-    'get several helper references');
-my $mk_color = $chref[1];
-
-# color helper
-my $white = Wx::Colour->new(255, 255, 255);
-is( Kephra::App::Util::is_color(0),      0, 'can detect what is not a color object');
-is( Kephra::App::Util::is_color($white), 1, 'can detect what is a color object');
-is( $testcolor->($white), 1, 'refernce works too');
-is( $testcolor->( $mk_color->(0,0,255) ), 1, 'R,G,B input layout works ');
-is( $testcolor->( $mk_color->("0,0,255") ), 1, '"R,G,B" input layout works');
-is( $testcolor->( $mk_color->("#0000FF") ), 1, '"#RRGGBB" input layout works');
-is( $testcolor->( $mk_color->("0000ff") ), 1, '"RRGGBB" input layout works');
-is( $testcolor->( $mk_color->("blue") ), 1,'"colorname" input layout works');
-is( $testcolor->( $mk_color->("WHEAT") ), 1,'"colorname" input layout works with db names');
-
-exit(0);
-

File t/610-api-command.t

+#!usr/bin/perl
+
+# making local lib favoured
+BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
+
+package probe;
+use Test::More tests => 14;
+use Test::NoWarnings;
+
+use Wx;
+use Kephra;
+use Kephra::App::Util;
+
+Kephra::load_libs();
+
+sub one     { 'one' }
+sub true    { 'true' }
+sub color   { Kephra::App::Util::create_color("blue") }
+sub channel { $_[0] }
+
+
+eval { Kephra::API::Command::register_namespace('test') };
+is($@, '', 'registered cmd namespace');
+
+eval { Kephra::API::Command::register_context_var('color') };
+is($@, '', 'registered package switch var');
+
+eval { Kephra::API::Command::register_switch_var({ '$color' => 'color'}) };
+is($@, '', 'registered named switch var');
+
+eval { Kephra::API::Command::register({
+		'test-one' => {sub => 'probe::one', label => 'one'},
+		   '+-true'=> {sub => 'true', label => 'true'},
+		   '+-blue'=> {sub => '$_->IsOk', label => 'blue', help => 'help'},
+		   '+-gc'=>   {sub => '$color->IsOk', label => 'gc'},
+		   '+-chan'=> {sub => 'channel', label => 'channel', parameter => 4},
+})};
+is($@, '', 'registered command');
+
+eval { Kephra::API::Command::init() };
+is($@, '', 'initialized command list');
+
+
+my $data = Kephra::API::Command::all_properties('test-one');
+is(ref $data, 'HASH', 'command entry created');
+is($data->{'label'}, 'one', 'command data stored');
+is( Kephra::API::Command::run('test-one'), 'one', 'run command');
+
+my $data = Kephra::API::Command::all_properties('test-true');
+is(ref $data, 'HASH', 'command ID prefix completion');
+is( Kephra::API::Command::run('test-true'), 'true', 'sub prefix completion (module name)');
+is( Kephra::API::Command::run('test-blue'), 1, 'package switch var substitution');
+is( Kephra::API::Command::run('test-gc'), 1, 'named switch var substitution');
+is( Kephra::API::Command::run('test-chan'), 4, 'parameter insertion');
+
+
+exit(0);

File t/610-commandlist.t

-#!usr/bin/perl
-
-# making local lib favoured
-BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
-
-package probe;
-use Test::More tests => 14;
-use Test::NoWarnings;
-
-use Wx;
-use Kephra;
-use Kephra::App::Util;
-
-Kephra::load_libs();
-
-sub one     { 'one' }
-sub true    { 'true' }
-sub color   { Kephra::App::Util::create_color("blue") }
-sub channel { $_[0] }
-
-
-eval { Kephra::API::Command::register_namespace('test') };
-is($@, '', 'registered cmd namespace');
-
-eval { Kephra::API::Command::register_context_var('color') };
-is($@, '', 'registered package switch var');
-
-eval { Kephra::API::Command::register_switch_var({ '$color' => 'color'}) };
-is($@, '', 'registered named switch var');
-
-eval { Kephra::API::Command::register({
-		'test-one' => {sub => 'probe::one', label => 'one'},
-		   '+-true'=> {sub => 'true', label => 'true'},
-		   '+-blue'=> {sub => '$_->IsOk', label => 'blue', help => 'help'},
-		   '+-gc'=>   {sub => '$color->IsOk', label => 'gc'},
-		   '+-chan'=> {sub => 'channel', label => 'channel', parameter => 4},
-})};
-is($@, '', 'registered command');
-
-eval { Kephra::API::Command::init() };
-is($@, '', 'initialized command list');
-
-
-my $data = Kephra::API::Command::all_properties('test-one');
-is(ref $data, 'HASH', 'command entry created');
-is($data->{'label'}, 'one', 'command data stored');
-is( Kephra::API::Command::run('test-one'), 'one', 'run command');
-
-my $data = Kephra::API::Command::all_properties('test-true');
-is(ref $data, 'HASH', 'command ID prefix completion');
-is( Kephra::API::Command::run('test-true'), 'true', 'sub prefix completion (module name)');
-is( Kephra::API::Command::run('test-blue'), 1, 'package switch var substitution');
-is( Kephra::API::Command::run('test-gc'), 1, 'named switch var substitution');
-is( Kephra::API::Command::run('test-chan'), 4, 'parameter insertion');
-
-
-exit(0);

File t/620-api-keymap.t

+#!usr/bin/perl
+
+# making local lib favoured
+BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
+
+package probe;
+use Test::More tests => 1;
+use Test::NoWarnings;
+
+#use Wx;
+#use Kephra::App::Util;
+#use Kephra::KeyMap;
+
+#sub one     { 1 }
+#sub true    { 'true' }
+#sub color   { Kephra::App::Util::create_color("blue") }
+#sub channel { $_[0] }
+#
+#
+#eval { Kephra::CommandList::register_cmd_namespace('test') };
+#is($@, '', 'registered cmd namespace');
+#
+#eval { Kephra::CommandList::register_switch_var('color') };
+#is($@, '', 'registered package switch var');
+#
+#eval { Kephra::CommandList::register_switch_var({ '$color' => 'color'}) };
+#is($@, '', 'registered named switch var');
+#
+#eval { Kephra::CommandList::register_cmd({
+		#'test-one' => {sub => 'probe::one', label => 'one'},
+		    #'-true'=> {sub => 'true', label => 'true'},
+		    #'-blue'=> {sub => '$_->IsOk', label => 'blue', help => 'help'},
+		    #'-gc'=>   {sub => '$color->IsOk', label => 'gc'},
+		    #'-chan'=> {sub => 'channel', label => 'channel', parameter => 4},
+#})};
+#is($@, '', 'registered command');
+#
+#eval { Kephra::CommandList::init() };
+#is($@, '', 'initialized command list');
+#
+#
+#my $data = Kephra::CommandList::cmd_all_properties('test-one');
+#is(ref $data, 'HASH', 'command entry created');
+#is($data->{'label'}, 'one', 'command data stored');
+#is( Kephra::CommandList::run_cmd('test-one'), 1, 'run command');
+#
+#my $data = Kephra::CommandList::cmd_all_properties('test-true');
+#is(ref $data, 'HASH', 'command ID prefix completion');
+#is( Kephra::CommandList::run_cmd('test-true'), 'true', 'sub prefix completion (module name)');
+#is( Kephra::CommandList::run_cmd('test-blue'), 1, 'package switch var substitution');
+#is( Kephra::CommandList::run_cmd('test-gc'), 1, 'named switch var substitution');
+#is( Kephra::CommandList::run_cmd('test-chan'), 4, 'parameter insertion');
+
+
+exit(0);

File t/620-keymap.t

-#!usr/bin/perl
-
-# making local lib favoured
-BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }
-
-package probe;
-use Test::More tests => 1;
-use Test::NoWarnings;
-
-#use Wx;
-#use Kephra::App::Util;
-#use Kephra::KeyMap;
-
-#sub one     { 1 }
-#sub true    { 'true' }
-#sub color   { Kephra::App::Util::create_color("blue") }
-#sub channel { $_[0] }
-#
-#
-#eval { Kephra::CommandList::register_cmd_namespace('test') };
-#is($@, '', 'registered cmd namespace');
-#
-#eval { Kephra::CommandList::register_switch_var('color') };
-#is($@, '', 'registered package switch var');
-#
-#eval { Kephra::CommandList::register_switch_var({ '$color' => 'color'}) };
-#is($@, '', 'registered named switch var');
-#
-#eval { Kephra::CommandList::register_cmd({
-		#'test-one' => {sub => 'probe::one', label => 'one'},
-		    #'-true'=> {sub => 'true', label => 'true'},
-		    #'-blue'=> {sub => '$_->IsOk', label => 'blue', help => 'help'},
-		    #'-gc'=>   {sub => '$color->IsOk', label => 'gc'},
-		    #'-chan'=> {sub => 'channel', label => 'channel', parameter => 4},
-#})};
-#is($@, '', 'registered command');
-#
-#eval { Kephra::CommandList::init() };
-#is($@, '', 'initialized command list');
-#
-#
-#my $data = Kephra::CommandList::cmd_all_properties('test-one');
-#is(ref $data, 'HASH', 'command entry created');
-#is($data->{'label'}, 'one', 'command data stored');
-#is( Kephra::CommandList::run_cmd('test-one'), 1, 'run command');
-#
-#my $data = Kephra::CommandList::cmd_all_properties('test-true');
-#is(ref $data, 'HASH', 'command ID prefix completion');
-#is( Kephra::CommandList::run_cmd('test-true'), 'true', 'sub prefix completion (module name)');
-#is( Kephra::CommandList::run_cmd('test-blue'), 1, 'package switch var substitution');
-#is( Kephra::CommandList::run_cmd('test-gc'), 1, 'named switch var substitution');
-#is( Kephra::CommandList::run_cmd('test-chan'), 4, 'parameter insertion');
-
-
-exit(0);