Commit bef74db6 authored by dobbyth33lf's avatar dobbyth33lf Committed by Torsten Schönfeld

Add helper functions Gtk3->get_version_info, Gtk3->GET_VERSION_INFO

https://bugzilla.gnome.org/show_bug.cgi?id=795778
parent ecf075af
......@@ -507,15 +507,27 @@ sub import {
# - Overrides --------------------------------------------------------------- #
=item * For backwards compatibility, C<Gtk3::CHECK_VERSION>,
C<Gtk3::check_version>, C<Gtk3::init>, C<Gtk3::init_check>, C<Gtk3::main>,
C<Gtk3::main_level> and C<Gtk3::main_quit> can be called as class-static or as
normal functions: for example, C<< Gtk3->main_quit >> and C<< Gtk3::main_quit
>> are both supported. Additionally, C<Gtk3::init> and C<Gtk3::init_check>
automatically handle passing and updating C<@ARGV> as appropriate.
=item * For backwards compatibility, the functions C<Gtk3::get_version_info>
and C<Gtk3::GET_VERSION_INFO> are provided, and the functions
C<Gtk3::CHECK_VERSION>, C<Gtk3::check_version>, C<Gtk3::init>,
C<Gtk3::init_check>, C<Gtk3::main>, C<Gtk3::main_level> and C<Gtk3::main_quit>
can be called as class-static or as normal functions: for example, C<<
Gtk3->main_quit >> and C<< Gtk3::main_quit >> are both supported.
Additionally, C<Gtk3::init> and C<Gtk3::init_check> automatically handle
passing and updating C<@ARGV> as appropriate.
=cut
sub Gtk3::get_version_info {
return Gtk3::get_major_version (),
Gtk3::get_minor_version (),
Gtk3::get_micro_version ();
}
sub Gtk3::GET_VERSION_INFO {
return Gtk3->MAJOR_VERSION, Gtk3->MINOR_VERSION, Gtk3->MICRO_VERSION;
}
sub Gtk3::CHECK_VERSION {
return not defined Gtk3::check_version(@_ == 4 ? @_[1..3] : @_);
}
......
......@@ -17,12 +17,7 @@ unless (eval { Gtk3->import; 1 }) {
}
}
plan tests => 3;
diag (sprintf 'Testing against gtk+ %d.%d.%d',
Gtk3::get_major_version (),
Gtk3::get_minor_version (),
Gtk3::get_micro_version ());
plan tests => 16;
SKIP: {
@ARGV = qw(--help --name gtk2perl --urgs tree);
......@@ -42,3 +37,27 @@ SKIP: {
eval { my $b = Gtk3::LinkButton->new; };
like ($@, qr/00-init\.t/);
}
my @run_version = Gtk3->get_version_info;
my @compile_version = Gtk3->GET_VERSION_INFO;
diag 'Testing Gtk3 ', $Gtk3::VERSION;
diag ' Running against gtk+ ', join '.', @run_version;
diag ' Compiled against gtk+ ', join '.', @compile_version;
is (@run_version, 3, 'version info is three items long' );
is (Gtk3->check_version(0,0,0), 'GTK+ version too new (major mismatch)',
'check_version fail 1');
is (Gtk3->check_version(3,0,0), undef, 'check_version pass');
is (Gtk3->check_version(50,0,0), 'GTK+ version too old (major mismatch)',
'check_version fail 2');
ok (defined (Gtk3::get_major_version()), 'major_version');
ok (defined (Gtk3::get_minor_version()), 'minor_version');
ok (defined (Gtk3::get_micro_version()), 'micro_version');
is (@compile_version, 3, 'version info is three items long');
ok (Gtk3->CHECK_VERSION(3,0,0), 'CHECK_VERSION pass');
ok (!Gtk3->CHECK_VERSION(50,0,0), 'CHECK_VERSION fail');
is (Gtk3->MAJOR_VERSION, $compile_version[0], 'MAJOR_VERSION');
is (Gtk3->MINOR_VERSION, $compile_version[1], 'MINOR_VERSION');
is (Gtk3->MICRO_VERSION, $compile_version[2], 'MICRO_VERSION');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment