Missing parameter to post_xcos_simulate 30/11330/3
Bruno JOFRET [Fri, 19 Apr 2013 08:09:22 +0000 (10:09 +0200)]
Change-Id: I3719c9e55f8a2e40ecdc340c38f6b10a8d0ef3fa

scilab/modules/xcos/macros/xcos_simulate.sci
scilab/modules/xcos/tests/unit_tests/post_xcos_simulate.dia.ref [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/post_xcos_simulate.tst [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/pre_xcos_simulate.dia.ref [new file with mode: 0644]
scilab/modules/xcos/tests/unit_tests/pre_xcos_simulate.tst [new file with mode: 0644]

index 0638176..1ed035d 100644 (file)
@@ -391,7 +391,7 @@ function %cpr = xcos_simulate(scs_m, needcompile)
         if type(post_xcos_simulate) == 15 then
             // if has a multiple implementation (on a list)
             for f=post_xcos_simulate;
-                ok=invoke_post_simulate(f, scs_m, needcompile);
+                ok=invoke_post_simulate(f, %cpr, scs_m, needcompile);
                 if ~ok then
                     %cpr=[];
                     return;
diff --git a/scilab/modules/xcos/tests/unit_tests/post_xcos_simulate.dia.ref b/scilab/modules/xcos/tests/unit_tests/post_xcos_simulate.dia.ref
new file mode 100644 (file)
index 0000000..f7cf730
--- /dev/null
@@ -0,0 +1,79 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Bruno JOFRET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- XCOS TEST -->
+// post_xcos_simulate test
+loadXcosLibs();
+assert_checktrue(importXcosDiagram(SCI + "/modules/xcos/tests/unit_tests/cumsum.zcos"));
+function disp_post_simulate(%cpr, scs_m, needcompile)
+    disp("Calling disp_post_simulate");
+endfunction
+// Register function
+post_xcos_simulate = list("disp_post_simulate");
+xcos_simulate(scs_m, 4);
+ Calling disp_post_simulate   
+assert_checktrue(isdef('cumsum_r'));
+clear('cumsum_r');
+// Register function
+clear post_xcos_simulate
+post_xcos_simulate = disp_post_simulate;
+xcos_simulate(scs_m, 4);
+ Calling disp_post_simulate   
+assert_checktrue(isdef('cumsum_r'));
+function analyze_post_simulate(%cpr, scs_m, needcompile)
+// Retrieve all objects
+    objs = scs_m.objs;
+    links = 0;
+    blocks = 0;
+    other = 0;
+// Count Links and Blocks
+    for i = 1:size(objs)
+        currentType = typeof(objs(i));
+        select (currentType)
+         case "Link"
+          links = links + 1;
+         case "Block"
+          blocks = blocks + 1;
+        else
+            other = other + 1;
+        end
+    end
+// Diplay Diagram analisys.
+    disp("Diagram Analysis:")
+    disp("Found "+string(blocks)+" Blocks.")
+    disp("Found "+string(links)+" Links.")
+    disp("Found "+string(other)+" Other component.")
+endfunction
+clear('cumsum_r');
+// Register function
+clear post_xcos_simulate
+post_xcos_simulate = list("analyze_post_simulate");
+xcos_simulate(scs_m, 4);
+ Diagram Analysis:   
+ Found 24 Blocks.   
+ Found 22 Links.   
+ Found 0 Other component.   
+assert_checktrue(isdef('cumsum_r'));
+clear('cumsum_r');
+// Register function
+clear post_xcos_simulate
+post_xcos_simulate = analyze_post_simulate;
+xcos_simulate(scs_m, 4);
+ Diagram Analysis:   
+ Found 24 Blocks.   
+ Found 22 Links.   
+ Found 0 Other component.   
+assert_checktrue(isdef('cumsum_r'));
diff --git a/scilab/modules/xcos/tests/unit_tests/post_xcos_simulate.tst b/scilab/modules/xcos/tests/unit_tests/post_xcos_simulate.tst
new file mode 100644 (file)
index 0000000..4ee0711
--- /dev/null
@@ -0,0 +1,74 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Bruno JOFRET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- XCOS TEST -->
+
+// post_xcos_simulate test
+loadXcosLibs();
+
+assert_checktrue(importXcosDiagram(SCI + "/modules/xcos/tests/unit_tests/cumsum.zcos"));
+
+function disp_post_simulate(%cpr, scs_m, needcompile)
+    disp("Calling disp_post_simulate");
+endfunction
+
+// Register function
+post_xcos_simulate = list("disp_post_simulate");
+xcos_simulate(scs_m, 4);
+assert_checktrue(isdef('cumsum_r'));
+
+clear('cumsum_r');
+
+// Register function
+clear post_xcos_simulate
+post_xcos_simulate = disp_post_simulate;
+xcos_simulate(scs_m, 4);
+assert_checktrue(isdef('cumsum_r'));
+
+function analyze_post_simulate(%cpr, scs_m, needcompile)
+// Retrieve all objects
+    objs = scs_m.objs;
+
+    links = 0;
+    blocks = 0;
+    other = 0;
+// Count Links and Blocks
+    for i = 1:size(objs)
+        currentType = typeof(objs(i));
+        select (currentType)
+         case "Link"
+          links = links + 1;
+         case "Block"
+          blocks = blocks + 1;
+        else
+            other = other + 1;
+        end
+    end
+
+// Diplay Diagram analisys.
+    disp("Diagram Analysis:")
+    disp("Found "+string(blocks)+" Blocks.")
+    disp("Found "+string(links)+" Links.")
+    disp("Found "+string(other)+" Other component.")
+endfunction
+
+clear('cumsum_r');
+
+// Register function
+clear post_xcos_simulate
+post_xcos_simulate = list("analyze_post_simulate");
+xcos_simulate(scs_m, 4);
+assert_checktrue(isdef('cumsum_r'));
+
+clear('cumsum_r');
+
+// Register function
+clear post_xcos_simulate
+post_xcos_simulate = analyze_post_simulate;
+xcos_simulate(scs_m, 4);
+assert_checktrue(isdef('cumsum_r'));
+
diff --git a/scilab/modules/xcos/tests/unit_tests/pre_xcos_simulate.dia.ref b/scilab/modules/xcos/tests/unit_tests/pre_xcos_simulate.dia.ref
new file mode 100644 (file)
index 0000000..eacfd64
--- /dev/null
@@ -0,0 +1,80 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Bruno JOFRET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- XCOS TEST -->
+// pre_xcos_simulate test
+loadXcosLibs();
+assert_checktrue(importXcosDiagram(SCI + "/modules/xcos/tests/unit_tests/cumsum.zcos"));
+function continueSimulation = fail_pre_simulate(scs_m, needcompile)
+    disp("Calling fail_pre_simulate");
+    continueSimulation = %f;
+endfunction
+// Register function
+pre_xcos_simulate = list("fail_pre_simulate");
+xcos_simulate(scs_m, 4);
+ Calling fail_pre_simulate   
+assert_checkfalse(isdef('cumsum_r'));
+// Register function
+clear pre_xcos_simulate
+pre_xcos_simulate = fail_pre_simulate;
+xcos_simulate(scs_m, 4);
+ Calling fail_pre_simulate   
+assert_checkfalse(isdef('cumsum_r'));
+function continueSimulation = analyze_pre_simulate(scs_m, needcompile)
+// Retrieve all objects
+    objs = scs_m.objs;
+    links = 0;
+    blocks = 0;
+    other = 0;
+// Count Links and Blocks
+    for i = 1:size(objs)
+        currentType = typeof(objs(i));
+        select (currentType)
+         case "Link"
+          links = links + 1;
+         case "Block"
+          blocks = blocks + 1;
+        else
+            other = other + 1;
+        end
+    end
+// Diplay Diagram analisys.
+    disp("Diagram Analysis:")
+    disp("Found "+string(blocks)+" Blocks.")
+    disp("Found "+string(links)+" Links.")
+    disp("Found "+string(other)+" Other component.")
+// Continue Simulation
+    continueSimulation = %T;
+endfunction
+// Register function
+clear pre_xcos_simulate
+pre_xcos_simulate = list("analyze_pre_simulate");
+xcos_simulate(scs_m, 4);
+ Diagram Analysis:   
+ Found 24 Blocks.   
+ Found 22 Links.   
+ Found 0 Other component.   
+assert_checktrue(isdef('cumsum_r'));
+clear('cumsum_r');
+// Register function
+clear pre_xcos_simulate
+pre_xcos_simulate = analyze_pre_simulate;
+xcos_simulate(scs_m, 4);
+ Diagram Analysis:   
+ Found 24 Blocks.   
+ Found 22 Links.   
+ Found 0 Other component.   
+assert_checktrue(isdef('cumsum_r'));
diff --git a/scilab/modules/xcos/tests/unit_tests/pre_xcos_simulate.tst b/scilab/modules/xcos/tests/unit_tests/pre_xcos_simulate.tst
new file mode 100644 (file)
index 0000000..6f81c86
--- /dev/null
@@ -0,0 +1,73 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Bruno JOFRET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- XCOS TEST -->
+
+// pre_xcos_simulate test
+loadXcosLibs();
+
+assert_checktrue(importXcosDiagram(SCI + "/modules/xcos/tests/unit_tests/cumsum.zcos"));
+
+function continueSimulation = fail_pre_simulate(scs_m, needcompile)
+    disp("Calling fail_pre_simulate");
+    continueSimulation = %f;
+endfunction
+
+// Register function
+pre_xcos_simulate = list("fail_pre_simulate");
+xcos_simulate(scs_m, 4);
+assert_checkfalse(isdef('cumsum_r'));
+
+// Register function
+clear pre_xcos_simulate
+pre_xcos_simulate = fail_pre_simulate;
+xcos_simulate(scs_m, 4);
+assert_checkfalse(isdef('cumsum_r'));
+
+function continueSimulation = analyze_pre_simulate(scs_m, needcompile)
+// Retrieve all objects
+    objs = scs_m.objs;
+
+    links = 0;
+    blocks = 0;
+    other = 0;
+// Count Links and Blocks
+    for i = 1:size(objs)
+        currentType = typeof(objs(i));
+        select (currentType)
+         case "Link"
+          links = links + 1;
+         case "Block"
+          blocks = blocks + 1;
+        else
+            other = other + 1;
+        end
+    end
+
+// Diplay Diagram analisys.
+    disp("Diagram Analysis:")
+    disp("Found "+string(blocks)+" Blocks.")
+    disp("Found "+string(links)+" Links.")
+    disp("Found "+string(other)+" Other component.")
+
+// Continue Simulation
+    continueSimulation = %T;
+endfunction
+
+// Register function
+clear pre_xcos_simulate
+pre_xcos_simulate = list("analyze_pre_simulate");
+xcos_simulate(scs_m, 4);
+assert_checktrue(isdef('cumsum_r'));
+
+clear('cumsum_r');
+
+// Register function
+clear pre_xcos_simulate
+pre_xcos_simulate = analyze_pre_simulate;
+xcos_simulate(scs_m, 4);
+assert_checktrue(isdef('cumsum_r'));