* Bug #13059 fixed - Nan propagated at startup made the simulation fail. 02/13102/3
Clément DAVID [Thu, 7 Nov 2013 16:18:08 +0000 (17:18 +0100)]
Change-Id: Iaabd4ba171505d2cd14c92606db582b65d99c53a

scilab/CHANGES_5.5.X
scilab/modules/scicos/src/c/scicos.c
scilab/modules/xcos/macros/xcos_simulate.sci
scilab/modules/xcos/tests/nonreg_tests/bug_13059.dia.ref [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_13059.tst [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_13059.zcos [new file with mode: 0644]

index a117156..d4de880 100644 (file)
@@ -165,6 +165,8 @@ Xcos Bug Fixes
 
 * Bug #13030 fixed - Selection to superblock did not reset the origin.
 
+* Bug #13059 fixed - Nan propagated at startup made the simulation fail.
+
 
                  Changes between version 5.4.1 and 5.5.0-beta-1
                  ==============================================
index bc11338..6019cd9 100644 (file)
@@ -1182,6 +1182,13 @@ static void cosini(double *told)
                     sszz = outtbsz[jj] * outtbsz[jj + nlnk];
                     for (kk = 0; kk < sszz; kk++)
                     {
+                        int outtbdptr_isnan = outtbdptr[kk] != outtbdptr[kk];
+                        int outtbd_isnan = (SCSREAL_COP)outtbd[curouttbd + kk] != (SCSREAL_COP)outtbd[curouttbd + kk];
+
+                        if (outtbdptr_isnan == outtbd_isnan)
+                        {
+                            continue;
+                        }
                         if (outtbdptr[kk] != (SCSREAL_COP)outtbd[curouttbd + kk])
                         {
                             goto L30;
@@ -1195,7 +1202,14 @@ static void cosini(double *told)
                     sszz = 2 * outtbsz[jj] * outtbsz[jj + nlnk];
                     for (kk = 0; kk < sszz; kk++)
                     {
-                        if (outtbdptr[kk] != (SCSCOMPLEX_COP)outtbd[curouttbd + kk])
+                        int outtbdptr_isnan = outtbdptr[kk] != outtbdptr[kk];
+                        int outtbd_isnan = (SCSCOMPLEX_COP)outtbd[curouttbd + kk] != (SCSCOMPLEX_COP)outtbd[curouttbd + kk];
+
+                        if (outtbdptr_isnan == outtbd_isnan)
+                        {
+                            continue;
+                        }
+                        if (outtbdptr[kk] != (SCSCOMPLEX_COP)outtbd[curouttbd + kk] && outtbdptr[kk] == outtbdptr[kk])
                         {
                             goto L30;
                         }
index 48567ab..d29b194 100644 (file)
@@ -220,7 +220,7 @@ function %cpr = xcos_simulate(scs_m, needcompile)
                 kfun    = curblock()
                 corinv  = %cpr.corinv
 
-                if kfun<>0 then //** block error
+                if kfun<>0 & length(corinv) > kfun then //** block error
                     path = corinv(kfun)
                     //** get error cmd for the block
                     get_errorcmd(path,"End problem.",str_err);
@@ -271,10 +271,10 @@ function %cpr = xcos_simulate(scs_m, needcompile)
         //** error case
         if ierr<>0 then
             str_err=split_lasterror(lasterror());
-
             kfun=curblock()
             corinv=%cpr.corinv
-            if kfun<>0 then  //** block error
+
+            if kfun<>0 & length(corinv) > kfun then  //** block error
                 path=corinv(kfun)
                 //** get error cmd for the block
                 disp(str_err);
@@ -327,11 +327,10 @@ function %cpr = xcos_simulate(scs_m, needcompile)
             //** error case
             if ierr<>0 then
                 str_err = split_lasterror(lasterror());
-
                 kfun   = curblock()
                 corinv = %cpr.corinv
 
-                if kfun<>0 then //** block error
+                if kfun<>0 & length(corinv) > kfun then //** block error
                     path = corinv(kfun)
                     //** get error cmd for the block
                     get_errorcmd(path,gettext("End problem"),str_err);
@@ -350,8 +349,7 @@ function %cpr = xcos_simulate(scs_m, needcompile)
         alreadyran = %f;
         kfun       = curblock();
         corinv     = %cpr.corinv;
-
-        if kfun<>0 then //** block error
+        if kfun<>0 & length(corinv) > kfun then //** block error
             path = corinv(kfun);
             //** get error cmd for the block
             execstr(get_errorcmd(path,gettext("Simulation problem"),str_err));
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_13059.dia.ref b/scilab/modules/xcos/tests/nonreg_tests/bug_13059.dia.ref
new file mode 100644 (file)
index 0000000..2a2c9a7
--- /dev/null
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- XCOS TEST -->
+//
+// <-- Non-regression test for bug 13059 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13059
+//
+// <-- Short Description -->
+// '%nan' propagated at startup fail the simulation
+loadXcosLibs();
+assert_checktrue(importXcosDiagram(SCI + "/modules/xcos/tests/nonreg_tests/bug_13059.zcos"));
+// check using scicos_simulate
+scicos_simulate(scs_m);
+assert_checkequal(A.values, %nan);
+clear A;
+// check using xcos_simulate
+xcos_simulate(scs_m, 4);
+assert_checkequal(A.values, %nan);
+clear A;
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_13059.tst b/scilab/modules/xcos/tests/nonreg_tests/bug_13059.tst
new file mode 100644 (file)
index 0000000..f7ed05c
--- /dev/null
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- XCOS TEST -->
+//
+// <-- Non-regression test for bug 13059 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=13059
+//
+// <-- Short Description -->
+// '%nan' propagated at startup fail the simulation
+
+loadXcosLibs();
+
+assert_checktrue(importXcosDiagram(SCI + "/modules/xcos/tests/nonreg_tests/bug_13059.zcos"));
+
+// check using scicos_simulate
+scicos_simulate(scs_m);
+
+assert_checkequal(A.values, %nan);
+clear A;
+
+// check using xcos_simulate
+xcos_simulate(scs_m, 4);
+
+assert_checkequal(A.values, %nan);
+clear A;
+
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_13059.zcos b/scilab/modules/xcos/tests/nonreg_tests/bug_13059.zcos
new file mode 100644 (file)
index 0000000..b420271
Binary files /dev/null and b/scilab/modules/xcos/tests/nonreg_tests/bug_13059.zcos differ