diff options
Diffstat (limited to 'Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb')
-rw-r--r-- | Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb b/Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb new file mode 100644 index 000000000..d2c9fe3df --- /dev/null +++ b/Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +require 'swig_assert' + +require 'cpp11_move_typemaps' + +Cpp11_move_typemaps::Counter.reset_counts() +mo = Cpp11_move_typemaps::MoveOnly.new(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) +mo = nil +Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 1, 0, 2) + +Cpp11_move_typemaps::Counter.reset_counts() +mo = Cpp11_move_typemaps::MovableCopyable.new(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) +mo = nil +Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 1, 0, 2) + +mo = Cpp11_move_typemaps::MoveOnly.new(222) +Cpp11_move_typemaps::MoveOnly.take(mo) +exception_thrown = false +begin + Cpp11_move_typemaps::MoveOnly.take(mo) +rescue RuntimeError => e + if (!e.to_s.include? "cannot release ownership as memory is not owned") + raise RuntimeError, "incorrect exception message: #{e.to_s}" + end + exception_thrown = true +end +if (!exception_thrown) + raise RuntimeError, "Should have thrown 'Cannot release ownership as memory is not owned' error" +end |