[perl-Glib-Object-Introspection] Add tests for boxed objects



commit ad5d4cfc1df64a45aa539d9ef010db1e812148a8
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Tue Aug 16 20:03:29 2011 +0200

    Add tests for boxed objects

 Makefile.PL    |   32 ++++++++++----------
 t/boxed.t      |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 t/inc/setup.pl |    8 ++++-
 3 files changed, 113 insertions(+), 17 deletions(-)
---
diff --git a/Makefile.PL b/Makefile.PL
index 2d3da0c..1c18919 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -136,22 +136,22 @@ sub compile_test_libraries {
                    1>/dev/null 2>/dev/null))
     && !system (qq(g-ir-compiler Regress-1.0.gir -o Regress-1.0.typelib \\
                    1>/dev/null 2>/dev/null))
-    #&& !system (qq(gcc -shared \\
-    #               $glib_flags{cflags} $glib_flags{libs} \\
-    #               $testsdir/gimarshallingtests.c \\
-    #               -o libgimarshallingtests.so 1>/dev/null 2>/dev/null))
-    #&& !system (qq(LD_LIBRARY_PATH=$build_dir \\
-    #               g-ir-scanner \\
-    #               --include=GObject-2.0 \\
-    #               --namespace=GIMarshallingTests \\
-    #               --symbol-prefix=gi_marshalling_tests --nsversion=1.0 \\
-    #               --quiet --warn-all --warn-error \\
-    #               --library=gimarshallingtests \\
-    #               --output=GIMarshallingTests-1.0.gir \\
-    #               $testsdir/gimarshallingtests.h $testsdir/gimarshallingtests.c \\
-    #               1>/dev/null 2>/dev/null))
-    #&& !system (qq(g-ir-compiler GIMarshallingTests-1.0.gir \\
-    #               -o GIMarshallingTests-1.0.typelib 1>/dev/null 2>/dev/null))
+    && !system (qq(gcc -shared \\
+                   $glib_flags{cflags} $glib_flags{libs} \\
+                   $testsdir/gimarshallingtests.c \\
+                   -o libgimarshallingtests.so 1>/dev/null 2>/dev/null))
+    && !system (qq(LD_LIBRARY_PATH=$build_dir \\
+                   g-ir-scanner \\
+                   --include=GObject-2.0 \\
+                   --namespace=GIMarshallingTests \\
+                   --symbol-prefix=gi_marshalling_tests --nsversion=1.0 \\
+                   --quiet --warn-all --warn-error \\
+                   --library=gimarshallingtests \\
+                   --output=GIMarshallingTests-1.0.gir \\
+                   $testsdir/gimarshallingtests.h $testsdir/gimarshallingtests.c \\
+                   1>/dev/null 2>/dev/null))
+    && !system (qq(g-ir-compiler GIMarshallingTests-1.0.gir \\
+                   -o GIMarshallingTests-1.0.typelib 1>/dev/null 2>/dev/null))
   };
 
   print $success ? "OK\n" : "not OK\n";
diff --git a/t/boxed.t b/t/boxed.t
new file mode 100644
index 0000000..a311005
--- /dev/null
+++ b/t/boxed.t
@@ -0,0 +1,90 @@
+#!/usr/bin/env perl
+
+BEGIN { require './t/inc/setup.pl' };
+
+use strict;
+use warnings;
+use Scalar::Util qw/weaken/;
+
+plan tests => 33;
+
+{
+  my $boxed = GI::BoxedStruct->new;
+  isa_ok ($boxed, 'GI::BoxedStruct');
+  weaken $boxed;
+  is ($boxed, undef);
+}
+
+{
+  my $boxed = GI::BoxedStruct::returnv ();
+  isa_ok ($boxed, 'GI::BoxedStruct');
+  $boxed->inv;
+  weaken $boxed;
+  is ($boxed, undef);
+  # make sure we haven't destroyed the static object
+  isa_ok (GI::BoxedStruct::returnv (), 'GI::BoxedStruct');
+  isa_ok (GI::BoxedStruct::returnv ()->copy, 'GI::BoxedStruct');
+}
+
+{
+  my $boxed = GI::BoxedStruct::out ();
+  isa_ok ($boxed, 'GI::BoxedStruct');
+  weaken $boxed;
+  is ($boxed, undef);
+  # make sure we haven't destroyed the static object
+  isa_ok (GI::BoxedStruct::out (), 'GI::BoxedStruct');
+  isa_ok (GI::BoxedStruct::out ()->copy, 'GI::BoxedStruct');
+}
+
+{
+  my $boxed = GI::BoxedStruct::inout (GI::BoxedStruct::out ());
+  isa_ok ($boxed, 'GI::BoxedStruct');
+  weaken $boxed;
+  is ($boxed, undef);
+}
+
+# --------------------------------------------------------------------------- #
+
+{
+  my $boxed = TestSimpleBoxedA::const_return ();
+  isa_ok ($boxed, 'TestSimpleBoxedA');
+  isa_ok ($boxed, 'Glib::Boxed');
+  my $copy = $boxed->copy;
+  ok ($boxed->equals ($copy));
+  weaken $boxed;
+  is ($boxed, undef);
+  weaken $copy;
+  is ($copy, undef);
+}
+
+{
+  my $boxed = TestBoxed->new;
+  isa_ok ($boxed, 'TestBoxed');
+  isa_ok ($boxed, 'Glib::Boxed');
+  my $copy = $boxed->copy;
+  isa_ok ($boxed, 'TestBoxed');
+  isa_ok ($boxed, 'Glib::Boxed');
+  ok ($boxed->equals ($copy));
+  weaken $boxed;
+  is ($boxed, undef);
+  weaken $copy;
+  is ($copy, undef);
+
+  $boxed = TestBoxed->new_alternative_constructor1 (23);
+  isa_ok ($boxed, 'TestBoxed');
+  isa_ok ($boxed, 'Glib::Boxed');
+  weaken $boxed;
+  is ($boxed, undef);
+
+  $boxed = TestBoxed->new_alternative_constructor2 (23, 42);
+  isa_ok ($boxed, 'TestBoxed');
+  isa_ok ($boxed, 'Glib::Boxed');
+  weaken $boxed;
+  is ($boxed, undef);
+
+  $boxed = TestBoxed->new_alternative_constructor3 ("perl");
+  isa_ok ($boxed, 'TestBoxed');
+  isa_ok ($boxed, 'Glib::Boxed');
+  weaken $boxed;
+  is ($boxed, undef);
+}
diff --git a/t/inc/setup.pl b/t/inc/setup.pl
index fcdefa1..7e59113 100644
--- a/t/inc/setup.pl
+++ b/t/inc/setup.pl
@@ -1,7 +1,7 @@
 use Glib::Object::Introspection;
 use Test::More;
 
-unless (-e 'build/libregress.so') {
+unless (-e 'build/libregress.so' && -e 'build/libgimarshallingtests.so') {
   plan skip_all => 'Need the test libraries';
 }
 
@@ -17,6 +17,12 @@ Glib::Object::Introspection->setup(
   package => 'main',
   search_path => 'build');
 
+Glib::Object::Introspection->setup(
+  basename => 'GIMarshallingTests',
+  version => '1.0',
+  package => 'GI',
+  search_path => 'build');
+
 # Inspired by Test::Number::Delta
 sub delta_ok ($$;$) {
   my ($a, $b, $msg) = @_;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]