Fix external_objects_java module tests under Linux/Mac OS X
[scilab.git] / scilab / modules / external_objects_java / tests / unit_tests / jwrap.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7
8 exec("SCI/modules/external_objects_java/tests/unit_tests/ecjclasspath.sce", -1);
9
10 myString=jwrap("foo");
11 assert_checkequal(jgetclassname(myString),"java.lang.String");
12
13 a=jwrap(2);
14 assert_checkequal(typeof(a),"_EObj");
15 assert_checkequal(jgetclassname(a),"double");
16 b=junwrap(a);
17 assert_checkequal(typeof(b),"constant");
18
19
20 c = jcompile("Test", ["public class Test {";
21 "public int[] returnArrayInt() {";
22 "    return new int[]{1,2,3,4};";
23 "}";
24 "}";]);
25 t = c.new();
26 assert_checkequal(jgetclassname(c),"Test");
27 assert_checkequal(int32([1,2,3,4]), t.returnArrayInt());
28
29 c = jcompile("Test", ["public class Test {";
30 "public int returnInt() {";
31 "    return 32;";
32 "}";
33 "}";]);
34 t = c.new();
35 assert_checkequal(jgetclassname(c),"Test");
36 assert_checkequal(int32(32), t.returnInt());
37
38 //////////////////////////////////////////////
39
40 c = jcompile("Test", ["public class Test {";
41 "public double[] returnDouble() {";
42 "    return new double[]{1,2,3,4};";
43 "}";
44 "}";]);
45 t = c.new();
46 assert_checkequal(jgetclassname(c),"Test");
47 assert_checkequal([1,2,3,4], t.returnDouble());
48
49 c = jcompile("Test", ["public class Test {";
50 "public double returnDouble() {";
51 "    return 32;";
52 "}";
53 "}";]);
54 t = c.new();
55 assert_checkequal(jgetclassname(c),"Test");
56 assert_checkequal(32, t.returnDouble());
57
58 //////////////////////////////////////////////
59
60 c = jcompile("Test", ["public class Test {";
61 "public byte[] returnByte() {";
62 "    return new byte[]{1,2,3,4};";
63 "}";
64 "}";]);
65 t = c.new();
66 assert_checkequal(jgetclassname(c),"Test");
67 assert_checkequal(int8([1,2,3,4]), t.returnByte());
68
69 c = jcompile("Test", ["public class Test {";
70 "public byte returnByte() {";
71 "    return 32;";
72 "}";
73 "}";]);
74 t = c.new();
75 assert_checkequal(jgetclassname(c),"Test");
76 assert_checkequal(int8(32), t.returnByte());
77
78 //////////////////////////////////////////////
79
80 c = jcompile("Test", ["public class Test {";
81 "public short[] returnShort() {";
82 "    return new short[]{1,2,3,4};";
83 "}";
84 "}";]);
85 t = c.new();
86 assert_checkequal(jgetclassname(c),"Test");
87 assert_checkequal(int16([1,2,3,4]), t.returnShort());
88
89 c = jcompile("Test", ["public class Test {";
90 "public short returnShort() {";
91 "    return 32;";
92 "}";
93 "}";]);
94 t = c.new();
95 assert_checkequal(jgetclassname(c),"Test");
96 assert_checkequal(int16(32), t.returnShort());
97
98
99 //////////////////////////////////////////////
100
101 c = jcompile("Test", ["public class Test {";
102 "public long[] returnLong() {";
103 "    return new long[]{1L,2L,3L,4L};";
104 "}";
105 "}";]);
106 t = c.new();
107 assert_checkequal(jgetclassname(c),"Test");
108 assert_checkequal(int32([1,2,3,4]), t.returnLong());
109
110 c = jcompile("Test", ["public class Test {";
111 "public long returnLong() {";
112 "    return 32L;";
113 "}";
114 "}";]);
115 t = c.new();
116 assert_checkequal(jgetclassname(c),"Test");
117 assert_checkequal(int32(32), t.returnLong());
118
119 //////////////////////////////////////////////
120
121 c = jcompile("Test", ["public class Test {";
122 "public float[] returnFloat() {";
123 "    return new float[]{1f,2f,3f,4f};";
124 "}";
125 "}";]);
126 t = c.new();
127 assert_checkequal(jgetclassname(c),"Test");
128 assert_checkequal([1,2,3,4], t.returnFloat());
129
130 c = jcompile("Test", ["public class Test {";
131 "public float returnFloat() {";
132 "    return 32f;";
133 "}";
134 "}";]);
135 t = c.new();
136 assert_checkequal(jgetclassname(c),"Test");
137 assert_checkequal(32, t.returnFloat());
138
139
140 //////////////////////////////////////////////
141
142 // c = jcompile("Test", ["public class Test {";
143 //     "public char[] returnChar() {";
144 //     "    return new char[]{''a'',''b'',''c'',''d''};";
145 //     "}";
146 //     "}";]);
147 // t = c.new();
148 // assert_checkequal(jgetclassname(c),"Test");
149 // assert_checkequal(['a','b','c','d'], t.returnChar());
150
151 // c = jcompile("Test", ["public class Test {";
152 //     "public char returnChar() {";
153 //     "    return ''a'';";
154 //     "}";
155 //     "}";]);
156 // t = c.new();
157 // assert_checkequal(jgetclassname(c),"Test");
158 // assert_checkequal(int16(32), t.returnChar());
159
160
161
162 //////////////////////////////////////////////
163
164 c = jcompile("Test", ["public class Test {";
165 "public boolean[] returnBoolean() {";
166 "    return new boolean[]{true,true,false,false};";
167 "}";
168 "}";]);
169 t = c.new();
170 assert_checkequal(jgetclassname(c),"Test");
171 assert_checkequal([%t,%t,%f,%f], t.returnBoolean());
172
173 c = jcompile("Test", ["public class Test {";
174 "public boolean returnBoolean() {";
175 "    return true;";
176 "}";
177 "}";]);
178 t = c.new();
179 assert_checkequal(jgetclassname(c),"Test");
180 assert_checkequal(%t, t.returnBoolean());
181