Continue the work on the wrap
[scilab.git] / scilab / modules / external_objects_java / tests / unit_tests / jwrap.dia.ref
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 myString=jwrap("foo");
8 assert_checkequal(jgetclassname(myString),"java.lang.String");
9 a=jwrap(2);
10 assert_checkequal(typeof(a),"_EObj");
11 assert_checkequal(jgetclassname(a),"double");
12 b=junwrap(a);
13 assert_checkequal(typeof(b),"constant");
14 c = jcompile("Test", ["public class Test {";
15     "public int[] returnArrayInt() {";
16     "    return new int[]{1,2,3,4};";
17     "}";
18     "}";]);
19 t = c.new();
20 assert_checkequal(jgetclassname(c),"Test");
21 assert_checkequal(int32([1,2,3,4]), t.returnArrayInt());
22 c = jcompile("Test", ["public class Test {";
23     "public int returnInt() {";
24     "    return 32;";
25     "}";
26     "}";]);
27 t = c.new();
28 assert_checkequal(jgetclassname(c),"Test");
29 assert_checkequal(int32(32), t.returnInt());
30 //////////////////////////////////////////////
31 c = jcompile("Test", ["public class Test {";
32     "public double[] returnDouble() {";
33     "    return new double[]{1,2,3,4};";
34     "}";
35     "}";]);
36 t = c.new();
37 assert_checkequal(jgetclassname(c),"Test");
38 assert_checkequal([1,2,3,4], t.returnDouble());
39 c = jcompile("Test", ["public class Test {";
40     "public double returnDouble() {";
41     "    return 32;";
42     "}";
43     "}";]);
44 t = c.new();
45 assert_checkequal(jgetclassname(c),"Test");
46 assert_checkequal(32, t.returnDouble());
47 //////////////////////////////////////////////
48 c = jcompile("Test", ["public class Test {";
49     "public byte[] returnByte() {";
50     "    return new byte[]{1,2,3,4};";
51     "}";
52     "}";]);
53 t = c.new();
54 assert_checkequal(jgetclassname(c),"Test");
55 assert_checkequal(int8([1,2,3,4]), t.returnByte());
56 c = jcompile("Test", ["public class Test {";
57     "public byte returnByte() {";
58     "    return 32;";
59     "}";
60     "}";]);
61 t = c.new();
62 assert_checkequal(jgetclassname(c),"Test");
63 assert_checkequal(int8(32), t.returnByte());
64 //////////////////////////////////////////////
65 c = jcompile("Test", ["public class Test {";
66     "public short[] returnShort() {";
67     "    return new short[]{1,2,3,4};";
68     "}";
69     "}";]);
70 t = c.new();
71 assert_checkequal(jgetclassname(c),"Test");
72 assert_checkequal(int16([1,2,3,4]), t.returnShort());
73 c = jcompile("Test", ["public class Test {";
74     "public short returnShort() {";
75     "    return 32;";
76     "}";
77     "}";]);
78 t = c.new();
79 assert_checkequal(jgetclassname(c),"Test");
80 assert_checkequal(int16(32), t.returnShort());
81 //////////////////////////////////////////////
82 // c = jcompile("Test", ["public class Test {";
83 //     "public long[] returnLong() {";
84 //     "    return new long[]{1L,2L,3L,4L};";
85 //     "}";
86 //     "}";]);
87 // t = c.new();
88 // assert_checkequal(jgetclassname(c),"Test");
89 // assert_checkequal(int16([1,2,3,4]), t.returnLong());
90 // c = jcompile("Test", ["public class Test {";
91 //     "public long returnLong() {";
92 //     "    return 32L;";
93 //     "}";
94 //     "}";]);
95 // t = c.new();
96 // assert_checkequal(jgetclassname(c),"Test");
97 // assert_checkequal(int16(32), t.returnLong());
98 //////////////////////////////////////////////
99 // c = jcompile("Test", ["public class Test {";
100 //     "public float[] returnFloat() {";
101 //     "    return new float[]{1f,2f,3f,4f};";
102 //     "}";
103 //     "}";]);
104 // t = c.new();
105 // assert_checkequal(jgetclassname(c),"Test");
106 // assert_checkequal(int16([1,2,3,4]), t.returnFloat());
107 // c = jcompile("Test", ["public class Test {";
108 //     "public float returnFloat() {";
109 //     "    return 32f;";
110 //     "}";
111 //     "}";]);
112 // t = c.new();
113 // assert_checkequal(jgetclassname(c),"Test");
114 // assert_checkequal(int16(32), t.returnFloat());
115 //////////////////////////////////////////////
116 // c = jcompile("Test", ["public class Test {";
117 //     "public char[] returnChar() {";
118 //     "    return new char[]{''a'',''b'',''c'',''d''};";
119 //     "}";
120 //     "}";]);
121 // t = c.new();
122 // assert_checkequal(jgetclassname(c),"Test");
123 // assert_checkequal(['a','b','c','d'], t.returnChar());
124 // c = jcompile("Test", ["public class Test {";
125 //     "public char returnChar() {";
126 //     "    return ''a'';";
127 //     "}";
128 //     "}";]);
129 // t = c.new();
130 // assert_checkequal(jgetclassname(c),"Test");
131 // assert_checkequal(int16(32), t.returnChar());
132 //
133 //////////////////////////////////////////////
134 c = jcompile("Test", ["public class Test {";
135     "public boolean[] returnBoolean() {";
136     "    return new boolean[]{true,true,false,false};";
137     "}";
138     "}";]);
139 t = c.new();
140 assert_checkequal(jgetclassname(c),"Test");
141 assert_checkequal([%t,%t,%f,%f], t.returnBoolean());
142 c = jcompile("Test", ["public class Test {";
143     "public boolean returnBoolean() {";
144     "    return true;";
145     "}";
146     "}";]);
147 t = c.new();
148 assert_checkequal(jgetclassname(c),"Test");
149 assert_checkequal(%t, t.returnBoolean());