fix prod : variables that are returned are binding link with outType 96/14996/11
Sylvain GENIN [Thu, 7 Aug 2014 08:45:40 +0000 (10:45 +0200)]
i=uint8([1 10;254 9]);

//fail: type return is bad
assert_checkequal(prod(i, 3, "native"), double(i));

// type return is good
assert_checkequal(prod(i, 3, "native"), i);
i=uint8([1 10;254 9]);
typeof(prod(i, 3, "native"))//uint8
typeof(prod(i, 3))          //uint8
typeof(prod(i))             //uint8
typeof(prod(i, 3, "double"))//double

//
test_run("elementary_functions","prod",["no_check_error_output" ]);

Change-Id: Ia133692455a161445d5d8d2feaa5828cea4599a1

scilab/modules/elementary_functions/tests/unit_tests/prod.dia.ref
scilab/modules/elementary_functions/tests/unit_tests/prod.tst
scilab/modules/integer/src/fortran/i_prod.f

index ebfb303..5d647b3 100644 (file)
@@ -162,7 +162,7 @@ for typ=T
     assert_checkequal(prod(i, "*", typ(:)), uint8(76));
     assert_checkequal(prod(i, 1, typ(:)), uint8([254 90]));
     assert_checkequal(prod(i, 2, typ(:)), uint8([10;238]));
-    assert_checkequal(prod(i, 3, typ(:)), double(i));
+    assert_checkequal(prod(i, 3, typ(:)), i);
 end
 assert_checkequal(prod(i, "double"), 22860);
 assert_checkequal(prod(i, "*", "double"), 22860);
index 00e10d8..db70b48 100644 (file)
@@ -195,7 +195,7 @@ for typ=T
     assert_checkequal(prod(i, "*", typ(:)), uint8(76));
     assert_checkequal(prod(i, 1, typ(:)), uint8([254 90]));
     assert_checkequal(prod(i, 2, typ(:)), uint8([10;238]));
-    assert_checkequal(prod(i, 3, typ(:)), double(i));
+    assert_checkequal(prod(i, 3, typ(:)), i);
 end
 
 assert_checkequal(prod(i, "double"), 22860);
index 6bbb3d3..636db80 100644 (file)
@@ -82,21 +82,25 @@ c     .  should never be used.
       endif
       if (sel.gt.2) then
 c     prod(a,sel)-->a
-         lr=sadr(il0+4)
-         err=lr+mn-lstk(bot)
-         if(err.gt.0) then
-            call error(17)
+         if(type.ne.native) then
+            lr=sadr(il0+4)
+            err=lr+mn-lstk(bot)
+            if(err.gt.0) then
+               call error(17)
+               return
+            endif
+            call tpconv(it,0, mn,istk(l1),-1,stk(lr),-1)
+            istk(ilr)=1
+            istk(ilr+1)=m
+            istk(ilr+2)=n
+            istk(ilr+3)=0
+            lstk(top+1)=lr+mn
             return
+         else
+            mr=m
+            nr=n
          endif
-         call tpconv(it,0, mn,istk(l1),-1,stk(lr),-1)
-         istk(ilr)=1
-         istk(ilr+1)=m
-         istk(ilr+2)=n
-         istk(ilr+3)=0
-         lstk(top+1)=lr+mn
-         return
-      endif
-      if(sel.eq.0) then
+      elseif(sel.eq.0) then
          mr=1
          nr=1
       elseif(sel.eq.1) then