bug_14212: unable to reload array of struct from scilab 5.5.2 sod file 82/17382/2
Antoine ELIAS [Fri, 23 Oct 2015 09:25:48 +0000 (11:25 +0200)]
Change-Id: I416c8a7a28ce147515a463591448690be9d3f70f

scilab/CHANGES_6.0.X
scilab/modules/io/macros/%_sodload.sci
scilab/modules/io/tests/nonreg_tests/bug_14212.dia.ref [new file with mode: 0644]
scilab/modules/io/tests/nonreg_tests/bug_14212.tst [new file with mode: 0644]
scilab/modules/io/tests/nonreg_tests/bug_14212_1x1.h5 [new file with mode: 0644]
scilab/modules/io/tests/nonreg_tests/bug_14212_2x2.h5 [new file with mode: 0644]

index b5ab1c9..9c8d8d6 100644 (file)
@@ -130,6 +130,8 @@ Scilab Bug Fixes
 
 * Bug #14209 fixed - 1:245 created infinite loop.
 
+* Bug #14212 fixed - Scilab 6 did not load array of struct from Scilab 5.5 files correctly
+
 
             Changes between version 5.5.2 and 6.0.0-alpha-1 of Scilab
             =========================================================
index 63e4ea1..f2d2c8f 100644 (file)
@@ -61,7 +61,17 @@ function varargout = %_sodload(%__varnameList__)
                 end
 
                 if typeof(varValue)=="st" then
-                    varValue(fieldNames(kField)) = fieldValue;
+                    s = size(varValue, "*");
+                    if s > 1 then
+                        if typeof(fieldValue) <> "list" then //houston !
+                        end
+
+                        for iDim = 1:s
+                            varValue(iDim)(fieldNames(kField)) = fieldValue(iDim);
+                        end
+                    else
+                        varValue(fieldNames(kField)) = fieldValue;
+                    end
                 else
                     varValue{kField} = fieldValue;
                 end
diff --git a/scilab/modules/io/tests/nonreg_tests/bug_14212.dia.ref b/scilab/modules/io/tests/nonreg_tests/bug_14212.dia.ref
new file mode 100644 (file)
index 0000000..2e30ba7
--- /dev/null
@@ -0,0 +1,44 @@
+//<-- CLI SHELL MODE -->
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 14212 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14212
+//
+// <-- Short Description -->
+// Scilab 6 did not load array of struct from Scilab 5.5 files correctly
+//code to generated test struct on Scilab 5.5.2
+//disp(TMPDIR);
+//clear a;
+//a.b = "b";
+//a.c = "c";
+//save("TMPDIR/bug_14212_1x1.h5", "a");
+//clear a;
+//a(1,1).b = "11b";
+//a(1,1).c = "11c";
+//a(1,2).b = "12b";
+//a(1,2).c = "12c";
+//a(2,1).b = "21b";
+//a(2,1).c = "21c";
+//a(2,2).b = "22b";
+//a(2,2).c = "22c";
+//save("TMPDIR/bug_14212_2x2.h5", "a");
+clear a;
+load("SCI/modules/io/tests/nonreg_tests/bug_14212_1x1.h5");
+assert_checkequal(a.b, "b");
+assert_checkequal(a.c, "c");
+clear a;
+load("SCI/modules/io/tests/nonreg_tests/bug_14212_2x2.h5");
+assert_checkequal(a(1,1).b, "11b");
+assert_checkequal(a(1,1).c, "11c");
+assert_checkequal(a(1,2).b, "12b");
+assert_checkequal(a(1,2).c, "12c");
+assert_checkequal(a(2,1).b, "21b");
+assert_checkequal(a(2,1).c, "21c");
+assert_checkequal(a(2,2).b, "22b");
+assert_checkequal(a(2,2).c, "22c");
diff --git a/scilab/modules/io/tests/nonreg_tests/bug_14212.tst b/scilab/modules/io/tests/nonreg_tests/bug_14212.tst
new file mode 100644 (file)
index 0000000..43d634c
--- /dev/null
@@ -0,0 +1,49 @@
+//<-- CLI SHELL MODE -->
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- Non-regression test for bug 14212 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14212
+//
+// <-- Short Description -->
+// Scilab 6 did not load array of struct from Scilab 5.5 files correctly
+
+//code to generated test struct on Scilab 5.5.2
+//disp(TMPDIR);
+//clear a;
+//a.b = "b";
+//a.c = "c";
+//save("TMPDIR/bug_14212_1x1.h5", "a");
+//clear a;
+//a(1,1).b = "11b";
+//a(1,1).c = "11c";
+//a(1,2).b = "12b";
+//a(1,2).c = "12c";
+//a(2,1).b = "21b";
+//a(2,1).c = "21c";
+//a(2,2).b = "22b";
+//a(2,2).c = "22c";
+//save("TMPDIR/bug_14212_2x2.h5", "a");
+
+clear a;
+load("SCI/modules/io/tests/nonreg_tests/bug_14212_1x1.h5");
+assert_checkequal(a.b, "b");
+assert_checkequal(a.c, "c");
+
+clear a;
+load("SCI/modules/io/tests/nonreg_tests/bug_14212_2x2.h5");
+assert_checkequal(a(1,1).b, "11b");
+assert_checkequal(a(1,1).c, "11c");
+assert_checkequal(a(1,2).b, "12b");
+assert_checkequal(a(1,2).c, "12c");
+assert_checkequal(a(2,1).b, "21b");
+assert_checkequal(a(2,1).c, "21c");
+assert_checkequal(a(2,2).b, "22b");
+assert_checkequal(a(2,2).c, "22c");
+
diff --git a/scilab/modules/io/tests/nonreg_tests/bug_14212_1x1.h5 b/scilab/modules/io/tests/nonreg_tests/bug_14212_1x1.h5
new file mode 100644 (file)
index 0000000..06e50f2
Binary files /dev/null and b/scilab/modules/io/tests/nonreg_tests/bug_14212_1x1.h5 differ
diff --git a/scilab/modules/io/tests/nonreg_tests/bug_14212_2x2.h5 b/scilab/modules/io/tests/nonreg_tests/bug_14212_2x2.h5
new file mode 100644 (file)
index 0000000..22e5d66
Binary files /dev/null and b/scilab/modules/io/tests/nonreg_tests/bug_14212_2x2.h5 differ