Updated test case for naming rules.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8468 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Charlie Savage 2006-01-16 10:46:25 +00:00
commit bc1629d3ed
2 changed files with 97 additions and 37 deletions

View file

@ -3,29 +3,49 @@
%predicate predicateMethod();
%bang bangMethod();
/* This gets mapped to a constant */
%constant int constant1 = 1;
/* This gets mapped to a constant */
%constant bool constant1 = false;
%immutable TestConstants::constant4;
#define constant2 2
%immutable TestConstants::constant8;
%inline %{
/* ============ Test Constants Names ============== */
typedef enum {One, Two, Three, Four, Five} finger;
const char BeginString_FIX44a[8] = "FIX.a.a";
/* This gets mapped to a constant */
#define constant3 3
/* These are all singleton methods */
const int constant4[2] = {10, 20};
const int constant5 = 5;
static const int constant6 = 6;
class TestConstants {
public:
/* This gets mapped to a method */
const int constant7;
/* This gets mapped to a singleton method, but this is not legal C++ */
static const int constant8;
/* This gets mapped to a method, but this it not legal C++ */
/*const int constant9 = 9;*/
/* This gets mapped to a constant */
static const int constant2 = 1;
const char *constant3;
const char *constant4;
static const int constant10 = 10;
};
const TestConstants * constant4[5];
const int constant5[2] = {10, 20};
const int TestConstants::constant8 = 8;
const TestConstants * constant11[5];
/* ============ Test Enum ============== */
typedef enum {Red, Green, Blue} Colors;
/* ============ Test Method Names ============== */

View file

@ -1,6 +1,6 @@
require 'naming'
# Check class names
if not Naming
raise RuntimeError, 'Invalid module name for Naming'
end
@ -10,33 +10,73 @@ if not Naming::MyClass
end
# Check constant names / values
if Naming::CONSTANT1 != 1
raise RuntimeError, "Incorrect value for CONSTANT1"
end
if Naming::CONSTANT2 != 2
raise RuntimeError, "Incorrect value for CONSTANT2"
end
# Check constant names / values
if Naming::CONSTANT3 != 3
raise RuntimeError, "Incorrect value for CONSTANT3"
end
if not Naming::methods.include?("constant4")
raise RuntimeError, "Incorrect mapping for constant4"
end
if not Naming::methods.include?("constant5")
raise RuntimeError, "Incorrect mapping for constant5"
end
if not Naming::methods.include?("constant6")
raise RuntimeError, "Incorrect mapping for constant6"
end
if not Naming::TestConstants.instance_methods.include?("constant7")
raise RuntimeError, "Incorrect mapping for constant7"
end
if not Naming::TestConstants.methods.include?("constant8")
raise RuntimeError, "Incorrect mapping for constant8"
end
# There is no constant9 because it is illegal C++
#if not Naming::TestConstants.instance_methods.include?("constant9")
# raise RuntimeError, "Incorrect mapping for constant9"
#end
if Naming::TestConstants::CONSTANT10 != 10
raise RuntimeError, "Incorrect value for CONSTANT10"
end
if not Naming::methods.include?("constant11")
raise RuntimeError, "Incorrect mapping for constant11"
end
# Check enums
if Naming::constants.include?("Color")
raise RuntimeError, "Color enum should not be exposed to Ruby"
end
if Naming::RED != 0
raise RuntimeError, "Incorrect value for enum RED"
end
if Naming::GREEN != 1
raise RuntimeError, "Incorrect value for enum GREEN"
end
if Naming::BLUE != 2
raise RuntimeError, "Incorrect value for enum BLUE"
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
my_class = Naming::MyClass.new()
if my_class.method_one != 1