update scicos.tst (Thanks Simoné)
Allan Cornet [Fri, 29 Aug 2008 09:07:39 +0000 (09:07 +0000)]
scilab/modules/scicos/tests/unit_tests/scicos.dia.ref
scilab/modules/scicos/tests/unit_tests/scicos.tst
scilab/modules/scicos/tests/unit_tests/scicos_tests.sci [new file with mode: 0644]

index 684d275..c217cea 100644 (file)
@@ -1,51 +1,28 @@
-load SCI/modules/scicos/macros/scicos/lib;
-getf SCI/tests/basic_tests/scicos_tests.sci;
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) ????-2008 - INRIA
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+load('SCI/modules/scicos/macros/scicos_scicos/lib');
 options=default_options();
 //build the block set
-blockslib='scs'+['Branching','Events','Misc','Sinks','Threshold','Linear',0...
+blockslib='scs'+['Branching','Events','Misc','Sinks','Threshold','Linear', ...
          'NonLinear','Sources','Electrical','Hydraulics']+'lib';
 Blocs=[]
  Blocs  =
  
      []
 for blocklib=blockslib
   B=string(blocklib);Blocs=[Blocs;B(2:$)];
 end
 Blocs(Blocs=="m_sin")=[];
 nb=size(Blocs,1);
 if checkdefine() then bugmes();quit;end
-if checkdraw() then bugmes();quit;end
 if checkinputs() then bugmes();quit;end
 if checkoutputs() then bugmes();quit;end
 if checkorigin() then bugmes();quit;end
-if checkset() then bugmes();quit;end
 if checkdeput() then bugmes();quit;end
 if checkfiring() then bugmes();quit;end
 if check_define_ports() then bugmes();quit;end
 if check_set_ports() then bugmes();quit;end
index 16d964d..c3a13a8 100644 (file)
@@ -22,11 +22,9 @@ Blocs(Blocs=="m_sin")=[];
 
 nb=size(Blocs,1);
 if checkdefine() then pause,end
-if checkdraw() then pause,end
 if checkinputs() then pause,end
 if checkoutputs() then pause,end
 if checkorigin() then pause,end
-if checkset() then pause,end
 if checkdeput() then pause,end
 if checkfiring() then pause,end
 if check_define_ports() then pause,end
diff --git a/scilab/modules/scicos/tests/unit_tests/scicos_tests.sci b/scilab/modules/scicos/tests/unit_tests/scicos_tests.sci
new file mode 100644 (file)
index 0000000..4cc1966
--- /dev/null
@@ -0,0 +1,179 @@
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test du cas 'define' des fonctions gui des blocs\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=checkdefine()\r
+   r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    ierr=execstr('x=gui(''define'')','errcatch')\r
+    if ierr<>0 then\r
+      mprintf('define failed for block '+Blocs(i));\r
+      r=%t\r
+      return; \r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test du cas 'inputs' des fonctions gui des blocs\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=checkinputs()\r
+   r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    o=gui('define')\r
+    ierr=execstr('[x,y,typ]=gui(''getinputs'',o)','errcatch')\r
+    if ierr<>0 then\r
+      mprintf('getinputs failed for block '+Blocs(i));\r
+      r=%t\r
+      return; \r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test du cas 'outputs' des fonctions gui des blocs\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=checkoutputs()\r
+   r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    o=gui('define')\r
+    ierr=execstr('[x,y,typ]=gui(''getoutputs'',o)','errcatch')\r
+    if ierr<>0 then\r
+      mprintf('getoutputs failed for block '+Blocs(i));\r
+      r=%t\r
+      return; \r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test du cas 'origin' des fonctions gui des blocs\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=checkorigin()\r
+   r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    o=gui('define')\r
+    ierr=execstr('[x,y,typ]=gui(''getorigin'',o)','errcatch')\r
+    if ierr<>0 then\r
+      mprintf('getorigin failed for block '+Blocs(i));\r
+      r=%t\r
+      return; \r
+    elseif x<>0|y<>0 then \r
+      mprintf('getorigin failed for block '+Blocs(i));\r
+      r=%t\r
+      return; \r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test de la taille du vecteur dep_ut\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=checkdeput()\r
+  r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    o=gui('define');\r
+    dpt=o.model.dep_ut;\r
+    if length(o.model.dep_ut)~=2 then \r
+      mprintf('check dep_ut failed for block '+Blocs(i)); \r
+      r=%t\r
+      return;\r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test de la taille du vecteur firing\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=checkfiring()\r
+  r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    o=gui('define');\r
+    dpt=o.model.firing;\r
+    if length(o.model.firing)==[] then \r
+      mprintf('check firing failed for block '+Blocs(i));\r
+      r=%t\r
+      return;\r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test de coherence des ports entre model et graphic cas define\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=check_define_ports()\r
+  r=%f\r
+  for i=1:nb\r
+    execstr('gui='+Blocs(i))\r
+    o=gui('define');\r
+    opim=o.model.in;\r
+    opom=o.model.out;\r
+    opeim=o.model.evtin;\r
+    opeom=o.model.evtout;\r
+    opig=o.graphics.pin;\r
+    opog=o.graphics.pout;\r
+    opeig=o.graphics.pein;\r
+    opeog=o.graphics.peout;\r
+    \r
+    if size(opim,1)<>size(opig,1) | ..\r
+         size(opom,1)<>size(opog,1)  | ..\r
+         size(opeim,1)<>size(opeig,1)  | ..\r
+         size(opeom,1)<>size(opeog,1) then \r
+      mprintf('check  define_ports failed for block '+Blocs(i));\r
+      r=%t\r
+      return;\r
+    end\r
+    clear gui\r
+  end\r
+endfunction\r
+\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+//Test de coherence des ports entre model et graphic : cas set\r
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r
+function r=check_set_ports()\r
+  r=%f\r
+  funcprot(0)\r
+  getf('SCI/modules/scicos/macros/scicos_scicos/setvalue.sci')\r
+  getvalue=setvalue;\r
+  alreadyran=%f;  %scicos_prob=%f\r
+  for i=1:nb\r
+    if and(Blocs(i)~=["SUPER_f" "func_block" "scifunc_block" "GENERAL_f" "SOM_f" "CURV_f" "LOOKUP_f"]) then \r
+      if Blocs(i)=='fortran_block'|Blocs(i)=='c_block' then\r
+       getf('SCI/modules/scicos_blocks/macros/'+Blocs(i)+'.sci')\r
+      else\r
+       getf('SCI/modules/scicos_blocks/macros/'+Blocs(i)+'.sci')\r
+      end\r
+      execstr('gui='+Blocs(i))\r
+      o=gui('define');\r
+      o_n=gui('set',o);\r
+      o_npim=o_n.model.in;\r
+      o_npom=o_n.model.out;\r
+      o_npeim=o_n.model.evtin;\r
+      o_npeom=o_n.model.evtout;\r
+      o_npig=o_n.graphics.pin;\r
+      o_npog=o_n.graphics.pout;\r
+      o_npeig=o_n.graphics.pein;\r
+      o_npeog=o_n.graphics.peout;\r
+      if size(o_npim,1)<>size(o_npig,1) | ..\r
+           size(o_npom,1)<>size(o_npog,1)  | ..  \r
+           size(o_npeim,1)<>size(o_npeig,1)| ..  \r
+           size(o_npeom,1)<>size(o_npeog,1) then \r
+       mprintf('check set_ports failed for block '+Blocs(i));\r
+       r=%t\r
+       return;\r
+      end\r
+      clear gui\r
+    end\r
+  end\r
+endfunction\r