New Ruby test case for checking renames, predicate methods, bang methods and constants.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8445 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
de0b9ba295
commit
ca4e7fc8df
3 changed files with 127 additions and 1 deletions
|
|
@ -16,7 +16,8 @@ CPP_TEST_CASES = \
|
|||
track_objects_directors \
|
||||
primitive_types \
|
||||
li_cdata \
|
||||
li_cstring
|
||||
li_cstring \
|
||||
naming
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cdata \
|
||||
|
|
@ -27,7 +28,12 @@ include $(srcdir)/../common.mk
|
|||
# Overridden variables here
|
||||
SWIGOPT += -noautorename
|
||||
|
||||
|
||||
# Rules for the different types of tests
|
||||
|
||||
# make sure -autorename is true for the naming test
|
||||
naming.cpptest: SWIGOPT = -autorename
|
||||
|
||||
%.cpptest:
|
||||
$(setup) \
|
||||
($(swig_and_compile_cpp); ) &&\
|
||||
|
|
|
|||
46
SWIG/Examples/test-suite/ruby/naming.i
Normal file
46
SWIG/Examples/test-suite/ruby/naming.i
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
%module naming
|
||||
|
||||
%predicate predicateMethod();
|
||||
%bang bangMethod();
|
||||
|
||||
%inline %{
|
||||
|
||||
|
||||
class my_class {
|
||||
public:
|
||||
static const int const1 = 1;
|
||||
|
||||
my_class() {}
|
||||
|
||||
int methodOne()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MethodTwo()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int Method_THREE()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
int Method44_4()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
bool predicateMethod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bangMethod()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
%}
|
||||
74
SWIG/Examples/test-suite/ruby/naming_runme.rb
Normal file
74
SWIG/Examples/test-suite/ruby/naming_runme.rb
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
require 'naming'
|
||||
|
||||
|
||||
if not Naming
|
||||
raise RuntimeError, 'Invalid module name for Naming'
|
||||
end
|
||||
|
||||
if not Naming::MyClass
|
||||
raise RuntimeError, 'Invalid class name for MyClass'
|
||||
end
|
||||
|
||||
# Check constant names
|
||||
if not Naming::MyClass::CONST1
|
||||
raise RuntimeError, 'Invalid constant name for CONST1'
|
||||
end
|
||||
|
||||
|
||||
# Check method names
|
||||
if not Naming::MyClass.instance_methods.include?('method_one')
|
||||
raise RuntimeError, 'Invalid method name for method_one'
|
||||
end
|
||||
|
||||
if not Naming::MyClass.instance_methods.include?('method_two')
|
||||
raise RuntimeError, 'Invalid method name for method_two'
|
||||
end
|
||||
|
||||
if not Naming::MyClass.instance_methods.include?('method_three')
|
||||
raise RuntimeError, 'Invalid method name for method_three'
|
||||
end
|
||||
|
||||
if not Naming::MyClass.instance_methods.include?('method44_4')
|
||||
raise RuntimeError, 'Invalid method name for method44_4'
|
||||
end
|
||||
|
||||
# Check predicate methods
|
||||
if not Naming::MyClass.instance_methods.include?('predicate_method?')
|
||||
raise RuntimeError, 'Invalid method name for predicate_method?'
|
||||
end
|
||||
|
||||
# Check bang methods
|
||||
if not Naming::MyClass.instance_methods.include?('bang_method!')
|
||||
raise RuntimeError, 'Invalid method name for bang_method!'
|
||||
end
|
||||
|
||||
# Run all these methods as a sanity check
|
||||
if Naming::MyClass::CONST1 != 1
|
||||
raise RuntimeError, "Incorrect value for CONST1"
|
||||
end
|
||||
|
||||
my_class = Naming::MyClass.new()
|
||||
|
||||
if my_class.method_one != 1
|
||||
raise RuntimeError, "Incorrect value for method_one"
|
||||
end
|
||||
|
||||
if my_class.method_two != 2
|
||||
raise RuntimeError, "Incorrect value for method_two"
|
||||
end
|
||||
|
||||
if my_class.method_three != 3
|
||||
raise RuntimeError, "Incorrect value for method_three"
|
||||
end
|
||||
|
||||
if my_class.method44_4 != 4
|
||||
raise RuntimeError, "Incorrect value for method44_4"
|
||||
end
|
||||
|
||||
if my_class.predicate_method? != true
|
||||
raise RuntimeError, "Incorrect value for predicate_method?"
|
||||
end
|
||||
|
||||
if my_class.bang_method! != true
|
||||
raise RuntimeError, "Incorrect value for bang_method!"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue