* Add more tests 51/11951/2
Sylvestre Ledru [Fri, 5 Jul 2013 09:42:11 +0000 (11:42 +0200)]
* Improve tests
* Enable the build of the documentation
* Update of the TODO list

Change-Id: I76cb83cb729e890c621aee577ed3c202cf093180

12 files changed:
scilab/modules/external_objects_java/TODO
scilab/modules/external_objects_java/help/en_US/addchapter.sce
scilab/modules/external_objects_java/help/fr_FR/addchapter.sce [new file with mode: 0644]
scilab/modules/external_objects_java/help/ja_JP/addchapter.sce [new file with mode: 0644]
scilab/modules/external_objects_java/help/pt_BR/addchapter.sce [new file with mode: 0644]
scilab/modules/external_objects_java/help/ru_RU/addchapter.sce [new file with mode: 0644]
scilab/modules/external_objects_java/tests/unit_tests/extract.tst [new file with mode: 0644]
scilab/modules/external_objects_java/tests/unit_tests/jautoUnwrap.tst
scilab/modules/external_objects_java/tests/unit_tests/junwrap.tst [new file with mode: 0644]
scilab/modules/external_objects_java/tests/unit_tests/jwrap.tst
scilab/modules/external_objects_java/tests/unit_tests/jwrapinfloat.tst [new file with mode: 0644]
scilab/modules/helptools/etc/MAIN_CHAPTERS

index 9fb59d9..3e44c24 100644 (file)
@@ -7,10 +7,6 @@ junwraprem
 junwrap
 jvoid
 jwrapinchar
-jwrapinfloat
-jwrap
 new
 
 In the help pages, add the matching types <=> java
-
-what is long / float / char wrap  ? 
index 8562a5e..4ec4463 100644 (file)
@@ -7,4 +7,4 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-//add_help_chapter("Java from Scilab",SCI+"/modules/external_objects_java/help/en_US",%T);
+add_help_chapter("Java from Scilab",SCI+"/modules/external_objects_java/help/en_US",%T);
diff --git a/scilab/modules/external_objects_java/help/fr_FR/addchapter.sce b/scilab/modules/external_objects_java/help/fr_FR/addchapter.sce
new file mode 100644 (file)
index 0000000..f30c019
--- /dev/null
@@ -0,0 +1,10 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - S/E - Sylvestre Ledru
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+add_help_chapter("Java depuis Scilab",SCI+"/modules/external_objects_java/help/fr_FR",%T);
diff --git a/scilab/modules/external_objects_java/help/ja_JP/addchapter.sce b/scilab/modules/external_objects_java/help/ja_JP/addchapter.sce
new file mode 100644 (file)
index 0000000..d69a508
--- /dev/null
@@ -0,0 +1,10 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - S/E - Sylvestre Ledru
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+add_help_chapter("Java from Scilab",SCI+"/modules/external_objects_java/help/ru_RU",%T);
diff --git a/scilab/modules/external_objects_java/help/pt_BR/addchapter.sce b/scilab/modules/external_objects_java/help/pt_BR/addchapter.sce
new file mode 100644 (file)
index 0000000..d69a508
--- /dev/null
@@ -0,0 +1,10 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - S/E - Sylvestre Ledru
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+add_help_chapter("Java from Scilab",SCI+"/modules/external_objects_java/help/ru_RU",%T);
diff --git a/scilab/modules/external_objects_java/help/ru_RU/addchapter.sce b/scilab/modules/external_objects_java/help/ru_RU/addchapter.sce
new file mode 100644 (file)
index 0000000..05b72c2
--- /dev/null
@@ -0,0 +1,10 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - S/E - Sylvestre Ledru
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+
+add_help_chapter("Java from Scilab",SCI+"/modules/external_objects_java/help/ja_JP",%T);
diff --git a/scilab/modules/external_objects_java/tests/unit_tests/extract.tst b/scilab/modules/external_objects_java/tests/unit_tests/extract.tst
new file mode 100644 (file)
index 0000000..0473900
--- /dev/null
@@ -0,0 +1,35 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+
+jimport java.util.HashMap;
+h = HashMap.new();
+h.put("Coucou", "Foo");
+h.put("Hello", "Bar");
+a=rand(10,10);
+h.put("MyMatrix", a);
+dense=[%F, %F, %T, %F, %F
+%T, %F, %F, %F, %F
+%F, %F, %F, %F, %F
+%F, %F, %F, %F, %T];
+h.put("MyBool", dense);
+
+assert_checkequal(h.get("Coucou"), "Foo");
+assert_checkequal(h.Coucou, "Foo");
+assert_checkequal(h("Coucou"),"Foo");
+
+assert_checkequal(h.get("Hello"), "Bar");
+assert_checkequal(h.Hello, "Bar");
+assert_checkequal(h("Hello"),"Bar");
+
+assert_checkequal(h.get("MyMatrix"), a);
+assert_checkequal(h.MyMatrix, a);
+assert_checkequal(h("MyMatrix"),a);
+
+assert_checkequal(h.get("MyBool"), dense);
+assert_checkequal(h.MyBool, dense);
+assert_checkequal(h("MyBool"),dense);
index db47b90..af5a817 100644 (file)
@@ -7,12 +7,13 @@
 
 jautoUnwrap(%t)
 assert_checktrue(jautoUnwrap());
-jautoUnwrap(%f)
+jautoUnwrap(%f);
 assert_checkfalse(jautoUnwrap());
+jautoUnwrap(%t); // Plug back the normal behavior
 
 c = jcompile("Test", ["public class Test {";"public static double foo(double d) { return d; }";"}"]);
 jautoUnwrap(%f);
 assert_checkequal(typeof(c.foo(12)), "_EObj");
 
 jautoUnwrap(%t);
-assert_checkequal(typeof(c.foo(12)), "constant");
\ No newline at end of file
+assert_checkequal(typeof(c.foo(12)), "constant");
diff --git a/scilab/modules/external_objects_java/tests/unit_tests/junwrap.tst b/scilab/modules/external_objects_java/tests/unit_tests/junwrap.tst
new file mode 100644 (file)
index 0000000..77189c1
--- /dev/null
@@ -0,0 +1,182 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+jautoUnwrap(%f);
+myString=jwrap("foo");
+assert_checkequal(jgetclassname(myString),"java.lang.String");
+assert_checkequal("foo",junwrap(myString));
+
+a=jwrap(2);
+assert_checkequal(typeof(a),"_EObj");
+assert_checkequal(jgetclassname(a),"double");
+b=junwrap(a);
+assert_checkequal(typeof(b),"constant");
+
+
+c = jcompile("Test", ["public class Test {";
+    "public int[] returnArrayInt() {";
+    "    return new int[]{1,2,3,4};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int32([1,2,3,4]), junwrap(t.returnArrayInt()));
+
+c = jcompile("Test", ["public class Test {";
+    "public int returnInt() {";
+    "    return 32;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int32(32), junwrap(t.returnInt()));
+
+//////////////////////////////////////////////
+
+c = jcompile("Test", ["public class Test {";
+    "public double[] returnDouble() {";
+    "    return new double[]{1,2,3,4};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal([1,2,3,4], junwrap(t.returnDouble()));
+
+c = jcompile("Test", ["public class Test {";
+    "public double returnDouble() {";
+    "    return 32;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(32, junwrap(t.returnDouble()));
+
+//////////////////////////////////////////////
+
+c = jcompile("Test", ["public class Test {";
+    "public byte[] returnByte() {";
+    "    return new byte[]{1,2,3,4};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int8([1,2,3,4]), junwrap(t.returnByte()));
+
+c = jcompile("Test", ["public class Test {";
+    "public byte returnByte() {";
+    "    return 32;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int8(32), junwrap(t.returnByte()));
+
+//////////////////////////////////////////////
+
+c = jcompile("Test", ["public class Test {";
+    "public short[] returnShort() {";
+    "    return new short[]{1,2,3,4};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int16([1,2,3,4]), junwrap(t.returnShort()));
+
+c = jcompile("Test", ["public class Test {";
+    "public short returnShort() {";
+    "    return 32;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int16(32), junwrap(t.returnShort()));
+
+
+//////////////////////////////////////////////
+
+c = jcompile("Test", ["public class Test {";
+    "public long[] returnLong() {";
+    "    return new long[]{1L,2L,3L,4L};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int32([1,2,3,4]), junwrap(t.returnLong()));
+
+c = jcompile("Test", ["public class Test {";
+    "public long returnLong() {";
+    "    return 32L;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int32(32), junwrap(t.returnLong()));
+
+//////////////////////////////////////////////
+
+c = jcompile("Test", ["public class Test {";
+    "public float[] returnFloat() {";
+    "    return new float[]{1f,2f,3f,4f};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal([1,2,3,4], junwrap(t.returnFloat()));
+
+c = jcompile("Test", ["public class Test {";
+    "public float returnFloat() {";
+    "    return 32f;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(32, junwrap(t.returnFloat()));
+
+
+//////////////////////////////////////////////
+
+// c = jcompile("Test", ["public class Test {";
+//     "public char[] returnChar() {";
+//     "    return new char[]{''a'',''b'',''c'',''d''};";
+//     "}";
+//     "}";]);
+// t = c.new();
+// assert_checkequal(jgetclassname(c),"Test");
+// assert_checkequal(['a','b','c','d'], t.returnChar());
+
+// c = jcompile("Test", ["public class Test {";
+//     "public char returnChar() {";
+//     "    return ''a'';";
+//     "}";
+//     "}";]);
+// t = c.new();
+// assert_checkequal(jgetclassname(c),"Test");
+// assert_checkequal(int16(32), t.returnChar());
+
+
+
+//////////////////////////////////////////////
+
+c = jcompile("Test", ["public class Test {";
+    "public boolean[] returnBoolean() {";
+    "    return new boolean[]{true,true,false,false};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal([%t,%t,%f,%f], junwrap(t.returnBoolean()));
+
+c = jcompile("Test", ["public class Test {";
+    "public boolean returnBoolean() {";
+    "    return true;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(%t, junwrap(t.returnBoolean()));
+
+jautoUnwrap(%t);
index ae41b0e..38f3f5b 100644 (file)
@@ -97,43 +97,43 @@ assert_checkequal(int16(32), t.returnShort());
 
 //////////////////////////////////////////////
 
-// c = jcompile("Test", ["public class Test {";
-//     "public long[] returnLong() {";
-//     "    return new long[]{1L,2L,3L,4L};";
-//     "}";
-//     "}";]);
-// t = c.new();
-// assert_checkequal(jgetclassname(c),"Test");
-// assert_checkequal(int16([1,2,3,4]), t.returnLong());
+c = jcompile("Test", ["public class Test {";
+    "public long[] returnLong() {";
+    "    return new long[]{1L,2L,3L,4L};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int32([1,2,3,4]), t.returnLong());
 
-// c = jcompile("Test", ["public class Test {";
-//     "public long returnLong() {";
-//     "    return 32L;";
-//     "}";
-//     "}";]);
-// t = c.new();
-// assert_checkequal(jgetclassname(c),"Test");
-// assert_checkequal(int16(32), t.returnLong());
+c = jcompile("Test", ["public class Test {";
+    "public long returnLong() {";
+    "    return 32L;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(int32(32), t.returnLong());
 
 //////////////////////////////////////////////
 
-// c = jcompile("Test", ["public class Test {";
-//     "public float[] returnFloat() {";
-//     "    return new float[]{1f,2f,3f,4f};";
-//     "}";
-//     "}";]);
-// t = c.new();
-// assert_checkequal(jgetclassname(c),"Test");
-// assert_checkequal(int16([1,2,3,4]), t.returnFloat());
+c = jcompile("Test", ["public class Test {";
+    "public float[] returnFloat() {";
+    "    return new float[]{1f,2f,3f,4f};";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal([1,2,3,4], t.returnFloat());
 
-// c = jcompile("Test", ["public class Test {";
-//     "public float returnFloat() {";
-//     "    return 32f;";
-//     "}";
-//     "}";]);
-// t = c.new();
-// assert_checkequal(jgetclassname(c),"Test");
-// assert_checkequal(int16(32), t.returnFloat());
+c = jcompile("Test", ["public class Test {";
+    "public float returnFloat() {";
+    "    return 32f;";
+    "}";
+    "}";]);
+t = c.new();
+assert_checkequal(jgetclassname(c),"Test");
+assert_checkequal(32, t.returnFloat());
 
 
 //////////////////////////////////////////////
@@ -155,7 +155,7 @@ assert_checkequal(int16(32), t.returnShort());
 // t = c.new();
 // assert_checkequal(jgetclassname(c),"Test");
 // assert_checkequal(int16(32), t.returnChar());
-//
+
 
 
 //////////////////////////////////////////////
diff --git a/scilab/modules/external_objects_java/tests/unit_tests/jwrapinfloat.tst b/scilab/modules/external_objects_java/tests/unit_tests/jwrapinfloat.tst
new file mode 100644 (file)
index 0000000..9ded86e
--- /dev/null
@@ -0,0 +1,9 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+f = jwrapinfloat(%pi);
+assert_checkalmostequal(junwrap(f), %pi, 10^-7);
index b7d6b52..40d0697 100644 (file)
@@ -63,9 +63,10 @@ parallel
 modules_manager
 localization
 action_binding
-jvm
 api_scilab
 call_scilab
+jvm
+external_objects_java
 javasci
 intersci
 graph