Change in default behaviour wrapping C++ bool for Python.
Only a Python True or False will now work for C++ bool parameters. This fixes overloading bool with other types.
This commit is contained in:
parent
7f45cbd178
commit
504c2030bb
11 changed files with 251 additions and 11 deletions
88
Examples/test-suite/ruby/overload_bool_runme.rb
Executable file
88
Examples/test-suite/ruby/overload_bool_runme.rb
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put description here
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
require 'swig_assert'
|
||||
|
||||
require 'overload_bool'
|
||||
|
||||
include Overload_bool
|
||||
|
||||
# Overloading bool, int, string
|
||||
if overloaded(true) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded(false) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded(0) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded(1) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded(2) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded("1234") != "string"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
# Test bool masquerading as integer
|
||||
# Not possible
|
||||
|
||||
# Test int masquerading as bool
|
||||
if boolfunction(0) != "false"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction(1) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction(2) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
#############################################
|
||||
|
||||
# Overloading bool, int, string
|
||||
if overloaded_ref(true) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded_ref(false) != "bool"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded_ref(0) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded_ref(1) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if overloaded_ref(2) != "int"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
if overloaded_ref("1234") != "string"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
|
||||
# Test bool masquerading as integer
|
||||
# Not possible
|
||||
|
||||
# Test int masquerading as bool
|
||||
if boolfunction_ref(0) != "false"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction_ref(1) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
if boolfunction_ref(2) != "true"
|
||||
raise RuntimeError, "wrong!"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue