summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2015-02-20 14:27:41 +0100
committerBenoit Foucher <benoit@zeroc.com>2015-02-20 14:27:41 +0100
commitaf1544e7b81e8708c5fdee05a59328558a3030fe (patch)
tree0933eb39159b8cf714aab7fe5901d0515674d7c6 /py
parentSimplification to Atomic usage (diff)
downloadice-af1544e7b81e8708c5fdee05a59328558a3030fe.tar.bz2
ice-af1544e7b81e8708c5fdee05a59328558a3030fe.tar.xz
ice-af1544e7b81e8708c5fdee05a59328558a3030fe.zip
Fix for ICE-6268, initialize enum, string and structs in Java/C#/Objective-C/JavaScript
Diffstat (limited to 'py')
-rw-r--r--py/test/Ice/defaultValue/AllTests.py39
-rw-r--r--py/test/Ice/defaultValue/Test.ice55
2 files changed, 90 insertions, 4 deletions
diff --git a/py/test/Ice/defaultValue/AllTests.py b/py/test/Ice/defaultValue/AllTests.py
index af38110db4a..bc529c4b90e 100644
--- a/py/test/Ice/defaultValue/AllTests.py
+++ b/py/test/Ice/defaultValue/AllTests.py
@@ -41,7 +41,7 @@ def allTests():
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test.Struct2()
test(v.boolTrue == Test.ConstBool)
test(v.b == Test.ConstByte)
@@ -63,7 +63,7 @@ def allTests():
test(v.zeroDotF == Test.ConstZeroDotF)
test(v.zeroD == Test.ConstZeroD)
test(v.zeroDotD == Test.ConstZeroDotD)
-
+
v = Test.Base()
test(not v.boolFalse)
test(v.boolTrue)
@@ -81,7 +81,7 @@ def allTests():
test(v.zeroDotF == 0)
test(v.zeroD == 0)
test(v.zeroDotD == 0)
-
+
v = Test.Derived()
test(not v.boolFalse)
test(v.boolTrue)
@@ -149,3 +149,36 @@ def allTests():
test(v.zeroDotD == 0)
print("ok")
+
+ sys.stdout.write("testing default constructor... ")
+ sys.stdout.flush()
+ v = Test.StructNoDefaults()
+ test(v.bo == False)
+ test(v.b == 0)
+ test(v.s == 0)
+ test(v.i == 0)
+ test(v.l == 0)
+ test(v.f == 0.0)
+ test(v.d == 0.0)
+ test(v.str == '')
+ test(v.c1 == Test.Color.red)
+ test(v.bs is None)
+ test(v.iseq is None)
+ test(isinstance(v.st, Test.InnerStruct));
+ test(v.dict is None);
+
+ e = Test.ExceptionNoDefaults()
+ test(e.str == '')
+ test(e.c1 == Test.Color.red)
+ test(e.bs is None)
+ test(isinstance(e.st, Test.InnerStruct));
+ test(e.dict is None);
+
+ c = Test.ClassNoDefaults()
+ test(c.str == '')
+ test(c.c1 == Test.Color.red)
+ test(c.bs is None)
+ test(isinstance(c.st, Test.InnerStruct));
+ test(c.dict is None);
+
+ print("ok")
diff --git a/py/test/Ice/defaultValue/Test.ice b/py/test/Ice/defaultValue/Test.ice
index 49126d9265a..101a42883f3 100644
--- a/py/test/Ice/defaultValue/Test.ice
+++ b/py/test/Ice/defaultValue/Test.ice
@@ -21,6 +21,7 @@ enum Color { red, green, blue };
};
+
struct Struct1
{
bool boolFalse = false;
@@ -77,7 +78,7 @@ struct Struct2
long l = ConstLong;
float f = ConstFloat;
double d = ConstDouble;
- string str = ConstString;
+ string str = ConstString;
Color c1 = ConstColor1;
Color c2 = ConstColor2;
Color c3 = ConstColor3;
@@ -152,4 +153,56 @@ exception DerivedEx extends BaseEx
Nested::Color nc3 = ConstNestedColor3;
};
+sequence<byte> ByteSeq;
+sequence<int> IntSeq;
+dictionary<int, string> IntStringDict;
+
+struct InnerStruct
+{
+ int a;
+};
+
+struct StructNoDefaults
+{
+ bool bo;
+ byte b;
+ short s;
+ int i;
+ long l;
+ float f;
+ double d;
+ string str;
+ Color c1;
+ ByteSeq bs;
+ IntSeq iseq;
+ IntStringDict dict;
+ InnerStruct st;
+};
+
+exception ExceptionNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+exception ExceptionNoDefaults extends ExceptionNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
+class ClassNoDefaultsBase
+{
+ string str;
+ Color c1;
+ ByteSeq bs;
+};
+
+class ClassNoDefaults extends ClassNoDefaultsBase
+{
+ InnerStruct st;
+ IntStringDict dict;
+};
+
};