aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl')
-rw-r--r--Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl b/Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl
new file mode 100644
index 000000000..aae3e4dcb
--- /dev/null
+++ b/Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+BEGIN { use_ok('cpp11_move_typemaps') }
+require_ok('cpp11_move_typemaps');
+
+{
+ cpp11_move_typemaps::Counter::reset_counts();
+ my $mo = new cpp11_move_typemaps::MoveOnly(111);
+ cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 0, 0, 0);
+ cpp11_move_typemaps::MoveOnly::take($mo);
+ cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
+ undef $mo;
+}
+cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
+
+{
+ cpp11_move_typemaps::Counter::reset_counts();
+ my $mo = new cpp11_move_typemaps::MovableCopyable(111);
+ cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 0, 0, 0);
+ cpp11_move_typemaps::MovableCopyable::take($mo);
+ cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
+ undef $mo;
+}
+cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
+
+{
+ my $mo = new cpp11_move_typemaps::MoveOnly(222);
+ cpp11_move_typemaps::MoveOnly::take($mo);
+ eval {
+ cpp11_move_typemaps::MoveOnly::take($mo);
+ };
+ like($@, qr/\bcannot release ownership as memory is not owned\b/, "double usage of takeKlassUniquePtr should be an error");
+}