diff options
Diffstat (limited to 'modules/overloading/tests')
84 files changed, 3747 insertions, 0 deletions
diff --git a/modules/overloading/tests/nonreg_tests/bug_10180.dia.ref b/modules/overloading/tests/nonreg_tests/bug_10180.dia.ref new file mode 100755 index 000000000..f84ca3586 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10180.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 10180 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10180 +// +// <-- Short Description --> +// det is not defined for sparse matrix +A=[1,2,3;3,4,5;0,0,5]; +sp=sparse(A); +assert_checkequal(det(sp), det(A)); +[e,m]=det(sp); +assert_checkequal(e, 1); +assert_checkequal(m, -1); diff --git a/modules/overloading/tests/nonreg_tests/bug_10180.tst b/modules/overloading/tests/nonreg_tests/bug_10180.tst new file mode 100755 index 000000000..d0b7a5feb --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10180.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 10180 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10180 +// +// <-- Short Description --> +// det is not defined for sparse matrix + +A=[1,2,3;3,4,5;0,0,5]; +sp=sparse(A); +assert_checkequal(det(sp), det(A)); +[e,m]=det(sp); +assert_checkequal(e, 1); +assert_checkequal(m, -1); diff --git a/modules/overloading/tests/nonreg_tests/bug_10305.dia.ref b/modules/overloading/tests/nonreg_tests/bug_10305.dia.ref new file mode 100755 index 000000000..d7a702f61 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10305.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 10305 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10305 +// +// <-- Short Description --> +// Compare lists with empty items is impossible +l1 = list(1,,2); +l2=l1; +assert_checkequal(l1==l2, [%t %f %t]); diff --git a/modules/overloading/tests/nonreg_tests/bug_10305.tst b/modules/overloading/tests/nonreg_tests/bug_10305.tst new file mode 100755 index 000000000..e279a2508 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10305.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + + +// <-- Non-regression test for bug 10305 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10305 +// +// <-- Short Description --> +// Compare lists with empty items is impossible + +l1 = list(1,,2); +l2=l1; +assert_checkequal(l1==l2, [%t %f %t]); diff --git a/modules/overloading/tests/nonreg_tests/bug_10396.dia.ref b/modules/overloading/tests/nonreg_tests/bug_10396.dia.ref new file mode 100755 index 000000000..8d7819d88 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10396.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 10396 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10396 +// +// <-- Short Description --> +// Display of a structure with large matrix took a long time. +a = struct(); +a.toto = zeros(1,100000); +a.titi = zeros(1,100000); +tic(); +a + a = + + toto: [1x100000 constant] + titi: [1x100000 constant] +timeSpent=toc(); +assert_checktrue(timeSpent<1); diff --git a/modules/overloading/tests/nonreg_tests/bug_10396.tst b/modules/overloading/tests/nonreg_tests/bug_10396.tst new file mode 100755 index 000000000..7afb1c558 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10396.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Scilab Enterprises - Sylvestre Ledru +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 10396 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10396 +// +// <-- Short Description --> +// Display of a structure with large matrix took a long time. + +a = struct(); +a.toto = zeros(1,100000); +a.titi = zeros(1,100000); +tic(); +a +timeSpent=toc(); +assert_checktrue(timeSpent<1); diff --git a/modules/overloading/tests/nonreg_tests/bug_10479.dia.ref b/modules/overloading/tests/nonreg_tests/bug_10479.dia.ref new file mode 100755 index 000000000..798088d35 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10479.dia.ref @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - INRIA - Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10479 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10479 +// +// <-- Short Description --> +//The max and min functions where incorrect for N-D array +A=rand(3,3,3); +M=max(A,0.5); +assert_checkequal(M,matrix(max(A(:),0.5),size(A))); +M=max(0.5,A); +assert_checkequal(M,matrix(max(A(:),0.5),size(A))); +B=rand(3,3,3); +M=max(A,B); +assert_checkequal(M,matrix(max(A(:),B(:)),size(A))); +A=matrix(1:27,3,3,3); +assert_checkequal(max(A,'r'),matrix(3:3:27,1,3,3)); +assert_checkequal(max(A,'c'),matrix([7:9 16:18 25:27],3,1,3)); diff --git a/modules/overloading/tests/nonreg_tests/bug_10479.tst b/modules/overloading/tests/nonreg_tests/bug_10479.tst new file mode 100755 index 000000000..11048b683 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10479.tst @@ -0,0 +1,31 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - INRIA - Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10479 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10479 +// +// <-- Short Description --> +//The max and min functions where incorrect for N-D array + +A=rand(3,3,3); +M=max(A,0.5); +assert_checkequal(M,matrix(max(A(:),0.5),size(A))); +M=max(0.5,A); +assert_checkequal(M,matrix(max(A(:),0.5),size(A))); + + +B=rand(3,3,3); +M=max(A,B); +assert_checkequal(M,matrix(max(A(:),B(:)),size(A))); + +A=matrix(1:27,3,3,3); +assert_checkequal(max(A,'r'),matrix(3:3:27,1,3,3)); +assert_checkequal(max(A,'c'),matrix([7:9 16:18 25:27],3,1,3)); diff --git a/modules/overloading/tests/nonreg_tests/bug_10998.dia.ref b/modules/overloading/tests/nonreg_tests/bug_10998.dia.ref new file mode 100755 index 000000000..86234b091 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10998.dia.ref @@ -0,0 +1,52 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10998 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10998 +// +// <-- Short Description --> +// matrix*hypermatrix operation failed. +//--------------------------------------------------- +// Matrix * Hypermatrix +clear +rand("seed", 0); +test1 = rand(3, 3, 3); +test2 = rand(3, 3, 3); +// Multiply a 3x3 matrix by a 3x1x3 hypermatrix. +c = test1(:, :, 1) * test2(:, 2, :); +// Build the expected result. Its size is 3x1x3. +refC = zeros(3, 1, 3); +for i=1:3 + refC(:, :, i) = test1(:, :, 1) * test2(:, 2, i); +end +assert_checkequal(c, refC); +// Now with harder dimensions +test1 = rand(5, 3); +test2 = rand(3, 4, 3); +// Multiply a 5x3 matrix by a 3x2x3 hypermatrix. +c = test1(:, :) * test2(:, 1:2, :); +// Build the expected result. Its size is 5x2x3. +refC = zeros(5, 2, 3); +for i=1:3 + refC(:, :, i) = test1(:, :) * test2(:, 1:2, i); +end +assert_checkequal(c, refC); +//--------------------------------------------------- +// Hypermatrix * Matrix +test1 = rand(4, 3); +// Multiply a 3x4x3 matrix by a 4x3 hypermatrix. +c = test2(:, :, :) * test1(:, :); +// Build the expected result. Its size is 3x3x3. +refC = zeros(3, 3, 3); +for i=1:3 + refC(:, :, i) = test2(:, :, i) * test1(:, :); +end +assert_checkequal(c, refC); diff --git a/modules/overloading/tests/nonreg_tests/bug_10998.tst b/modules/overloading/tests/nonreg_tests/bug_10998.tst new file mode 100755 index 000000000..a1d0753dd --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_10998.tst @@ -0,0 +1,67 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 10998 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10998 +// +// <-- Short Description --> +// matrix*hypermatrix operation failed. + +//--------------------------------------------------- +// Matrix * Hypermatrix + +clear +rand("seed", 0); +test1 = rand(3, 3, 3); +test2 = rand(3, 3, 3); + +// Multiply a 3x3 matrix by a 3x1x3 hypermatrix. +c = test1(:, :, 1) * test2(:, 2, :); + +// Build the expected result. Its size is 3x1x3. +refC = zeros(3, 1, 3); +for i=1:3 + refC(:, :, i) = test1(:, :, 1) * test2(:, 2, i); +end + +assert_checkequal(c, refC); + + +// Now with harder dimensions +test1 = rand(5, 3); +test2 = rand(3, 4, 3); + +// Multiply a 5x3 matrix by a 3x2x3 hypermatrix. +c = test1(:, :) * test2(:, 1:2, :); + +// Build the expected result. Its size is 5x2x3. +refC = zeros(5, 2, 3); +for i=1:3 + refC(:, :, i) = test1(:, :) * test2(:, 1:2, i); +end + +assert_checkequal(c, refC); + + +//--------------------------------------------------- +// Hypermatrix * Matrix + +test1 = rand(4, 3); +// Multiply a 3x4x3 matrix by a 4x3 hypermatrix. +c = test2(:, :, :) * test1(:, :); + +// Build the expected result. Its size is 3x3x3. +refC = zeros(3, 3, 3); +for i=1:3 + refC(:, :, i) = test2(:, :, i) * test1(:, :); +end + +assert_checkequal(c, refC); diff --git a/modules/overloading/tests/nonreg_tests/bug_11139.dia.ref b/modules/overloading/tests/nonreg_tests/bug_11139.dia.ref new file mode 100755 index 000000000..5babcb38c --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_11139.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 11139 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11139 +// +// <-- Short Description --> +// conj is not defined for sparse matrices +A=[complex(1,2), complex(2,3); 0, 0]; +sp_ref=sparse(conj(A)); +sp=conj(sparse(A)); +assert_checkequal(sp,sp_ref); diff --git a/modules/overloading/tests/nonreg_tests/bug_11139.tst b/modules/overloading/tests/nonreg_tests/bug_11139.tst new file mode 100755 index 000000000..24a4f998e --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_11139.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 11139 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11139 +// +// <-- Short Description --> +// conj is not defined for sparse matrices + +A=[complex(1,2), complex(2,3); 0, 0]; +sp_ref=sparse(conj(A)); +sp=conj(sparse(A)); +assert_checkequal(sp,sp_ref); diff --git a/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref b/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref new file mode 100755 index 000000000..6cc74470c --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_11996.dia.ref @@ -0,0 +1,45 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 11996 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11996 +// +// <-- Short Description --> +// Extend eye() to hypermatrix +ref222(:,:,1) = [1,0;0,0]; +ref222(:,:,2) = [0,0;0,1]; +assert_checkequal(eye(rand(2,2,2)), ref222); +ref4445(:,:,1,1) = [1,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0]; +ref4445(:,:,2,1) = zeros(4,4); +ref4445(:,:,3,1) = zeros(4,4); +ref4445(:,:,4,1) = zeros(4,4); +ref4445(:,:,1,2) = zeros(4,4); +ref4445(:,:,2,2) = [0,0,0,0;0,1,0,0;0,0,0,0;0,0,0,0]; +ref4445(:,:,3,2) = zeros(4,4); +ref4445(:,:,4,2) = zeros(4,4); +ref4445(:,:,1,3) = zeros(4,4); +ref4445(:,:,2,3) = zeros(4,4); +ref4445(:,:,3,3) = [0,0,0,0;0,0,0,0;0,0,1,0;0,0,0,0]; +ref4445(:,:,4,3) = zeros(4,4); +ref4445(:,:,1,4) = zeros(4,4); +ref4445(:,:,2,4) = zeros(4,4); +ref4445(:,:,3,4) = zeros(4,4); +ref4445(:,:,4,4) = [0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,1]; +ref4445(:,:,1,5) = zeros(4,4); +ref4445(:,:,2,5) = zeros(4,4); +ref4445(:,:,3,5) = zeros(4,4); +ref4445(:,:,4,5) = zeros(4,4); +assert_checkequal(eye(zeros(4,4,4,5)), ref4445); +M = hypermat([2 3 2 2],1:24); +ref2322(:,:,1,1) = [1,0,0;0,0,0]; +ref2322(:,:,2,1) = zeros(2,3); +ref2322(:,:,1,2) = zeros(2,3); +ref2322(:,:,2,2) = [0,0,0;0,1,0]; +assert_checkequal(eye(M), ref2322); +// Error messages +assert_checkerror("eye(4,4,4)", [], 42); diff --git a/modules/overloading/tests/nonreg_tests/bug_11996.tst b/modules/overloading/tests/nonreg_tests/bug_11996.tst new file mode 100755 index 000000000..cb2e6eedb --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_11996.tst @@ -0,0 +1,49 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 11996 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11996 +// +// <-- Short Description --> +// Extend eye() to hypermatrix + +ref222(:,:,1) = [1,0;0,0]; +ref222(:,:,2) = [0,0;0,1]; +assert_checkequal(eye(rand(2,2,2)), ref222); + +ref4445(:,:,1,1) = [1,0,0,0;0,0,0,0;0,0,0,0;0,0,0,0]; +ref4445(:,:,2,1) = zeros(4,4); +ref4445(:,:,3,1) = zeros(4,4); +ref4445(:,:,4,1) = zeros(4,4); +ref4445(:,:,1,2) = zeros(4,4); +ref4445(:,:,2,2) = [0,0,0,0;0,1,0,0;0,0,0,0;0,0,0,0]; +ref4445(:,:,3,2) = zeros(4,4); +ref4445(:,:,4,2) = zeros(4,4); +ref4445(:,:,1,3) = zeros(4,4); +ref4445(:,:,2,3) = zeros(4,4); +ref4445(:,:,3,3) = [0,0,0,0;0,0,0,0;0,0,1,0;0,0,0,0]; +ref4445(:,:,4,3) = zeros(4,4); +ref4445(:,:,1,4) = zeros(4,4); +ref4445(:,:,2,4) = zeros(4,4); +ref4445(:,:,3,4) = zeros(4,4); +ref4445(:,:,4,4) = [0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,1]; +ref4445(:,:,1,5) = zeros(4,4); +ref4445(:,:,2,5) = zeros(4,4); +ref4445(:,:,3,5) = zeros(4,4); +ref4445(:,:,4,5) = zeros(4,4); +assert_checkequal(eye(zeros(4,4,4,5)), ref4445); + +M = hypermat([2 3 2 2],1:24); +ref2322(:,:,1,1) = [1,0,0;0,0,0]; +ref2322(:,:,2,1) = zeros(2,3); +ref2322(:,:,1,2) = zeros(2,3); +ref2322(:,:,2,2) = [0,0,0;0,1,0]; +assert_checkequal(eye(M), ref2322); +// Error messages +assert_checkerror("eye(4,4,4)", [], 42); diff --git a/modules/overloading/tests/nonreg_tests/bug_12364.dia.ref b/modules/overloading/tests/nonreg_tests/bug_12364.dia.ref new file mode 100755 index 000000000..cdc0f6d1d --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_12364.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 12364 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12364 +// +// <-- Short Description --> +// hypermat.^scalar returned a warning +r=rand(2,3,2); +assert_checktrue(execstr("r.^2","errcatch")==0); diff --git a/modules/overloading/tests/nonreg_tests/bug_12364.tst b/modules/overloading/tests/nonreg_tests/bug_12364.tst new file mode 100755 index 000000000..ea96e57a8 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_12364.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 12364 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12364 +// +// <-- Short Description --> +// hypermat.^scalar returned a warning + +r=rand(2,3,2); +assert_checktrue(execstr("r.^2","errcatch")==0); diff --git a/modules/overloading/tests/nonreg_tests/bug_12863.dia.ref b/modules/overloading/tests/nonreg_tests/bug_12863.dia.ref new file mode 100755 index 000000000..1d1b0d9f6 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_12863.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 12863 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12863 +// +// <-- Short Description --> +// Function size(state-space, "r") does not work +sl = ssrand(3, 2, 4); +assert_checkequal(size(sl), [3, 2]); +assert_checkequal(size(sl, "r"), 3); +assert_checkequal(size(sl, "c"), 2); diff --git a/modules/overloading/tests/nonreg_tests/bug_12863.tst b/modules/overloading/tests/nonreg_tests/bug_12863.tst new file mode 100755 index 000000000..7f9d99ce0 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_12863.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 12863 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12863 +// +// <-- Short Description --> +// Function size(state-space, "r") does not work + +sl = ssrand(3, 2, 4); +assert_checkequal(size(sl), [3, 2]); +assert_checkequal(size(sl, "r"), 3); +assert_checkequal(size(sl, "c"), 2); diff --git a/modules/overloading/tests/nonreg_tests/bug_13177.dia.ref b/modules/overloading/tests/nonreg_tests/bug_13177.dia.ref new file mode 100755 index 000000000..49b7bf251 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13177.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 13177 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13177 +// +// <-- Short Description --> +// Error when changing x_ticks.locations on axe +clf(); +plot(1:10,1:10); +f = gcf(); +f.children(1).x_ticks.labels(1) = "99"; +clf(); +plot(1:10,1:10); +a = gca(); +a.x_ticks.labels(1) = "99"; diff --git a/modules/overloading/tests/nonreg_tests/bug_13177.tst b/modules/overloading/tests/nonreg_tests/bug_13177.tst new file mode 100755 index 000000000..b2e16b0fa --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13177.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 13177 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13177 +// +// <-- Short Description --> +// Error when changing x_ticks.locations on axe + +clf(); +plot(1:10,1:10); +f = gcf(); +f.children(1).x_ticks.labels(1) = "99"; + +clf(); +plot(1:10,1:10); +a = gca(); +a.x_ticks.labels(1) = "99";
\ No newline at end of file diff --git a/modules/overloading/tests/nonreg_tests/bug_13247.dia.ref b/modules/overloading/tests/nonreg_tests/bug_13247.dia.ref new file mode 100755 index 000000000..318a50333 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13247.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// +// <-- Non-regression test for bug 13247 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13247 +// +// <-- Short Description --> +// hypermatrix in structure definition does not work properly +z = zeros(2,2,2); +s.f = z; +assert_checkequal(typeof(s), "st"); +assert_checkequal(s.f, z); diff --git a/modules/overloading/tests/nonreg_tests/bug_13247.tst b/modules/overloading/tests/nonreg_tests/bug_13247.tst new file mode 100755 index 000000000..b6de6d7b9 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13247.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// +// <-- Non-regression test for bug 13247 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13247 +// +// <-- Short Description --> +// hypermatrix in structure definition did not work properly + +z = zeros(2,2,2); +s.f = z; +assert_checkequal(typeof(s), "st"); +assert_checkequal(s.f, z); diff --git a/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref b/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref new file mode 100755 index 000000000..e5a095239 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 13481 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13481 +// +// <-- Short Description --> +// varn did not work on rational fractions +// +// <-- CLI SHELL MODE --> +// Test on a rational fractions +x = poly(0, "x"); +num = 3 + x + x^2; +den = 1 - x + 2*x^2; +R = num / den; +R.dt = 'c'; +assert_checkequal("x", varn(R)); +num = varn(num, "z"); +den = varn(den, "z"); +R2 = varn(R, "z"); +// Check varn created the same num and den +assert_checkequal(num / den, R2.num / R2.den); +// Check dt is kept with varn +assert_checkequal(R.dt, R2.dt); +// Test on matrix of rationals +matrix_R = [R, 2*R + x, R.den/R.num]; +assert_checkequal(varn(matrix_R), "x"); +assert_checkequal(varn(varn(matrix_R, "z")), "z"); diff --git a/modules/overloading/tests/nonreg_tests/bug_13481.tst b/modules/overloading/tests/nonreg_tests/bug_13481.tst new file mode 100755 index 000000000..8fa37c13f --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13481.tst @@ -0,0 +1,43 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 13481 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/13481 +// +// <-- Short Description --> +// varn did not work on rational fractions +// +// <-- CLI SHELL MODE --> + +// Test on a rational fractions + +x = poly(0, "x"); +num = 3 + x + x^2; +den = 1 - x + 2*x^2; + +R = num / den; +R.dt = 'c'; + +assert_checkequal("x", varn(R)); + +num = varn(num, "z"); +den = varn(den, "z"); + +R2 = varn(R, "z"); + +// Check varn created the same num and den +assert_checkequal(num / den, R2.num / R2.den); + +// Check dt is kept with varn +assert_checkequal(R.dt, R2.dt); + +// Test on matrix of rationals +matrix_R = [R, 2*R + x, R.den/R.num]; +assert_checkequal(varn(matrix_R), "x"); +assert_checkequal(varn(varn(matrix_R, "z")), "z"); diff --git a/modules/overloading/tests/nonreg_tests/bug_13507.dia.ref b/modules/overloading/tests/nonreg_tests/bug_13507.dia.ref new file mode 100755 index 000000000..eb3f9e2de --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13507.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 13507 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13507 +// +// <-- Short Description --> +// Imaginary part in result of a power complex was missing. +R = [1,2;3,4]; +c = 1 + 2*%i; +computed = R ^ c; +expected = expm(c*logm(R)); +assert_checkfalse(isreal(computed)); +assert_checkalmostequal(computed, expected); +c = 2 + 0*%i; +computed = R ^ c; +expected = R ^ 2; +assert_checktrue(isreal(computed)); +assert_checkalmostequal(computed, expected); diff --git a/modules/overloading/tests/nonreg_tests/bug_13507.tst b/modules/overloading/tests/nonreg_tests/bug_13507.tst new file mode 100755 index 000000000..676050f4e --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_13507.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Cedric Delamarre +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 13507 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13507 +// +// <-- Short Description --> +// Imaginary part in result of a complex power was missing. + +R = [1,2;3,4]; +c = 1 + 2*%i; + +computed = R ^ c; +expected = expm(c*logm(R)); +assert_checkfalse(isreal(computed)); +assert_checkalmostequal(computed, expected); + +c = 2 + 0*%i; +computed = R ^ c; +expected = R ^ 2; +assert_checktrue(isreal(computed)); +assert_checkalmostequal(computed, expected); diff --git a/modules/overloading/tests/nonreg_tests/bug_1611.dia.ref b/modules/overloading/tests/nonreg_tests/bug_1611.dia.ref new file mode 100755 index 000000000..f90b53eb2 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_1611.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 1611 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1611 +// +// <-- Short Description --> +// untrapped incorrect assignment +my_matrix(1, :) = [4, 5, 6]; +my_list = list(1, 2, 3); +if execstr('my_matrix(1)=mylist','errcatch')==0 then bugmes();quit;end; +if execstr('my_matrix(1,:)=mylist','errcatch')==0 then bugmes();quit;end; diff --git a/modules/overloading/tests/nonreg_tests/bug_1611.tst b/modules/overloading/tests/nonreg_tests/bug_1611.tst new file mode 100755 index 000000000..47e36dcdb --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_1611.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 1611 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1611 +// +// <-- Short Description --> +// untrapped incorrect assignment +my_matrix(1, :) = [4, 5, 6]; +my_list = list(1, 2, 3); + +if execstr('my_matrix(1)=mylist','errcatch')==0 then pause,end; +if execstr('my_matrix(1,:)=mylist','errcatch')==0 then pause,end; diff --git a/modules/overloading/tests/nonreg_tests/bug_2127.dia.ref b/modules/overloading/tests/nonreg_tests/bug_2127.dia.ref new file mode 100755 index 000000000..c86bf3d71 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_2127.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 2127 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2127 +// +// <-- Short Description --> +// Rank-increasing extraction can fail for booleans +T=%t([1 1],[1 1],[1 1]) ; +if or(T(:,:,1)<>[%t %t;%t %t]) then bugmes();quit;end +if or(T(:,:,2)<>[%t %t;%t %t]) then bugmes();quit;end +T=%s([1 1],[1 1],[1 1]) ; +if or(T(:,:,1)<>[%s %s;%s %s]) then bugmes();quit;end +if or(T(:,:,2)<>[%s %s;%s %s]) then bugmes();quit;end +t='x'; +T=t([1 1],[1 1],[1 1]) ; +if or(T(:,:,1)<>[t t;t t]) then bugmes();quit;end +if or(T(:,:,2)<>[t t;t t]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_2127.tst b/modules/overloading/tests/nonreg_tests/bug_2127.tst new file mode 100755 index 000000000..b38f37738 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_2127.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 2127 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2127 +// +// <-- Short Description --> +// Rank-increasing extraction can fail for booleans + +T=%t([1 1],[1 1],[1 1]) ; +if or(T(:,:,1)<>[%t %t;%t %t]) then pause,end +if or(T(:,:,2)<>[%t %t;%t %t]) then pause,end + +T=%s([1 1],[1 1],[1 1]) ; +if or(T(:,:,1)<>[%s %s;%s %s]) then pause,end +if or(T(:,:,2)<>[%s %s;%s %s]) then pause,end + +t='x'; +T=t([1 1],[1 1],[1 1]) ; +if or(T(:,:,1)<>[t t;t t]) then pause,end +if or(T(:,:,2)<>[t t;t t]) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_2153.dia.ref b/modules/overloading/tests/nonreg_tests/bug_2153.dia.ref new file mode 100755 index 000000000..d5b4dd55a --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_2153.dia.ref @@ -0,0 +1,14 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 2153 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2153 +// +// <-- Short Description --> +// addition and subtraction of matrix and hypermatrix of same dimension and size do not work +if execstr("zeros(1,3) + hypermat([1 3])", "errcatch")<>0 then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_2153.tst b/modules/overloading/tests/nonreg_tests/bug_2153.tst new file mode 100755 index 000000000..e19ed7c64 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_2153.tst @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 2153 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2153 +// +// <-- Short Description --> +// addition and subtraction of matrix and hypermatrix of same dimension and size do not work + +if execstr("zeros(1,3) + hypermat([1 3])", "errcatch")<>0 then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref b/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref new file mode 100755 index 000000000..8899f47b1 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 2267 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2267 +// +// <-- Short Description --> +// Wrong error message when ticks locations and labels have not the same sizes +clf(); plot2d(); a=gca(); +errmsg1=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "x_ticks.locations", "x_ticks.labels"); +execstr("a.x_ticks.locations=0:2:6","errcatch"); //assert_checkerror does not catch the error here +assert_checkequal(lasterror(), errmsg1); +execstr("a.x_ticks.labels=string([0:2:6])", "errcatch"); +assert_checkequal(lasterror(), errmsg1); +errmsg2=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "y_ticks.locations", "y_ticks.labels"); +execstr("a.y_ticks.locations=-2:1:2", "errcatch"); +assert_checkequal(lasterror(), errmsg2); +execstr("a.y_ticks.labels=string([-2:1:2])", "errcatch"); +assert_checkequal(lasterror(), errmsg2); +close diff --git a/modules/overloading/tests/nonreg_tests/bug_2267.tst b/modules/overloading/tests/nonreg_tests/bug_2267.tst new file mode 100755 index 000000000..d3f8cc63f --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_2267.tst @@ -0,0 +1,30 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 2267 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2267 +// +// <-- Short Description --> +// Wrong error message when ticks locations and labels have not the same sizes + +clf(); plot2d(); a=gca(); +errmsg1=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "x_ticks.locations", "x_ticks.labels"); +execstr("a.x_ticks.locations=0:2:6","errcatch"); //assert_checkerror does not catch the error here +assert_checkequal(lasterror(), errmsg1); +execstr("a.x_ticks.labels=string([0:2:6])", "errcatch"); +assert_checkequal(lasterror(), errmsg1); + +errmsg2=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "y_ticks.locations", "y_ticks.labels"); +execstr("a.y_ticks.locations=-2:1:2", "errcatch"); +assert_checkequal(lasterror(), errmsg2); +execstr("a.y_ticks.labels=string([-2:1:2])", "errcatch"); +assert_checkequal(lasterror(), errmsg2); +close diff --git a/modules/overloading/tests/nonreg_tests/bug_3121.dia.ref b/modules/overloading/tests/nonreg_tests/bug_3121.dia.ref new file mode 100755 index 000000000..235282bfc --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3121.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 3121 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3121 +// +// <-- Short Description --> +//The error message returned by zeros() when input arguments are not integers is not clear : +if or(zeros(2.1,2.1,2.1)<>zeros(2,2,2)) then bugmes();quit;end +if or(ones(2.1,2.1,2.1)<>ones(2,2,2)) then bugmes();quit;end +if or(size(rand(2.1,2.1,2.1))<>[2 2 2]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_3121.tst b/modules/overloading/tests/nonreg_tests/bug_3121.tst new file mode 100755 index 000000000..1cdd80180 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3121.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 3121 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3121 +// +// <-- Short Description --> +//The error message returned by zeros() when input arguments are not integers is not clear : +if or(zeros(2.1,2.1,2.1)<>zeros(2,2,2)) then pause,end +if or(ones(2.1,2.1,2.1)<>ones(2,2,2)) then pause,end +if or(size(rand(2.1,2.1,2.1))<>[2 2 2]) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_3222.dia.ref b/modules/overloading/tests/nonreg_tests/bug_3222.dia.ref new file mode 100755 index 000000000..d30a76f2e --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3222.dia.ref @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 3222 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3222 +// +// <-- Short Description --> +// indexing problem +clear D;D(1)(2)="3"; +if or(D<>["" "3"]) then bugmes();quit;end +clear D;D(1).x="3"; +if D.x<>"3" then bugmes();quit;end +clear D;D(1,2).x="3"; +if D(1).x<>[] then bugmes();quit;end +if D(2).x<>"3" then bugmes();quit;end +clear D;D.x(1,2)="3"; +if or(D.x<>["" "3"]) then bugmes();quit;end +clear D;D(1,1,2)="3"; +if D(1,1,2)<>"3" then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_3222.tst b/modules/overloading/tests/nonreg_tests/bug_3222.tst new file mode 100755 index 000000000..c402376c4 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3222.tst @@ -0,0 +1,33 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 3222 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3222 +// +// <-- Short Description --> +// indexing problem +clear D;D(1)(2)="3"; +if or(D<>["" "3"]) then pause,end + +clear D;D(1).x="3"; +if D.x<>"3" then pause,end + +clear D;D(1,2).x="3"; +if D(1).x<>[] then pause,end +if D(2).x<>"3" then pause,end + + +clear D;D.x(1,2)="3"; +if or(D.x<>["" "3"]) then pause,end + +clear D;D(1,1,2)="3"; +if D(1,1,2)<>"3" then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_3688.dia.ref b/modules/overloading/tests/nonreg_tests/bug_3688.dia.ref new file mode 100755 index 000000000..9c287a0f7 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3688.dia.ref @@ -0,0 +1,92 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 3688 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3688 +// +// <-- Short Description --> +// The assignment using ":" subscript for a dimension that does not exist +// does not work for hypermatrices +A=[];A(1,1,:) = [-1 3]; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[-1 3]) then bugmes();quit;end +A=[];A(1,1,:) = [-1;3]; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[-1 3]) then bugmes();quit;end +A=[];A(1,2,:) = [-1 3]; +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>[0 0;-1 3]) then bugmes();quit;end +A=[];A(1,2,:) = [-1;3]; +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>[0 0;-1 3]) then bugmes();quit;end +A=[];A(2,1,:) = [-1 3]; +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>[0 0;-1 3]) then bugmes();quit;end +A=[];A(1,:,1) = [-1 3]; +if or(A<>[-1 3]) then bugmes();quit;end +A=[];A(1,:,1) = [-1;3]; +if or(A<>[-1 3]) then bugmes();quit;end +A=[];A(:,1,1) = [-1 3]; +if or(A<>[-1;3]) then bugmes();quit;end +A=[];A(:,1,1) = [-1;3]; +if or(A<>[-1;3]) then bugmes();quit;end +A=[];A(1,:,:) = [-1 3;5 7]; +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>[-1 3;5 7]) then bugmes();quit;end +A=[];A(:,1,:) = [-1 3;5 7]; +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>[-1 3;5 7]) then bugmes();quit;end +A=[];A(1,:,:) = [-1 3 5 7]; +if or(size(A)<>[1 1 4])|or(matrix(A(1,1,:),1,-1)<>[-1 3 5 7]) then bugmes();quit;end +if execstr("A=[];A(1,1:2,:) = [-1 3 5 7];","errcatch")==0 then bugmes();quit;end +A=[];A(1,1,2)=3;A(1,1,1,:)=[-1 3]; +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>[-1 3]) then bugmes();quit;end +A=[];A(1,1,2)=3;A(1,1,1,:)=[-1;3]; +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>[-1 3]) then bugmes();quit;end +A=[];A(1,1,2)=3;A(2,1,1,:)=[-1;3]; +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>[-1 3]) then bugmes();quit;end +//insertion of integer +A=[];A(1,1,:) = int32([-1 3]); +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>int32([-1 3])) then bugmes();quit;end +A=[];A(1,1,:) = int32([-1;3]); +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>int32([-1 3])) then bugmes();quit;end +A=[];A(1,2,:) = int32([-1 3]); +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>int32([0 0;-1 3])) then bugmes();quit;end +A=[];A(1,2,:) = int32([-1;3]); +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>int32([0 0;-1 3])) then bugmes();quit;end +A=[];A(2,1,:) = int32([-1 3]); +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>int32([0 0;-1 3])) then bugmes();quit;end +A=[];A(1,:,1) = int32([-1 3]); +if or(A<>int32([-1 3])) then bugmes();quit;end +A=[];A(1,:,1) = int32([-1;3]); +if or(A<>int32([-1 3])) then bugmes();quit;end +A=[];A(:,1,1) = int32([-1 3]); +if or(A<>int32([-1;3])) then bugmes();quit;end +A=[];A(:,1,1) = int32([-1;3]); +if or(A<>int32([-1;3])) then bugmes();quit;end +A=[];A(1,:,:) = int32([-1 3;5 7]); +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>int32([-1 3;5 7])) then bugmes();quit;end +A=[];A(:,1,:) = int32([-1 3;5 7]); +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>int32([-1 3;5 7])) then bugmes();quit;end +A=[];A(1,:,:) = int32([-1 3 5 7]); +if or(size(A)<>[1 1 4])|or(matrix(A(1,1,:),1,-1)<>int32([-1 3 5 7])) then bugmes();quit;end +if execstr("A=[];A(1,1:2,:) = int32([-1 3 5 7];","errcatch")==0 then bugmes();quit;end +A=[];A(1,1,2)=int32(3);A(1,1,1,:)=int32([-1 3]); +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>int32([-1 3])) then bugmes();quit;end +A=[];A(1,1,2)=int32(3);A(1,1,1,:)=int32([-1;3]); +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>int32([-1 3])) then bugmes();quit;end +A=[];A(1,1,2)=int32(3);A(2,1,1,:)=int32([-1;3]); +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>int32([-1 3])) then bugmes();quit;end +//same should work for other types that uses the same algorithm (generic_i_hm) +//polynomials +A=[];A(1,1,:) = [-1 3]+%s; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[-1 3]+%s) then bugmes();quit;end +A=[];A(1,1,2)=3;A(2,1,1,:)=[-1;3]+%s; +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>[-1 3]+%s) then bugmes();quit;end +//booleans +A=[];A(1,1,:) = [%t %f]; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[%t %f]) then bugmes();quit;end +A=[];A(1,1,2)=%t;A(2,1,1,:)= [%t; %f]; +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>[%t %f]) then bugmes();quit;end +//added because a bug found in %b_i_b.sci +A=%t;A(2,1,1,:)= [%t; %f]; +if or(size(A)<>[2 1 1 2])|or(matrix(A(2,1,1,:),1,-1)<>[%t %f]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_3688.tst b/modules/overloading/tests/nonreg_tests/bug_3688.tst new file mode 100755 index 000000000..49291c08c --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3688.tst @@ -0,0 +1,134 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 3688 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3688 +// +// <-- Short Description --> +// The assignment using ":" subscript for a dimension that does not exist +// does not work for hypermatrices + +A=[];A(1,1,:) = [-1 3]; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[-1 3]) then pause,end + +A=[];A(1,1,:) = [-1;3]; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[-1 3]) then pause,end + +A=[];A(1,2,:) = [-1 3]; +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>[0 0;-1 3]) then pause,end + +A=[];A(1,2,:) = [-1;3]; +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>[0 0;-1 3]) then pause,end + +A=[];A(2,1,:) = [-1 3]; +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>[0 0;-1 3]) then pause,end + + + +A=[];A(1,:,1) = [-1 3]; +if or(A<>[-1 3]) then pause,end + +A=[];A(1,:,1) = [-1;3]; +if or(A<>[-1 3]) then pause,end + +A=[];A(:,1,1) = [-1 3]; +if or(A<>[-1;3]) then pause,end + +A=[];A(:,1,1) = [-1;3]; +if or(A<>[-1;3]) then pause,end + +A=[];A(1,:,:) = [-1 3;5 7]; +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>[-1 3;5 7]) then pause,end + +A=[];A(:,1,:) = [-1 3;5 7]; +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>[-1 3;5 7]) then pause,end + +A=[];A(1,:,:) = [-1 3 5 7]; +if or(size(A)<>[1 1 4])|or(matrix(A(1,1,:),1,-1)<>[-1 3 5 7]) then pause,end + +if execstr("A=[];A(1,1:2,:) = [-1 3 5 7];","errcatch")==0 then pause,end + +A=[];A(1,1,2)=3;A(1,1,1,:)=[-1 3]; +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>[-1 3]) then pause,end + +A=[];A(1,1,2)=3;A(1,1,1,:)=[-1;3]; +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>[-1 3]) then pause,end + +A=[];A(1,1,2)=3;A(2,1,1,:)=[-1;3]; +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>[-1 3]) then pause,end + +//insertion of integer +A=[];A(1,1,:) = int32([-1 3]); +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>int32([-1 3])) then pause,end + +A=[];A(1,1,:) = int32([-1;3]); +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>int32([-1 3])) then pause,end + +A=[];A(1,2,:) = int32([-1 3]); +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>int32([0 0;-1 3])) then pause,end + +A=[];A(1,2,:) = int32([-1;3]); +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>int32([0 0;-1 3])) then pause,end + +A=[];A(2,1,:) = int32([-1 3]); +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>int32([0 0;-1 3])) then pause,end + +A=[];A(1,:,1) = int32([-1 3]); +if or(A<>int32([-1 3])) then pause,end + +A=[];A(1,:,1) = int32([-1;3]); +if or(A<>int32([-1 3])) then pause,end + +A=[];A(:,1,1) = int32([-1 3]); +if or(A<>int32([-1;3])) then pause,end + +A=[];A(:,1,1) = int32([-1;3]); +if or(A<>int32([-1;3])) then pause,end + + +A=[];A(1,:,:) = int32([-1 3;5 7]); +if or(size(A)<>[1 2 2])|or(matrix(A(1,:,:),2,-1)<>int32([-1 3;5 7])) then pause,end + +A=[];A(:,1,:) = int32([-1 3;5 7]); +if or(size(A)<>[2 1 2])|or(matrix(A(:,1,:),2,-1)<>int32([-1 3;5 7])) then pause,end + +A=[];A(1,:,:) = int32([-1 3 5 7]); +if or(size(A)<>[1 1 4])|or(matrix(A(1,1,:),1,-1)<>int32([-1 3 5 7])) then pause,end + +if execstr("A=[];A(1,1:2,:) = int32([-1 3 5 7];","errcatch")==0 then pause,end + +A=[];A(1,1,2)=int32(3);A(1,1,1,:)=int32([-1 3]); +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>int32([-1 3])) then pause,end + +A=[];A(1,1,2)=int32(3);A(1,1,1,:)=int32([-1;3]); +if or(size(A)<>[1 1 2 2])|or(matrix(A(1,1,1,:),1,-1)<>int32([-1 3])) then pause,end + +A=[];A(1,1,2)=int32(3);A(2,1,1,:)=int32([-1;3]); +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>int32([-1 3])) then pause,end + +//same should work for other types that uses the same algorithm (generic_i_hm) +//polynomials +A=[];A(1,1,:) = [-1 3]+%s; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[-1 3]+%s) then pause,end + +A=[];A(1,1,2)=3;A(2,1,1,:)=[-1;3]+%s; +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>[-1 3]+%s) then pause,end + +//booleans +A=[];A(1,1,:) = [%t %f]; +if or(size(A)<>[1 1 2])|or(matrix(A(1,1,:),1,-1)<>[%t %f]) then pause,end + +A=[];A(1,1,2)=%t;A(2,1,1,:)= [%t; %f]; +if or(size(A)<>[2 1 2 2])|or(matrix(A(2,1,1,:),1,-1)<>[%t %f]) then pause,end + +//added because a bug found in %b_i_b.sci +A=%t;A(2,1,1,:)= [%t; %f]; +if or(size(A)<>[2 1 1 2])|or(matrix(A(2,1,1,:),1,-1)<>[%t %f]) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_3833.dia.ref b/modules/overloading/tests/nonreg_tests/bug_3833.dia.ref new file mode 100755 index 000000000..7125b7261 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3833.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 3833 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3833 +// +// <-- Short Description --> +// Assignment operator for cell structs storing matrices for indices greater than 1 overwrites all previous values and reinitialises the entries instead. +// Workaround was to extract the matrix from entries, update the matrix externally and re-assign the entire updated matrix into the specific cell entry. +// This is however not expedient when dealing with large structs and matrices. +g = cell(2,1); +g(2).entries = [1,2;3,4]; +if or(g(2).entries <> [1,2;3,4]) then bugmes();quit;end +g(2).entries(1,1) = 9; +if or(g(2).entries <> [9,2;3,4]) then bugmes();quit;end +g(2).entries(1,2) = 10; +if or(g(2).entries <> [9,10;3,4]) then bugmes();quit;end +g(2).entries(2,1) = 11; +if or(g(2).entries <> [9,10;11,4]) then bugmes();quit;end +g(2).entries(2,2) = 12; +if or(g(2).entries <> [9,10;11,12]) then bugmes();quit;end +g(2).entries(1) = 111; +if or(g(2).entries <> [111,10;11,12]) then bugmes();quit;end +g(2).entries(3) = 222; +if or(g(2).entries <> [111,222;11,12]) then bugmes();quit;end +g(2).entries(2) = 333; +if or(g(2).entries <> [111,222;333,12]) then bugmes();quit;end +g(2).entries(4) = 444; +if or(g(2).entries <> [111,222;333,444]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_3833.tst b/modules/overloading/tests/nonreg_tests/bug_3833.tst new file mode 100755 index 000000000..63b29844b --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_3833.tst @@ -0,0 +1,38 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 3833 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3833 +// +// <-- Short Description --> +// Assignment operator for cell structs storing matrices for indices greater than 1 overwrites all previous values and reinitialises the entries instead. +// Workaround was to extract the matrix from entries, update the matrix externally and re-assign the entire updated matrix into the specific cell entry. +// This is however not expedient when dealing with large structs and matrices. + +g = cell(2,1); +g(2).entries = [1,2;3,4]; +if or(g(2).entries <> [1,2;3,4]) then pause; end +g(2).entries(1,1) = 9; +if or(g(2).entries <> [9,2;3,4]) then pause; end +g(2).entries(1,2) = 10; +if or(g(2).entries <> [9,10;3,4]) then pause; end +g(2).entries(2,1) = 11; +if or(g(2).entries <> [9,10;11,4]) then pause; end +g(2).entries(2,2) = 12; +if or(g(2).entries <> [9,10;11,12]) then pause; end +g(2).entries(1) = 111; +if or(g(2).entries <> [111,10;11,12]) then pause; end +g(2).entries(3) = 222; +if or(g(2).entries <> [111,222;11,12]) then pause; end +g(2).entries(2) = 333; +if or(g(2).entries <> [111,222;333,12]) then pause; end +g(2).entries(4) = 444; +if or(g(2).entries <> [111,222;333,444]) then pause; end + + diff --git a/modules/overloading/tests/nonreg_tests/bug_4266.dia.ref b/modules/overloading/tests/nonreg_tests/bug_4266.dia.ref new file mode 100755 index 000000000..a8d79b1c8 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4266.dia.ref @@ -0,0 +1,41 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4266 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4266 +// +// <-- Short Description --> +// ones, rand, zeros functions do not remove highest dimensions equal to 1. +a=ones(2,2,1); +if or(size(a)<>[2 2]) then bugmes();quit;end +a=ones(2,2,1,1); +if or(size(a)<>[2 2]) then bugmes();quit;end +if or(a<>ones(2,2)) then bugmes();quit;end +a=ones(2,2,2); +if or(size(a)<>[2 2 2]) then bugmes();quit;end +a=zeros(2,2,1); +if or(size(a)<>[2 2]) then bugmes();quit;end +a=zeros(2,2,1,1); +if or(size(a)<>[2 2]) then bugmes();quit;end +if or(a<>zeros(2,2)) then bugmes();quit;end +a=zeros(2,2,2); +if or(size(a)<>[2 2 2]) then bugmes();quit;end +a=rand(2,2,1); +if or(size(a)<>[2 2]) then bugmes();quit;end +a=rand(2,2,1,1); +if or(size(a)<>[2 2]) then bugmes();quit;end +if or(a<>a(:,:)) then bugmes();quit;end +a=rand(2,2,2); +if or(size(a)<>[2 2 2]) then bugmes();quit;end +a=rand(2,2,1,'normal'); +if or(size(a)<>[2 2]) then bugmes();quit;end +a=rand(2,2,1,1,'normal'); +if or(size(a)<>[2 2]) then bugmes();quit;end +if or(a<>a(:,:)) then bugmes();quit;end +a=rand(2,2,2,'normal'); +if or(size(a)<>[2 2 2]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_4266.tst b/modules/overloading/tests/nonreg_tests/bug_4266.tst new file mode 100755 index 000000000..99a926164 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4266.tst @@ -0,0 +1,48 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4266 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4266 +// +// <-- Short Description --> +// ones, rand, zeros functions do not remove highest dimensions equal to 1. +a=ones(2,2,1); +if or(size(a)<>[2 2]) then pause,end +a=ones(2,2,1,1); +if or(size(a)<>[2 2]) then pause,end +if or(a<>ones(2,2)) then pause,end +a=ones(2,2,2); +if or(size(a)<>[2 2 2]) then pause,end + +a=zeros(2,2,1); +if or(size(a)<>[2 2]) then pause,end +a=zeros(2,2,1,1); +if or(size(a)<>[2 2]) then pause,end +if or(a<>zeros(2,2)) then pause,end +a=zeros(2,2,2); +if or(size(a)<>[2 2 2]) then pause,end + +a=rand(2,2,1); +if or(size(a)<>[2 2]) then pause,end +a=rand(2,2,1,1); +if or(size(a)<>[2 2]) then pause,end +if or(a<>a(:,:)) then pause,end +a=rand(2,2,2); +if or(size(a)<>[2 2 2]) then pause,end + + +a=rand(2,2,1,'normal'); +if or(size(a)<>[2 2]) then pause,end +a=rand(2,2,1,1,'normal'); +if or(size(a)<>[2 2]) then pause,end +if or(a<>a(:,:)) then pause,end +a=rand(2,2,2,'normal'); +if or(size(a)<>[2 2 2]) then pause,end + + diff --git a/modules/overloading/tests/nonreg_tests/bug_4646.dia.ref b/modules/overloading/tests/nonreg_tests/bug_4646.dia.ref new file mode 100755 index 000000000..ac634560d --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4646.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4266 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4266 +// +// <-- Short Description --> +// assigning a string to an element of a matrix of numbers gives an error. +a=zeros(1,5); +if execstr('a(1)=''a'';','errcatch')==0 then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_4646.tst b/modules/overloading/tests/nonreg_tests/bug_4646.tst new file mode 100755 index 000000000..c7419f6a2 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4646.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4266 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4266 +// +// <-- Short Description --> +// assigning a string to an element of a matrix of numbers gives an error. +a=zeros(1,5); +if execstr('a(1)=''a'';','errcatch')==0 then pause,end + diff --git a/modules/overloading/tests/nonreg_tests/bug_4806.dia.ref b/modules/overloading/tests/nonreg_tests/bug_4806.dia.ref new file mode 100755 index 000000000..6cf601d72 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4806.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4806 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4806 +// +// <-- Short Description --> +// If A is a sparse matrix, A^0 returns A and not the identity matrix as expected. +A=sparse(matrix(1:9,3,3)); +assert_checkequal(A^0,speye(A)); diff --git a/modules/overloading/tests/nonreg_tests/bug_4806.tst b/modules/overloading/tests/nonreg_tests/bug_4806.tst new file mode 100755 index 000000000..1a96a5ced --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4806.tst @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4806 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4806 +// +// <-- Short Description --> +// If A is a sparse matrix, A^0 returns A and not the identity matrix as expected. +A=sparse(matrix(1:9,3,3)); +assert_checkequal(A^0,speye(A)); diff --git a/modules/overloading/tests/nonreg_tests/bug_4826.dia.ref b/modules/overloading/tests/nonreg_tests/bug_4826.dia.ref new file mode 100755 index 000000000..717fe216b --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4826.dia.ref @@ -0,0 +1,30 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4826 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4826 +// +// <-- Short Description --> +// The type of the 'dims' entry of an hypermat is not always the same. +a=[1 2;3 4]; +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then bugmes();quit;end +if size(A.dims,1)<>1 then bugmes();quit;end +a=int8([1 2;3 4]); +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then bugmes();quit;end +if size(A.dims,1)<>1 then bugmes();quit;end +a = []; +a(1,1)= %s; +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then bugmes();quit;end +if size(A.dims,1)<>1 then bugmes();quit;end +a=['1' '2';'3' '4']; +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then bugmes();quit;end +if size(A.dims,1)<>1 then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_4826.tst b/modules/overloading/tests/nonreg_tests/bug_4826.tst new file mode 100755 index 000000000..581200a12 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_4826.tst @@ -0,0 +1,35 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4826 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4826 +// +// <-- Short Description --> +// The type of the 'dims' entry of an hypermat is not always the same. + +a=[1 2;3 4]; +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then pause,end +if size(A.dims,1)<>1 then pause,end + +a=int8([1 2;3 4]); +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then pause,end +if size(A.dims,1)<>1 then pause,end + +a = []; +a(1,1)= %s; +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then pause,end +if size(A.dims,1)<>1 then pause,end + +a=['1' '2';'3' '4']; +A=a(:,:,[1 1]); +if typeof(A.dims)<>"int32" then pause,end +if size(A.dims,1)<>1 then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_6305.dia.ref b/modules/overloading/tests/nonreg_tests/bug_6305.dia.ref new file mode 100755 index 000000000..e3e1a68d6 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6305.dia.ref @@ -0,0 +1,64 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 6305 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6305 +// +// <-- Short Description --> +// dsearch does not work with integers, hypermatrices and strings +indref_d = [1,0, 0, 2; 2, 0, 0, 0; 0, 0, 2, 0; 4, 3, 0, 0]; +occref_d = [1, 3, 1, 1]; +inforef_d = 10; +indref_c = [1, 2, 2, 1; 1, 0, 0, 0; 0, 0, 1, 0; 3, 2, 3, 3]; +occref_c = [4, 3, 3]; +inforef_c = 6; +I = [3, 5, 6, 4; 4, 1, 2, 11; 1, 11, 4, 0; 10, 7, 9 9]; +// Integers +I_int8 = int8(I); +[ind, occ, info] = dsearch(I_int8, int8([3 4 7 10]),"d"); +assert_checkequal(ind, indref_d); +assert_checkequal(occ, occref_d); +assert_checkequal(info, inforef_d); +[ind, occ, info] = dsearch(I_int8, int8([3 4 7 10]), "c"); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, occref_c); +assert_checkequal(info, inforef_c); +[ind, occ, info] = dsearch(I_int8, int8([3 4 7 10])); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, occref_c); +assert_checkequal(info, inforef_c); +// Strings +[ind, occ, info] = dsearch(["K", "M", "a", "g", "E", "b", "I"], ["E", "K", "O", "T"], "c"); +assert_checkequal(ind, [1 2 0 0 1 0 1]); +assert_checkequal(occ, [3 1 0]); +assert_checkequal(info, 3); +[ind, occ, info] = dsearch(["K", "M", "a", "g", "E", "b", "I"], ["E", "K", "O", "T"], "d"); +assert_checkequal(ind, [2 0 0 0 1 0 0]); +assert_checkequal(occ, [1 1 0 0]); +assert_checkequal(info, 5); +[ind, occ, info] = dsearch(["K", "M", "a", "g", "E", "b", "I"], ["E", "K", "O", "T"]); +assert_checkequal(ind, [1 2 0 0 1 0 1]); +assert_checkequal(occ, [3 1 0]); +assert_checkequal(info, 3); +// Hypermatrices +I_hm(:,:,1) = I; +I_hm(:,:,2) = I; +indref_d(:,:,2) = indref_d; +indref_c(:,:,2) = indref_c; +[ind, occ, info] = dsearch(I_hm, [3 4 7 10], "d"); +assert_checkequal(ind, indref_d); +assert_checkequal(occ, 2*occref_d); +assert_checkequal(info, 2*inforef_d); +[ind, occ, info] = dsearch(I_hm, [3 4 7 10], "c"); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, 2*occref_c); +assert_checkequal(info, 2*inforef_c); +[ind, occ, info] = dsearch(I_hm, [3 4 7 10]); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, 2*occref_c); +assert_checkequal(info, 2*inforef_c); diff --git a/modules/overloading/tests/nonreg_tests/bug_6305.tst b/modules/overloading/tests/nonreg_tests/bug_6305.tst new file mode 100755 index 000000000..7c18551d2 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6305.tst @@ -0,0 +1,72 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + + +// <-- Non-regression test for bug 6305 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6305 +// +// <-- Short Description --> +// dsearch does not work with integers, hypermatrices and strings + +indref_d = [1,0, 0, 2; 2, 0, 0, 0; 0, 0, 2, 0; 4, 3, 0, 0]; +occref_d = [1, 3, 1, 1]; +inforef_d = 10; +indref_c = [1, 2, 2, 1; 1, 0, 0, 0; 0, 0, 1, 0; 3, 2, 3, 3]; +occref_c = [4, 3, 3]; +inforef_c = 6; +I = [3, 5, 6, 4; 4, 1, 2, 11; 1, 11, 4, 0; 10, 7, 9 9]; + +// Integers +I_int8 = int8(I); +[ind, occ, info] = dsearch(I_int8, int8([3 4 7 10]),"d"); +assert_checkequal(ind, indref_d); +assert_checkequal(occ, occref_d); +assert_checkequal(info, inforef_d); +[ind, occ, info] = dsearch(I_int8, int8([3 4 7 10]), "c"); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, occref_c); +assert_checkequal(info, inforef_c); +[ind, occ, info] = dsearch(I_int8, int8([3 4 7 10])); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, occref_c); +assert_checkequal(info, inforef_c); + +// Strings +[ind, occ, info] = dsearch(["K", "M", "a", "g", "E", "b", "I"], ["E", "K", "O", "T"], "c"); +assert_checkequal(ind, [1 2 0 0 1 0 1]); +assert_checkequal(occ, [3 1 0]); +assert_checkequal(info, 3); + +[ind, occ, info] = dsearch(["K", "M", "a", "g", "E", "b", "I"], ["E", "K", "O", "T"], "d"); +assert_checkequal(ind, [2 0 0 0 1 0 0]); +assert_checkequal(occ, [1 1 0 0]); +assert_checkequal(info, 5); + +[ind, occ, info] = dsearch(["K", "M", "a", "g", "E", "b", "I"], ["E", "K", "O", "T"]); +assert_checkequal(ind, [1 2 0 0 1 0 1]); +assert_checkequal(occ, [3 1 0]); +assert_checkequal(info, 3); + +// Hypermatrices +I_hm(:,:,1) = I; +I_hm(:,:,2) = I; +indref_d(:,:,2) = indref_d; +indref_c(:,:,2) = indref_c; +[ind, occ, info] = dsearch(I_hm, [3 4 7 10], "d"); +assert_checkequal(ind, indref_d); +assert_checkequal(occ, 2*occref_d); +assert_checkequal(info, 2*inforef_d); +[ind, occ, info] = dsearch(I_hm, [3 4 7 10], "c"); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, 2*occref_c); +assert_checkequal(info, 2*inforef_c); +[ind, occ, info] = dsearch(I_hm, [3 4 7 10]); +assert_checkequal(ind, indref_c); +assert_checkequal(occ, 2*occref_c); +assert_checkequal(info, 2*inforef_c); diff --git a/modules/overloading/tests/nonreg_tests/bug_6698.dia.ref b/modules/overloading/tests/nonreg_tests/bug_6698.dia.ref new file mode 100755 index 000000000..a5552b1d3 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6698.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 20010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 6698 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 6698 +// +// <-- Short Description --> +// isreal does not work on hypermatrix +A = ones(2,2,2); +if or(~isreal(A)) then bugmes();quit;end +if or(~isreal(A,0)) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_6698.tst b/modules/overloading/tests/nonreg_tests/bug_6698.tst new file mode 100755 index 000000000..2efe05bc9 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6698.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 20010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 6698 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 6698 +// +// <-- Short Description --> +// isreal does not work on hypermatrix +A = ones(2,2,2); +if or(~isreal(A)) then pause,end +if or(~isreal(A,0)) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_6832.dia.ref b/modules/overloading/tests/nonreg_tests/bug_6832.dia.ref new file mode 100755 index 000000000..839e01bdb --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6832.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 6832 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6832 +// +// <-- Short Description --> +// Matrices of rationals can now be transposed via the " .' " operator. +num = (%z-%i).^grand(2, 4, "uin", 0, 2); +den = (%z+%i).^grand(2, 4, "uin", 0, 2); +R = num ./ den; +refR = ones(4, 2); +// Manually transposing R +for i=1:4 + refR(i, 1) = R(1, i); + refR(i, 2) = R(2, i); +end +assert_checkequal(R.', refR); diff --git a/modules/overloading/tests/nonreg_tests/bug_6832.tst b/modules/overloading/tests/nonreg_tests/bug_6832.tst new file mode 100755 index 000000000..22846bdf0 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6832.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 6832 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6832 +// +// <-- Short Description --> +// Matrices of rationals can now be transposed via the " .' " operator. + +num = (%z-%i).^grand(2, 4, "uin", 0, 2); +den = (%z+%i).^grand(2, 4, "uin", 0, 2); +R = num ./ den; +refR = ones(4, 2); + +// Manually transposing R +for i=1:4 + refR(i, 1) = R(1, i); + refR(i, 2) = R(2, i); +end + +assert_checkequal(R.', refR); diff --git a/modules/overloading/tests/nonreg_tests/bug_6990.dia.ref b/modules/overloading/tests/nonreg_tests/bug_6990.dia.ref new file mode 100755 index 000000000..bf5c17bf8 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6990.dia.ref @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 20010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 6990 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 6990 +// +// <-- Short Description --> +// and and or does not work on hypermatrix +A=matrix([%f;%t;%f;%f;%t;%t;%t;%t;%t;%f;%t;%t;%t;%f;%t;%t;%t;%t;%t;%t;%f;%f;%t;%t],2,3,4); +if or(and(A,1)<>matrix([%f;%f;%t;%t;%f;%t;%f;%t;%t;%t;%f;%t],1,3,4)) then bugmes();quit;end +if or(and(A,2)<>matrix([%f;%f;%t;%f;%t;%f;%f;%f],2,1,4)) then bugmes();quit;end +if or(and(A,3)<>[%f,%f,%t;%f,%f,%t]) then bugmes();quit;end +B=matrix([%f;%t;%f;%f;%f;%t;%t;%t;%f;%f;%t;%t;%t;%f;%f;%t;%t;%t;%f;%t;%f;%f;%f;%t],2,3,4); +if or(or(B,1)<>matrix([%t;%f;%t;%t;%f;%t;%t;%t;%t;%t;%f;%t],1,3,4)) then bugmes();quit;end +if or(or(B,2)<>matrix([%f;%t;%t;%t;%t;%t;%f;%t],2,1,4)) then bugmes();quit;end +if or(or(B,3)<>[%t,%f,%t;%t,%t,%t]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_6990.tst b/modules/overloading/tests/nonreg_tests/bug_6990.tst new file mode 100755 index 000000000..4b60330d2 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_6990.tst @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 6990 --> +// <-- CLI SHELL MODE --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 6990 +// +// <-- Short Description --> +// "and" and "or" does not work on hypermatrices +A=matrix([%f;%t;%f;%f;%t;%t;%t;%t;%t;%f;%t;%t;%t;%f;%t;%t;%t;%t;%t;%t;%f;%f;%t;%t],2,3,4); +if or(and(A,1)<>matrix([%f;%f;%t;%t;%f;%t;%f;%t;%t;%t;%f;%t],1,3,4)) then pause,end +if or(and(A,2)<>matrix([%f;%f;%t;%f;%t;%f;%f;%f],2,1,4)) then pause,end +if or(and(A,3)<>[%f,%f,%t;%f,%f,%t]) then pause,end + + +B=matrix([%f;%t;%f;%f;%f;%t;%t;%t;%f;%f;%t;%t;%t;%f;%f;%t;%t;%t;%f;%t;%f;%f;%f;%t],2,3,4); +if or(or(B,1)<>matrix([%t;%f;%t;%t;%f;%t;%t;%t;%t;%t;%f;%t],1,3,4)) then pause,end +if or(or(B,2)<>matrix([%f;%t;%t;%t;%t;%t;%f;%t],2,1,4)) then pause,end +if or(or(B,3)<>[%t,%f,%t;%t,%t,%t]) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref b/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref new file mode 100755 index 000000000..1c21b1404 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref @@ -0,0 +1,39 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 7042 --> +// +// <-- CLI SHELL MODE --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 7042 +// +// <-- Short Description --> +// insertion of an empty matrix into a struct (to remove a row or column) +// is buggy when multiple index is used +d11=struct('day',25,'month' ,'DEC','year',2006); +d12=struct('day',2,'month' ,'DEC','year',2006); +d21=struct('day',8,'month' ,'Feb','year',2010); +d22=struct('day',12,'month' ,'Feb','year',2010); +d=[d11 d12;d21 d22]; +dd=d; +dd(1,:)=[]; +if or(dd<>d(2,:)) then bugmes();quit;end +dd=d; +dd(:,2)=[]; +if or(dd<>d(:,1)) then bugmes();quit;end +dd=d; +dd(:,:)=[]; +if or(size(dd)<>0) then bugmes();quit;end +dd=d; +dd(1)=[]; +if or(dd<>d(2:4)) then bugmes();quit;end +dd=d; +dd(1,1,3)=d11; +dd(:,:,3)=[]; +if or(size(dd)<>[2 2 2]) then bugmes();quit;end +if or(dd(:,:,1)<>d) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_7042.tst b/modules/overloading/tests/nonreg_tests/bug_7042.tst new file mode 100755 index 000000000..b854268e8 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7042.tst @@ -0,0 +1,45 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 7042 --> +// +// <-- CLI SHELL MODE --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 7042 +// +// <-- Short Description --> +// insertion of an empty matrix into a struct (to remove a row or column) +// is buggy when multiple index is used +d11=struct('day',25,'month' ,'DEC','year',2006); +d12=struct('day',2,'month' ,'DEC','year',2006); +d21=struct('day',8,'month' ,'Feb','year',2010); +d22=struct('day',12,'month' ,'Feb','year',2010); + +d=[d11 d12;d21 d22]; + +dd=d; +dd(1,:)=[]; +if or(dd<>d(2,:)) then pause,end + +dd=d; +dd(:,2)=[]; +if or(dd<>d(:,1)) then pause,end + +dd=d; +dd(:,:)=[]; +if or(size(dd)<>0) then pause,end + +dd=d; +dd(1)=[]; +if or(dd<>d(2:4)) then pause,end + +dd=d; +dd(1,1,3)=d11; +dd(:,:,3)=[]; +if or(size(dd)<>[2 2 2]) then pause,end +if or(dd(:,:,1)<>d) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_7244.dia.ref b/modules/overloading/tests/nonreg_tests/bug_7244.dia.ref new file mode 100755 index 000000000..9d1677dfe --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7244.dia.ref @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 7244 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7244 +// +// <-- Short Description --> +// Extraction from a struct array with a boolean vector had a strange behavior. +foo(1).bar = 1; +foo(2).bar = 2; +foo(3).bar = 3; // 3x1 struct array with field: bar. +foo = foo([%T %F %T]); // 2x1 struct array with field: bar. +assert_checkequal(type(foo), 17); +foo(3).bar = 2; +assert_checkequal(foo.bar(1), 1); +assert_checkequal(foo.bar(2), 3); +assert_checkequal(foo.bar(3), 2); diff --git a/modules/overloading/tests/nonreg_tests/bug_7244.tst b/modules/overloading/tests/nonreg_tests/bug_7244.tst new file mode 100755 index 000000000..4c7bb52eb --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7244.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Paul Bignier +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 7244 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7244 +// +// <-- Short Description --> +// Extraction from a struct array with a boolean vector had a strange behavior. + +foo(1).bar = 1; +foo(2).bar = 2; +foo(3).bar = 3; // 3x1 struct array with field: bar. +foo = foo([%T %F %T]); // 2x1 struct array with field: bar. +assert_checkequal(type(foo), 17); + +foo(3).bar = 2; +assert_checkequal(foo.bar(1), 1); +assert_checkequal(foo.bar(2), 3); +assert_checkequal(foo.bar(3), 2); diff --git a/modules/overloading/tests/nonreg_tests/bug_7714.dia.ref b/modules/overloading/tests/nonreg_tests/bug_7714.dia.ref new file mode 100755 index 000000000..c62034a54 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7714.dia.ref @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 7714 --> +// +// <-- CLI SHELL MODE --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 7714 +// +// <-- Short Description --> +// diag, triu, tril applyed to rational matrices may change the formal variable name +h=[1/%s,1/%s;1/%s,1]; +if or(triu(h)<>[1/%s,1/%s;0,1]) then bugmes();quit;end +if or(tril(h)<>[1/%s,0;1/%s,1]) then bugmes();quit;end +if or(diag(h)<>[1/%s;1]) then bugmes();quit;end +if or(diag([1/%s;1])<>[1/%s,0;0,1]) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_7714.tst b/modules/overloading/tests/nonreg_tests/bug_7714.tst new file mode 100755 index 000000000..1ca6613d3 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7714.tst @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 7714 --> +// +// <-- CLI SHELL MODE --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id= 7714 +// +// <-- Short Description --> +// diag, triu, tril applyed to rational matrices may change the formal variable name + + +h=[1/%s,1/%s;1/%s,1]; + +if or(triu(h)<>[1/%s,1/%s;0,1]) then pause,end +if or(tril(h)<>[1/%s,0;1/%s,1]) then pause,end +if or(diag(h)<>[1/%s;1]) then pause,end +if or(diag([1/%s;1])<>[1/%s,0;0,1]) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_7900.dia.ref b/modules/overloading/tests/nonreg_tests/bug_7900.dia.ref new file mode 100755 index 000000000..1057ccddb --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7900.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 7900 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7900 +// +// <-- Short Description --> +// inserting a rational in a rational hymermatrix may generate invalid rationals entries (with zero denominators) +H(1,1,2)=1/%s; +H(2,1,2)=1/%s; +if or(H.den(:)==0) then bugmes();quit;end diff --git a/modules/overloading/tests/nonreg_tests/bug_7900.tst b/modules/overloading/tests/nonreg_tests/bug_7900.tst new file mode 100755 index 000000000..256bc5004 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_7900.tst @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 7900 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7900 +// +// <-- Short Description --> +// inserting a rational in a rational hymermatrix may generate invalid rationals entries (with zero denominators) + +H(1,1,2)=1/%s; +H(2,1,2)=1/%s; +if or(H.den(:)==0) then pause,end diff --git a/modules/overloading/tests/nonreg_tests/bug_8098.dia.ref b/modules/overloading/tests/nonreg_tests/bug_8098.dia.ref new file mode 100755 index 000000000..84f82b81e --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_8098.dia.ref @@ -0,0 +1,47 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 8098 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8098 +// +// <-- Short Description --> +// cumsum() did not apply to rational matrices. +// ============================================================================= +s = poly(0, "s"); +r = [1/s 1/s; 1/s^2 1]; +assert_checkequal(cumsum(r), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r,"*"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r, 1), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, 2), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "r"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, "c"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "m"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r,"native"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r,"double"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r,"*", "native"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r, 1, "native"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, 2, "native"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "r", "native"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, "c", "native"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "m", "native"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r,"*", "double"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r, 1, "double"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, 2, "double"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "r", "double"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, "c", "double"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "m", "double"), [1 1;1+s 1+s]./[s s;s^2 s]); +// Check error +assert_checkfalse(execstr("cumsum(r, ""toto"")" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),.. + "cumsum",2,"""*"",""r"",""c"",""m"""); +assert_checkerror("cumsum(r, ""toto"")", refMsg); +a = cumsum([1/%z %z/(1+2*%z)]); +assert_checkequal(a, [1/%z (1+2*%z+%z^2)/(%z+2*%z^2)]); +a = cumsum([1/%z %z/(1+2*%z)]'); +assert_checkequal(a, [1/%z (1+2*%z+%z^2)/(%z+2*%z^2)]'); diff --git a/modules/overloading/tests/nonreg_tests/bug_8098.tst b/modules/overloading/tests/nonreg_tests/bug_8098.tst new file mode 100755 index 000000000..b33d09d07 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_8098.tst @@ -0,0 +1,54 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 8098 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8098 +// +// <-- Short Description --> +// cumsum() did not apply to rational matrices. +// ============================================================================= + +s = poly(0, "s"); +r = [1/s 1/s; 1/s^2 1]; + +assert_checkequal(cumsum(r), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r,"*"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r, 1), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, 2), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "r"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, "c"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "m"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r,"native"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r,"double"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r,"*", "native"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r, 1, "native"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, 2, "native"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "r", "native"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, "c", "native"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "m", "native"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r,"*", "double"), [1 1+2*s;1+s 1+2*s+s^2]./[s s^2;s^2 s^2]); +assert_checkequal(cumsum(r, 1, "double"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, 2, "double"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "r", "double"), [1 1;1+s 1+s]./[s s;s^2 s]); +assert_checkequal(cumsum(r, "c", "double"), [1 2;1 1+s^2]./[s s;s^2 s^2]); +assert_checkequal(cumsum(r, "m", "double"), [1 1;1+s 1+s]./[s s;s^2 s]); + +// Check error +assert_checkfalse(execstr("cumsum(r, ""toto"")" ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong value for input argument #%d: Must be in the set {%s}.\n"),.. + "cumsum",2,"""*"",""r"",""c"",""m"""); +assert_checkerror("cumsum(r, ""toto"")", refMsg); + +a = cumsum([1/%z %z/(1+2*%z)]); +assert_checkequal(a, [1/%z (1+2*%z+%z^2)/(%z+2*%z^2)]); + +a = cumsum([1/%z %z/(1+2*%z)]'); +assert_checkequal(a, [1/%z (1+2*%z+%z^2)/(%z+2*%z^2)]'); diff --git a/modules/overloading/tests/nonreg_tests/bug_8607.dia.ref b/modules/overloading/tests/nonreg_tests/bug_8607.dia.ref new file mode 100755 index 000000000..bf82dab3c --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_8607.dia.ref @@ -0,0 +1,32 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 8607 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8607 +// +// <-- Short Description --> +// Some error messages in modules/overloading/macros are not standard and not localized +b=cell(3,1); +errmsg1=msprintf(_("%s: Wrong size for input argument #%d.\n"),"%ce_size",2); +assert_checkerror("size(b,3)", errmsg1); +A(:,:,2)=[1;1;1]; +B(:,:,2)=[1,1,1]; +errmsg2=msprintf(_("%s: Input argument #%d and input argument #%d have incompatible dimensions.\n"),"%hm_1_hm",1,2); +assert_checkerror("A<B", errmsg2); +s=poly(0,"s"); +P=[2*s+1;s]; +Q=[3*s+2,s,s]; +errmsg3=msprintf(_("%s: Wrong size for input arguments.\n"),"%p_v_p"); +assert_checkerror("P/.Q", errmsg3); +errmsg4=msprintf(_("%s: Wrong value for input argument #%d: %d or %s expected.\n"),"%r_norm",2,2,"inf"); +assert_checkerror("norm(P(1)/Q(1),1)", errmsg4); +errmsg5=msprintf(_("%s: Wrong type for input argument #%d: A scalar expected.\n"),"%s_1_hm",1); +assert_checkerror("[1 1]<A", errmsg5); +sys=tf2ss(P(1)/Q(1)); +errmsg6=msprintf(_("%s: Wrong value for input argument #%d: %d or %s expected.\n"),"%lss_norm",2,2,"inf"); +assert_checkerror("norm(sys,1)",errmsg6); diff --git a/modules/overloading/tests/nonreg_tests/bug_8607.tst b/modules/overloading/tests/nonreg_tests/bug_8607.tst new file mode 100755 index 000000000..747f2d41f --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_8607.tst @@ -0,0 +1,39 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 8607 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8607 +// +// <-- Short Description --> +// Some error messages in modules/overloading/macros are not standard and not localized + +b=cell(3,1); +errmsg1=msprintf(_("%s: Wrong size for input argument #%d.\n"),"%ce_size",2); +assert_checkerror("size(b,3)", errmsg1); + +A(:,:,2)=[1;1;1]; +B(:,:,2)=[1,1,1]; +errmsg2=msprintf(_("%s: Input argument #%d and input argument #%d have incompatible dimensions.\n"),"%hm_1_hm",1,2); +assert_checkerror("A<B", errmsg2); + +s=poly(0,"s"); +P=[2*s+1;s]; +Q=[3*s+2,s,s]; +errmsg3=msprintf(_("%s: Wrong size for input arguments.\n"),"%p_v_p"); +assert_checkerror("P/.Q", errmsg3); + +errmsg4=msprintf(_("%s: Wrong value for input argument #%d: %d or %s expected.\n"),"%r_norm",2,2,"inf"); +assert_checkerror("norm(P(1)/Q(1),1)", errmsg4); + +errmsg5=msprintf(_("%s: Wrong type for input argument #%d: A scalar expected.\n"),"%s_1_hm",1); +assert_checkerror("[1 1]<A", errmsg5); + +sys=tf2ss(P(1)/Q(1)); +errmsg6=msprintf(_("%s: Wrong value for input argument #%d: %d or %s expected.\n"),"%lss_norm",2,2,"inf"); +assert_checkerror("norm(sys,1)",errmsg6); diff --git a/modules/overloading/tests/nonreg_tests/bug_8859.dia.ref b/modules/overloading/tests/nonreg_tests/bug_8859.dia.ref new file mode 100755 index 000000000..80ef91851 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_8859.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 8859 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8859 +// +// <-- Short Description --> +//Missing some comparison operators for hypermatrices compared to scalar +I=int32(ones(2,2,2)); +assert_checktrue(execstr("t=I<>int32(1)","errcatch")==0); +assert_checktrue(~or(t(:))); +B=ones(2,2,2)>3; +assert_checktrue(execstr("t=B==%t","errcatch")==0); +assert_checktrue(~or(t(:))); +assert_checktrue(execstr("t=B<>%t","errcatch")==0); +assert_checktrue(or(t(:))); +P=%s;P(2,2,2)=%s; +assert_checktrue(execstr("t=P==%s+1","errcatch")==0); +assert_checktrue(~or(t(:))); +assert_checktrue(execstr("t=P<>%s+1","errcatch")==0); +assert_checktrue(or(t(:))); +S=string(rand(2,2,2)); +assert_checktrue(execstr("t=S==''x''","errcatch")==0); +assert_checktrue(~or(t(:))); +assert_checktrue(execstr("t=S<>''x''","errcatch")==0); +assert_checktrue(or(t(:))); diff --git a/modules/overloading/tests/nonreg_tests/bug_8859.tst b/modules/overloading/tests/nonreg_tests/bug_8859.tst new file mode 100755 index 000000000..a7347e181 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_8859.tst @@ -0,0 +1,47 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 8859 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8859 +// +// <-- Short Description --> +//Missing some comparison operators for hypermatrices compared to scalar + +I=int32(ones(2,2,2)); +assert_checktrue(execstr("t=I<>int32(1)","errcatch")==0); +assert_checktrue(~or(t(:))); + + +B=ones(2,2,2)>3; +assert_checktrue(execstr("t=B==%t","errcatch")==0); +assert_checktrue(~or(t(:))); + +assert_checktrue(execstr("t=B<>%t","errcatch")==0); +assert_checktrue(or(t(:))); + +P=%s;P(2,2,2)=%s; +assert_checktrue(execstr("t=P==%s+1","errcatch")==0); +assert_checktrue(~or(t(:))); + + +assert_checktrue(execstr("t=P<>%s+1","errcatch")==0); +assert_checktrue(or(t(:))); + + +S=string(rand(2,2,2)); +assert_checktrue(execstr("t=S==''x''","errcatch")==0); +assert_checktrue(~or(t(:))); + + +assert_checktrue(execstr("t=S<>''x''","errcatch")==0); +assert_checktrue(or(t(:))); + + diff --git a/modules/overloading/tests/nonreg_tests/bug_9682.dia.ref b/modules/overloading/tests/nonreg_tests/bug_9682.dia.ref new file mode 100755 index 000000000..bb06198cd --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_9682.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 9682 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9682 +// +// <-- Short Description --> +// 3D assignment into a 2D array of int issued an error +i = uint8([1 10;254 9]); +if execstr("i(:,:,2)=uint8(1)","errcatch")<>0 then bugmes();quit;end; +if ~assert_checkequal(i(:,:,2),uint8([1 1;1 1])) then bugmes();quit;end; diff --git a/modules/overloading/tests/nonreg_tests/bug_9682.tst b/modules/overloading/tests/nonreg_tests/bug_9682.tst new file mode 100755 index 000000000..2f9b358e5 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_9682.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 9682 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9682 +// +// <-- Short Description --> +// 3D assignment into a 2D array of int issued an error + + +i = uint8([1 10;254 9]); +if execstr("i(:,:,2)=uint8(1)","errcatch")<>0 then pause,end; +if ~assert_checkequal(i(:,:,2),uint8([1 1;1 1])) then pause,end; diff --git a/modules/overloading/tests/nonreg_tests/bug_9783.dia.ref b/modules/overloading/tests/nonreg_tests/bug_9783.dia.ref new file mode 100755 index 000000000..ba1ce5d49 --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_9783.dia.ref @@ -0,0 +1,67 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 9783 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9783 +// +// <-- Short Description --> +// Insertion overloading does not seem to work with mlist +// create structure +function [q] = new(x) + q = mlist(['X','x'], x); +endfunction +// q2(I) = q1 +function [q2] = %X_i_X(I,q1,q2) + if (I == []) + return; + else + x2 = q2.x; + x1 = q1.x; + x2(I) = x1; + q2 = new(x2); + end +endfunction +q0 = new([]) + q0 = + + + q0(1) + +!X x ! + + q0(2) + + [] +q1 = new([91,93]) + q1 = + + + q1(1) + +!X x ! + + q1(2) + + 91. 93. +q2 = new([10,20,30,40]) + q2 = + + + q2(1) + +!X x ! + + q2(2) + + 10. 20. 30. 40. +q2([1,3]) = q1; +q2_ref = new([91 20 93 40]); +assert_checkequal(q2,q2_ref); +q2([]) = q0; +assert_checktrue(execstr("q2([])=q0","errcatch")==0); diff --git a/modules/overloading/tests/nonreg_tests/bug_9783.tst b/modules/overloading/tests/nonreg_tests/bug_9783.tst new file mode 100755 index 000000000..01fe6153f --- /dev/null +++ b/modules/overloading/tests/nonreg_tests/bug_9783.tst @@ -0,0 +1,43 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014 - Scilab Enterprises - Charlotte HECQUET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- Non-regression test for bug 9783 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=9783 +// +// <-- Short Description --> +// Insertion overloading does not seem to work with mlist + + +// create structure +function [q] = new(x) + q = mlist(['X','x'], x); +endfunction + +// q2(I) = q1 +function [q2] = %X_i_X(I,q1,q2) + if (I == []) + return; + else + x2 = q2.x; + x1 = q1.x; + x2(I) = x1; + q2 = new(x2); + end +endfunction + +q0 = new([]) +q1 = new([91,93]) +q2 = new([10,20,30,40]) + +q2([1,3]) = q1; +q2_ref = new([91 20 93 40]); +assert_checkequal(q2,q2_ref); + +q2([]) = q0; +assert_checktrue(execstr("q2([])=q0","errcatch")==0); diff --git a/modules/overloading/tests/unit_tests/c_a_c.dia.ref b/modules/overloading/tests/unit_tests/c_a_c.dia.ref new file mode 100755 index 000000000..cebe46a42 --- /dev/null +++ b/modules/overloading/tests/unit_tests/c_a_c.dia.ref @@ -0,0 +1,50 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +a = 'a'; +b = ['a';'b']; +c = a + b; +ref = ['aa';'ab']; +if or(c <> ref) then bugmes();quit;end +a = 'a'; +b = ['a','b']; +c = a + b; +ref = ['aa','ab']; +if or(c <> ref) then bugmes();quit;end +a = ['a';'b']; +b = 'a'; +c = a + b; +ref = ['aa';'ba']; +if or(c <> ref) then bugmes();quit;end +a = ['a','b']; +b = 'a'; +c = a + b; +ref = ['aa','ba']; +if or(c <> ref) then bugmes();quit;end +a = 'a'; +b = 'b'; +c = a + b; +ref = 'ab'; +if or(c <> ref) then bugmes();quit;end +a = ['a','b']; +b = ['c','d']; +c = a + b; +ref = ['ac','bd']; +if or(c <> ref) then bugmes();quit;end +a = ['a';'b']; +b = ['c';'d']; +c = a + b; +ref = ['ac';'bd']; +if or(c <> ref) then bugmes();quit;end +a = ['a';'b';'e']; +b = ['c';'d']; +ierr = execstr('c = a + b;','errcatch'); +if ierr <> 8 then bugmes();quit;end +a = ['a';'b']; +b = ['c';'d';'e']; +ierr = execstr('c = a + b;','errcatch'); +if ierr <> 8 then bugmes();quit;end diff --git a/modules/overloading/tests/unit_tests/c_a_c.tst b/modules/overloading/tests/unit_tests/c_a_c.tst new file mode 100755 index 000000000..3e8afe060 --- /dev/null +++ b/modules/overloading/tests/unit_tests/c_a_c.tst @@ -0,0 +1,60 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> +a = 'a'; +b = ['a';'b']; +c = a + b; +ref = ['aa';'ab']; +if or(c <> ref) then pause,end + +a = 'a'; +b = ['a','b']; +c = a + b; +ref = ['aa','ab']; +if or(c <> ref) then pause,end + +a = ['a';'b']; +b = 'a'; +c = a + b; +ref = ['aa';'ba']; +if or(c <> ref) then pause,end + +a = ['a','b']; +b = 'a'; +c = a + b; +ref = ['aa','ba']; +if or(c <> ref) then pause,end + +a = 'a'; +b = 'b'; +c = a + b; +ref = 'ab'; +if or(c <> ref) then pause,end + +a = ['a','b']; +b = ['c','d']; +c = a + b; +ref = ['ac','bd']; +if or(c <> ref) then pause,end + +a = ['a';'b']; +b = ['c';'d']; +c = a + b; +ref = ['ac';'bd']; +if or(c <> ref) then pause,end + +a = ['a';'b';'e']; +b = ['c';'d']; +ierr = execstr('c = a + b;','errcatch'); +if ierr <> 8 then pause,end + +a = ['a';'b']; +b = ['c';'d';'e']; +ierr = execstr('c = a + b;','errcatch'); +if ierr <> 8 then pause,end + diff --git a/modules/overloading/tests/unit_tests/overloadingName.dia.ref b/modules/overloading/tests/unit_tests/overloadingName.dia.ref new file mode 100755 index 000000000..c4d9bbe58 --- /dev/null +++ b/modules/overloading/tests/unit_tests/overloadingName.dia.ref @@ -0,0 +1,289 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// +// <-- CLI SHELL MODE --> +// <-- ENGLISH IMPOSED --> +// +// This test is to check how overloading names are +// built then called. +// use mlist to define unknown type function. +// +// This test is base on the diary output. +// +overloadingNames = [ + "%unknown_p" // Display + "%unknown_e" // Extraction + "%unknown_i_unknown" // Insertion + "%unknown_t" // transpose + "%unknown_0" + "%unknown_a_unknown" // addition + "%unknown_s_unknown" // subtraction + "%unknown_m_unknown" // mutiplication + "%unknown_x_unknown" + "%unknown_k_unknown" + "%unknown_u_unknown" + "%unknown_r_unknown" // division + "%unknown_d_unknown" + "%unknown_y_unknown" + "%unknown_v_unknown" + "%unknown_l_unknown" // right left division + "%unknown_q_unknown" + "%unknown_z_unknown" + "%unknown_w_unknown" + "%unknown_p_unknown" // power + "%unknown_j_unknown" + "%unknown_c_unknown" // column concat + "%unknown_f_unknown" // row concat + "%unknown_b_unknown" // implicit list + "%unknown_o_unknown" // equal + "%unknown_n_unknown" // different + "%unknown_g_unknown" // or + "%unknown_h_unknown" // and + "%unknown_1_unknown" // < + "%unknown_2_unknown" // > + "%unknown_3_unknown" // <= + "%unknown_4_unknown" // >= + "%unknown_5" // not +]; +// Generate all overloading functions... +for name = overloadingNames + execstr("function r="+name+"(varargin); " + ... + "disp(""Calling "+name+"...""); " + ... + "r = []; " + ... + "endfunction"); +end +M = mlist("unknown"); +if typeof(M) <> "unknown" then bugmes();quit;end +M + M = + + + Calling %unknown_p... +M(1) + + Calling %unknown_e... + ans = + + [] +M(1,2) + + Calling %unknown_e... + ans = + + [] +N = M + N = + + + Calling %unknown_p... +N(2) = M + + Calling %unknown_i_unknown... + N = + + [] +M' + + Calling %unknown_t... + ans = + + [] +M.' + + Calling %unknown_0... + ans = + + [] +M + M + + Calling %unknown_a_unknown... + ans = + + [] +M - M + + Calling %unknown_s_unknown... + ans = + + [] +M * M + + Calling %unknown_m_unknown... + ans = + + [] +M .* M + + Calling %unknown_x_unknown... + ans = + + [] +M *. M + + Calling %unknown_u_unknown... + ans = + + [] +M .*. M + + Calling %unknown_k_unknown... + ans = + + [] +M / M + + Calling %unknown_r_unknown... + ans = + + [] +M ./ M + + Calling %unknown_d_unknown... + ans = + + [] +M /. M + + Calling %unknown_v_unknown... + ans = + + [] +M ./. M + + Calling %unknown_y_unknown... + ans = + + [] +M \ M + + Calling %unknown_l_unknown... + ans = + + [] +M .\ M + + Calling %unknown_q_unknown... + ans = + + [] +M \. M + + Calling %unknown_w_unknown... + ans = + + [] +M .\. M + + Calling %unknown_z_unknown... + ans = + + [] +M ^ M + + Calling %unknown_p_unknown... + ans = + + [] +M ** M + + Calling %unknown_p_unknown... + ans = + + [] +M .^ M + + Calling %unknown_j_unknown... + ans = + + [] +// M .** M <-- This do not exists in scilab ... Wired ... +M:M + + Calling %unknown_b_unknown... + ans = + + [] +M == M + + Calling %unknown_o_unknown... + ans = + + [] +M <> M + + Calling %unknown_n_unknown... + ans = + + [] +M ~= M + + Calling %unknown_n_unknown... + ans = + + [] +M @= M + + Calling %unknown_n_unknown... + ans = + + [] +M < M + + Calling %unknown_1_unknown... + ans = + + [] +M > M + + Calling %unknown_2_unknown... + ans = + + [] +M <= M + + Calling %unknown_3_unknown... + ans = + + [] +M >= M + + Calling %unknown_4_unknown... + ans = + + [] +M | M + + Calling %unknown_g_unknown... + ans = + + [] +M & M + + Calling %unknown_h_unknown... + ans = + + [] +~M + + Calling %unknown_5... + ans = + + [] +@M + + Calling %unknown_5... + ans = + + [] +// Clear all added functions +for name = overloadingNames + execstr("clear "+name); +end diff --git a/modules/overloading/tests/unit_tests/overloadingName.tst b/modules/overloading/tests/unit_tests/overloadingName.tst new file mode 100755 index 000000000..9a9945543 --- /dev/null +++ b/modules/overloading/tests/unit_tests/overloadingName.tst @@ -0,0 +1,134 @@ +// +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010-2010 - DIGITEO - Bruno JOFRET +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +// +// + +// <-- CLI SHELL MODE --> + +// <-- ENGLISH IMPOSED --> + +// +// This test is to check how overloading names are +// built then called. +// use mlist to define unknown type function. +// +// This test is base on the diary output. +// + +overloadingNames = [ + "%unknown_p" // Display + "%unknown_e" // Extraction + "%unknown_i_unknown" // Insertion + "%unknown_t" // transpose + "%unknown_0" + "%unknown_a_unknown" // addition + "%unknown_s_unknown" // subtraction + "%unknown_m_unknown" // mutiplication + "%unknown_x_unknown" + "%unknown_k_unknown" + "%unknown_u_unknown" + "%unknown_r_unknown" // division + "%unknown_d_unknown" + "%unknown_y_unknown" + "%unknown_v_unknown" + "%unknown_l_unknown" // right left division + "%unknown_q_unknown" + "%unknown_z_unknown" + "%unknown_w_unknown" + "%unknown_p_unknown" // power + "%unknown_j_unknown" + "%unknown_c_unknown" // column concat + "%unknown_f_unknown" // row concat + "%unknown_b_unknown" // implicit list + "%unknown_o_unknown" // equal + "%unknown_n_unknown" // different + "%unknown_g_unknown" // or + "%unknown_h_unknown" // and + "%unknown_1_unknown" // < + "%unknown_2_unknown" // > + "%unknown_3_unknown" // <= + "%unknown_4_unknown" // >= + "%unknown_5" // not +]; + + +// Generate all overloading functions... + +for name = overloadingNames + execstr("function r="+name+"(varargin); " + ... + "disp(""Calling "+name+"...""); " + ... + "r = []; " + ... + "endfunction"); +end + + +M = mlist("unknown"); + +if typeof(M) <> "unknown" then pause,end + +M + +M(1) +M(1,2) + +N = M +N(2) = M + +M' +M.' + +M + M + +M - M + +M * M +M .* M +M *. M +M .*. M + +M / M +M ./ M +M /. M +M ./. M + +M \ M +M .\ M +M \. M +M .\. M + +M ^ M +M ** M +M .^ M +// M .** M <-- This does not exists in Scilab ... Wired ... + +M:M + +M == M + +M <> M +M ~= M +M @= M + +M < M +M > M + +M <= M +M >= M + +M | M +M & M + +~M +@M + +// Clear all added functions +for name = overloadingNames + execstr("clear "+name); +end diff --git a/modules/overloading/tests/unit_tests/rational.dia.ref b/modules/overloading/tests/unit_tests/rational.dia.ref new file mode 100755 index 000000000..a703a7aca --- /dev/null +++ b/modules/overloading/tests/unit_tests/rational.dia.ref @@ -0,0 +1,341 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +s=poly(0,'s'); +z = s^0; +h=1/(2*s); +assert_checkequal(size(h), [1 1]); +assert_checkequal(h.num, 1*z); +assert_checkequal(h.den, 2*s); +//basic operations with 2D matrices +H=[h h]; +assert_checkequal(H.num, [1 1].*z); +assert_checkequal(H.den, [2*s 2*s]); +H=[h;h]; +assert_checkequal(H.num, [1;1].*z); +assert_checkequal(H.den, [2*s;2*s]); +H=[h 3]; +assert_checkequal(H.num, [1*z 3]); +assert_checkequal(H.den, [2*s 1]); +H=[h;5]; +assert_checkequal(H.num, [1*z;5]); +assert_checkequal(H.den, [2*s;1]); +H=[3 h]; +assert_checkequal(H.num, [3 1*z]); +assert_checkequal(H.den, [1 2*s]); +H=[5;h]; +assert_checkequal(H.num, [5;1*z]); +assert_checkequal(H.den, [1;2*s]); +H=[3 h;s 2]; +assert_checkequal(H(1,1), rlist(3,1)); +assert_checkequal(H(1,2), h); +assert_checkequal(H(1, [2 1]), [h rlist(3,1)]); +assert_checkequal(H(1, [2 2]), [h h]); +assert_checkequal(H(1,:), [rlist(3,1) h]); +assert_checkequal(H(:,1), [rlist(3,1); s]); +assert_checkequal(H([2 1], :), [s rlist(2,1);rlist(3,1) h]); +assert_checkequal(H([1 1], :), [rlist(3,1) h;rlist(3,1) h]); +assert_checkequal(matrix(H, -1, 1), [3*z;s;h;2*z]); +H=h;H(1,3)=1/s; +assert_checkequal(H.num, [1 0 1].*z); +assert_checkequal(H.den, [2*s 1 s]); +H=h;H(3,1)=1/s; +assert_checkequal(H.num, [1 0 1]'.*z); +assert_checkequal(H.den, [2*s 1 s]'); +H=h;H(1,3)=1.5; +assert_checkequal(H.num, [1 0 1.5].*z); +assert_checkequal(H.den, [2*s 1 1]); +H=h;H(3,1)=1.5; +assert_checkequal(H.num, [1 0 1.5]'.*z); +assert_checkequal(H.den, [2*s 1 1]'); +H=1.5;H(1,3)=1/s; +assert_checkequal(H.num, [1.5 0 1].*z); +assert_checkequal(H.den, [1 1 s]); +H=1.5;H(3,1)=1/s; +assert_checkequal(H.num, [1.5 0 1]'.*z); +assert_checkequal(H.den, [1 1 s]'); +H=[h s;1 h];H(:,1)=[]; +assert_checkequal(H, [s;h]); +H=[h s;1 h];H(2,:)=[]; +assert_checkequal(H, [h s]); +H=h+h;c=coeff(H.den,1); +assert_checkequal(H.num/c, 1*z); +assert_checkequal(H.den/c, s); +H=h+1; +assert_checkequal(H.num, 1+2*s); +assert_checkequal(H.den, 2*s); +H=1+h; +assert_checkequal(H.num, 1+2*s); +assert_checkequal(H.den, 2*s); +H=h+[]; +assert_checkequal(H, h); +H=[]+h; +assert_checkequal(H, h); +H=h+s; +assert_checkequal(H.num, 1+2*s^2); +assert_checkequal(H.den, 2*s); +H=s+h; +assert_checkequal(H.num, 1+2*s^2); +assert_checkequal(H.den, 2*s); +H=h-h; +assert_checkequal(H.num, 0*z); +assert_checkequal(H.den, 1*s^0); +H=h-1; +assert_checkequal(H.num, 1-2*s); +assert_checkequal(H.den, 2*s); +H=1-h; +assert_checkequal(H.num, -1+2*s); +assert_checkequal(H.den, 2*s); +H=[h h+1]-1; +assert_checkequal(H(1,1), h-1); +assert_checkequal(H(1,2), h); +H=[h h+1]-2*h; +assert_checkequal(H.num, [-2 -2+4*s]); +assert_checkequal(H.den, [4*s 4*s]); +H=-2*h+[h h+1]; +assert_checkequal(H.num, [-2 -2+4*s]); +assert_checkequal(H.den, [4*s 4*s]); +// * +H=h*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 4*s^2); +H=h*2; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); +H=2*h; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); +H=h*s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); +H=s*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); +H=[h h+1]*h; +assert_checkequal(H, [h*h (h+1)*h]); +H=h*[h h+1]; +assert_checkequal(H, [h*h, (h+1)*h]); +H=[h h+1]*2; +assert_checkequal(H, [h*2, (h+1)*2]); +H=2*[h h+1]; +assert_checkequal(H, [h*2, (h+1)*2]); +H=[h h+1]*s; +assert_checkequal(H, [h*s, (h+1)*s]); +H=s*[h h+1]; +assert_checkequal(H, [h*s, (h+1)*s]); +H=[h 1;s 3]*[1;h]; +assert_checkequal(H, [h+h;s+3*h]); +H=[h 1]*[h 1;s 3]; +assert_checkequal(H, [h*h+s, h+3]); +H=[h 1;s 3]*[1;2]; +assert_checkequal(H, [h+2;s+6]); +H=[2 1]*[h 1;s 3]; +assert_checkequal(H, [2*h+s, 2+3]); +// .* +H=h.*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 4*s^2); +H=h.*2; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); +H=2 .*h; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); +H=h.*s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); +H=s.*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); +H=[h h+1].*h; +assert_checkequal(H, [h*h (h+1)*h]); +H=h.*[h h+1]; +assert_checkequal(H, [h*h (h+1)*h]); +H=[h h+1].*2; +assert_checkequal(H, [h*2, (h+1)*2]); +H=2 .*[h h+1]; +assert_checkequal(H, [h*2, (h+1)*2]); +H=[h h+1].*s; +assert_checkequal(H, [h*s, (h+1)*s]); +H=s.*[h h+1]; +assert_checkequal(H, [h*s, (h+1)*s]); +H=[3 h;s 2].*[3 h;s 2]; +assert_checkequal(H, [9 h*h; s*s 4]); +// / +H=h/2; +assert_checkequal(H.num, 0.5*z); +assert_checkequal(H.den, 2*s); +H=h/s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*s^2); +H=h/(h+1); +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2+4*s); +H=[h h-1]/2; +assert_checkequal(H, [h/2 (h-1)/2]); +H=[h h-1]/s; +assert_checkequal(H, [h/s (h-1)/s]); +H=1/h; +assert_checkequal(H.num, 2*s); +assert_checkequal(H.den, 1*z); +H=[1 2]/h; +assert_checkequal(H, [1/h 2/h]); +H=[s+1 s-2]/h; +assert_checkequal(H, [(s+1)/h (s-2)/h]); +H=[h+1 (h+1)*(h-1)]/h; +assert_checkequal(H, [(h+1)/h ((h+1)*(h-1))/h]); +H=(eye(2,2)/[3 h;s 2])*[3 h;s 2]; +assert_checkequal(coeff(H.num)./(coeff(H.den, 0) + coeff(H.den, 2)), eye(2,2)); +// ./ +H=h./2; +assert_checkequal(H.num, 0.5*z); +assert_checkequal(H.den, 2*s); +H=h./s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*s^2); +H=h./(h+1); +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2+4*s); +H=[h h-1]./2; +assert_checkequal(H, [h/2 (h-1)/2]); +H=[h h-1]./s; +assert_checkequal(H, [h/s (h-1)/s]); +H=1 ./h; +assert_checkequal(H.num, 2*s); +assert_checkequal(H.den, 1*z); +H=[1 2]./h; +assert_checkequal(H, [1/h 2/h]); +H=[s+1 s-2]./h; +assert_checkequal(H, [(s+1)/h (s-2)/h]); +H=[h+1 (h+1)*(h-1)]./h; +assert_checkequal(H, [(h+1)/h ((h+1)*(h-1))/h]); +H=[3 h;s 2]./[3 h;s 2]; +assert_checkequal(coeff(H.num)./coeff(H.den), ones(2,2)); +// .\ +H=2 .\h; +assert_checkequal(H.num, 0.5*z); +assert_checkequal(H.den, 2*s); +H=s.\h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*s^2); +H=(h+1).\h; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2+4*s); +H=2 .\[h h-1]; +assert_checkequal(H, [h/2 (h-1)/2]); +H=s.\[h h-1]; +assert_checkequal(H, [h/s (h-1)/s]); +H=1 ./h; +assert_checkequal(H.num, 2*s); +assert_checkequal(H.den, 1*z); +H=h.\[1 2]; +assert_checkequal(H, [1/h 2/h]); +H=h.\[s+1 s-2]; +assert_checkequal(H, [(s+1)/h (s-2)/h]); +H=h.\[h+1 (h+1)*(h-1)]; +assert_checkequal(H, [(h+1)/h ((h+1)*(h-1))/h]); +H=[3 h;s 2]./[3 h;s 2]; +assert_checkequal(coeff(H.num)./coeff(H.den), ones(2,2)); +// hypermatrices of rationnals +clear H;H(1,1,2)=h; +assert_checkequal(H(1,1,1), rlist(0, 1, [])); +assert_checkequal(H(1,1,2), h); +H(2,1,2)=h+1; +assert_checkequal(size(H), [2 1 2]); +assert_checkequal(H(:,1,1), rlist([0; 0], [1; 1])); +assert_checkequal(H([2 2], 1, 2), [h+1;h+1]); +clear H;H(1,1,2)=h;H(2,1,1)=1; +assert_checkequal(H(:,1,1), rlist([0; 1], [1; 1])); +assert_checkequal(H(:,1,2), [h;0]); +clear H;H(1,1,2)=h;H(1,1,:)=3; +assert_checkequal(H(1,1,1), rlist(3,1)); +assert_checkequal(H(1,1,2), rlist(3,1)); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s; +assert_checkequal(H(1:2,1,1), rlist([%s;%s], [1;1])); +clear H;H(2,2,2)=s;H(2,1,1)=h; +assert_checkequal(H(:,:,1), [0 0;h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 s], [1 1;1 1])); +clear H;H(2,2,2)=8;H(2,1,1)=h; +assert_checkequal(H(:,:,1), [0 0;h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 8], [1 1;1 1])); +clear H;H(2,2,2)=8;H(2,1,1)=h; +H(:,:,1)=[]; +assert_checkequal(H, rlist([0 0;0 8], [1 1;1 1])); +clear H;H(2,2,2)=8;H(2,1,1)=h; +H2=H(2,:,:);H(1,:,:)=[]; +assert_checkequal(H, H2); +clear H;H(2,2,2)=8;H(2,1,1)=h; +H2=H(:,2,:);H(:,1,:)=[]; +assert_checkequal(H, H2); +clear H;H(2,2,2)=h;H=H+1; +assert_checkequal(H(:,:,1), rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [1 1;1 h+1]); +clear H;H(2,2,2)=h;H=1+H; +assert_checkequal(H(:,:,1), rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [1 1;1 h+1]); +clear H;H(2,2,2)=h;H=H+s; +assert_checkequal(H(:,:,1), rlist([s s;s s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [s s;s h+s]); +clear H;H(2,2,2)=h;H=s+H; +assert_checkequal(H(:,:,1), rlist([s s; s s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [s s;s h+s]); +clear H;H(2,2,2)=h;H=H-1; +assert_checkequal(H(:,:,1), -1*rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [-1 -1;-1 h-1]); +clear H;H(2,2,2)=h;H=1-H; +assert_checkequal(H(:,:,1), rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [1 1;1 1-h]); +clear H;H(2,2,2)=h;H=H-s; +assert_checkequal(H(:,:,1), rlist([-s -s;-s -s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [-s -s;-s h-s]); +clear H;H(2,2,2)=h;H=s-H; +assert_checkequal(H(:,:,1), rlist([s s;s s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [s s;s -h+s]); +clear H;H(2,2,2)=s;H(2,1,1)=h;H=H+H; +assert_checkequal(H(:,:,1), [0 0;h+h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 s+s], [1 1;1 1])); +clear H;H(2,2,2)=s;H(2,1,1)=h;H=H-H; +assert_checkequal(H(:,:,1), [0 0;h-h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 0], [1 1;1 1])); +// * +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H*h; +assert_checkequal(H(:,:,1), [s*h;s*h]); +assert_checkequal(H(:,:,2), [h*h; 0/1]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H*2; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=2*H; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H*s; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=s*H; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); +// .* +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*h; +assert_checkequal(H(:,:,1), [s*h;s*h]); +assert_checkequal(H(:,:,2), [h*h;0/1]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=h.*H; +assert_checkequal(H(:,:,1), [s*h;s*h]); +assert_checkequal(H(:,:,2), [h*h;0/1]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*2; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=2 .*H; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*s; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=s.*H; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*H; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*h;0]); diff --git a/modules/overloading/tests/unit_tests/rational.tst b/modules/overloading/tests/unit_tests/rational.tst new file mode 100755 index 000000000..3685cf7ad --- /dev/null +++ b/modules/overloading/tests/unit_tests/rational.tst @@ -0,0 +1,469 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + + +s=poly(0,'s'); +z = s^0; +h=1/(2*s); +assert_checkequal(size(h), [1 1]); +assert_checkequal(h.num, 1*z); +assert_checkequal(h.den, 2*s); + +//basic operations with 2D matrices +H=[h h]; +assert_checkequal(H.num, [1 1].*z); +assert_checkequal(H.den, [2*s 2*s]); + +H=[h;h]; +assert_checkequal(H.num, [1;1].*z); +assert_checkequal(H.den, [2*s;2*s]); + +H=[h 3]; +assert_checkequal(H.num, [1*z 3]); +assert_checkequal(H.den, [2*s 1]); + +H=[h;5]; +assert_checkequal(H.num, [1*z;5]); +assert_checkequal(H.den, [2*s;1]); + +H=[3 h]; +assert_checkequal(H.num, [3 1*z]); +assert_checkequal(H.den, [1 2*s]); + +H=[5;h]; +assert_checkequal(H.num, [5;1*z]); +assert_checkequal(H.den, [1;2*s]); + +H=[3 h;s 2]; +assert_checkequal(H(1,1), rlist(3,1)); +assert_checkequal(H(1,2), h); +assert_checkequal(H(1, [2 1]), [h rlist(3,1)]); +assert_checkequal(H(1, [2 2]), [h h]); +assert_checkequal(H(1,:), [rlist(3,1) h]); +assert_checkequal(H(:,1), [rlist(3,1); s]); +assert_checkequal(H([2 1], :), [s rlist(2,1);rlist(3,1) h]); +assert_checkequal(H([1 1], :), [rlist(3,1) h;rlist(3,1) h]); + +assert_checkequal(matrix(H, -1, 1), [3*z;s;h;2*z]); + +H=h;H(1,3)=1/s; +assert_checkequal(H.num, [1 0 1].*z); +assert_checkequal(H.den, [2*s 1 s]); + +H=h;H(3,1)=1/s; +assert_checkequal(H.num, [1 0 1]'.*z); +assert_checkequal(H.den, [2*s 1 s]'); + +H=h;H(1,3)=1.5; +assert_checkequal(H.num, [1 0 1.5].*z); +assert_checkequal(H.den, [2*s 1 1]); + +H=h;H(3,1)=1.5; +assert_checkequal(H.num, [1 0 1.5]'.*z); +assert_checkequal(H.den, [2*s 1 1]'); + +H=1.5;H(1,3)=1/s; +assert_checkequal(H.num, [1.5 0 1].*z); +assert_checkequal(H.den, [1 1 s]); + +H=1.5;H(3,1)=1/s; +assert_checkequal(H.num, [1.5 0 1]'.*z); +assert_checkequal(H.den, [1 1 s]'); + +H=[h s;1 h];H(:,1)=[]; +assert_checkequal(H, [s;h]); + +H=[h s;1 h];H(2,:)=[]; +assert_checkequal(H, [h s]); + +H=h+h;c=coeff(H.den,1); +assert_checkequal(H.num/c, 1*z); +assert_checkequal(H.den/c, s); + +H=h+1; +assert_checkequal(H.num, 1+2*s); +assert_checkequal(H.den, 2*s); + +H=1+h; +assert_checkequal(H.num, 1+2*s); +assert_checkequal(H.den, 2*s); + +H=h+[]; +assert_checkequal(H, h); + +H=[]+h; +assert_checkequal(H, h); + +H=h+s; +assert_checkequal(H.num, 1+2*s^2); +assert_checkequal(H.den, 2*s); + +H=s+h; +assert_checkequal(H.num, 1+2*s^2); +assert_checkequal(H.den, 2*s); + +H=h-h; +assert_checkequal(H.num, 0*z); +assert_checkequal(H.den, 1*s^0); + +H=h-1; +assert_checkequal(H.num, 1-2*s); +assert_checkequal(H.den, 2*s); + +H=1-h; +assert_checkequal(H.num, -1+2*s); +assert_checkequal(H.den, 2*s); + +H=[h h+1]-1; +assert_checkequal(H(1,1), h-1); +assert_checkequal(H(1,2), h); + +H=[h h+1]-2*h; +assert_checkequal(H.num, [-2 -2+4*s]); +assert_checkequal(H.den, [4*s 4*s]); + +H=-2*h+[h h+1]; +assert_checkequal(H.num, [-2 -2+4*s]); +assert_checkequal(H.den, [4*s 4*s]); + +// * + +H=h*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 4*s^2); + +H=h*2; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); + +H=2*h; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); + +H=h*s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); + +H=s*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); + +H=[h h+1]*h; +assert_checkequal(H, [h*h (h+1)*h]); + +H=h*[h h+1]; +assert_checkequal(H, [h*h, (h+1)*h]); + +H=[h h+1]*2; +assert_checkequal(H, [h*2, (h+1)*2]); + +H=2*[h h+1]; +assert_checkequal(H, [h*2, (h+1)*2]); + +H=[h h+1]*s; +assert_checkequal(H, [h*s, (h+1)*s]); + +H=s*[h h+1]; +assert_checkequal(H, [h*s, (h+1)*s]); + +H=[h 1;s 3]*[1;h]; +assert_checkequal(H, [h+h;s+3*h]); + +H=[h 1]*[h 1;s 3]; +assert_checkequal(H, [h*h+s, h+3]); + +H=[h 1;s 3]*[1;2]; +assert_checkequal(H, [h+2;s+6]); + +H=[2 1]*[h 1;s 3]; +assert_checkequal(H, [2*h+s, 2+3]); + +// .* + +H=h.*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 4*s^2); + +H=h.*2; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); + +H=2 .*h; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2*s); + +H=h.*s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); + +H=s.*h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*z); + +H=[h h+1].*h; +assert_checkequal(H, [h*h (h+1)*h]); + +H=h.*[h h+1]; +assert_checkequal(H, [h*h (h+1)*h]); + +H=[h h+1].*2; +assert_checkequal(H, [h*2, (h+1)*2]); + +H=2 .*[h h+1]; +assert_checkequal(H, [h*2, (h+1)*2]); + +H=[h h+1].*s; +assert_checkequal(H, [h*s, (h+1)*s]); + +H=s.*[h h+1]; +assert_checkequal(H, [h*s, (h+1)*s]); + +H=[3 h;s 2].*[3 h;s 2]; +assert_checkequal(H, [9 h*h; s*s 4]); + + +// / + +H=h/2; +assert_checkequal(H.num, 0.5*z); +assert_checkequal(H.den, 2*s); + +H=h/s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*s^2); + +H=h/(h+1); +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2+4*s); + +H=[h h-1]/2; +assert_checkequal(H, [h/2 (h-1)/2]); + +H=[h h-1]/s; +assert_checkequal(H, [h/s (h-1)/s]); + +H=1/h; +assert_checkequal(H.num, 2*s); +assert_checkequal(H.den, 1*z); + +H=[1 2]/h; +assert_checkequal(H, [1/h 2/h]); + +H=[s+1 s-2]/h; +assert_checkequal(H, [(s+1)/h (s-2)/h]); + +H=[h+1 (h+1)*(h-1)]/h; +assert_checkequal(H, [(h+1)/h ((h+1)*(h-1))/h]); + +H=(eye(2,2)/[3 h;s 2])*[3 h;s 2]; +assert_checkequal(coeff(H.num)./(coeff(H.den, 0) + coeff(H.den, 2)), eye(2,2)); + +// ./ +H=h./2; +assert_checkequal(H.num, 0.5*z); +assert_checkequal(H.den, 2*s); + +H=h./s; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*s^2); + +H=h./(h+1); +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2+4*s); + +H=[h h-1]./2; +assert_checkequal(H, [h/2 (h-1)/2]); + +H=[h h-1]./s; +assert_checkequal(H, [h/s (h-1)/s]); + +H=1 ./h; +assert_checkequal(H.num, 2*s); +assert_checkequal(H.den, 1*z); + +H=[1 2]./h; +assert_checkequal(H, [1/h 2/h]); + +H=[s+1 s-2]./h; +assert_checkequal(H, [(s+1)/h (s-2)/h]); + +H=[h+1 (h+1)*(h-1)]./h; +assert_checkequal(H, [(h+1)/h ((h+1)*(h-1))/h]); + +H=[3 h;s 2]./[3 h;s 2]; +assert_checkequal(coeff(H.num)./coeff(H.den), ones(2,2)); + +// .\ + +H=2 .\h; +assert_checkequal(H.num, 0.5*z); +assert_checkequal(H.den, 2*s); + +H=s.\h; +assert_checkequal(H.num, 1*z); +assert_checkequal(H.den, 2*s^2); + +H=(h+1).\h; +assert_checkequal(H.num, 2*z); +assert_checkequal(H.den, 2+4*s); + +H=2 .\[h h-1]; +assert_checkequal(H, [h/2 (h-1)/2]); + +H=s.\[h h-1]; +assert_checkequal(H, [h/s (h-1)/s]); + +H=1 ./h; +assert_checkequal(H.num, 2*s); +assert_checkequal(H.den, 1*z); + +H=h.\[1 2]; +assert_checkequal(H, [1/h 2/h]); + +H=h.\[s+1 s-2]; +assert_checkequal(H, [(s+1)/h (s-2)/h]); + +H=h.\[h+1 (h+1)*(h-1)]; +assert_checkequal(H, [(h+1)/h ((h+1)*(h-1))/h]); + +H=[3 h;s 2]./[3 h;s 2]; +assert_checkequal(coeff(H.num)./coeff(H.den), ones(2,2)); + +// hypermatrices of rationnals + +clear H;H(1,1,2)=h; +assert_checkequal(H(1,1,1), rlist(0, 1, [])); +assert_checkequal(H(1,1,2), h); + +H(2,1,2)=h+1; +assert_checkequal(size(H), [2 1 2]); +assert_checkequal(H(:,1,1), rlist([0; 0], [1; 1])); +assert_checkequal(H([2 2], 1, 2), [h+1;h+1]); + +clear H;H(1,1,2)=h;H(2,1,1)=1; +assert_checkequal(H(:,1,1), rlist([0; 1], [1; 1])); +assert_checkequal(H(:,1,2), [h;0]); + +clear H;H(1,1,2)=h;H(1,1,:)=3; +assert_checkequal(H(1,1,1), rlist(3,1)); +assert_checkequal(H(1,1,2), rlist(3,1)); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s; +assert_checkequal(H(1:2,1,1), rlist([%s;%s], [1;1])); + +clear H;H(2,2,2)=s;H(2,1,1)=h; +assert_checkequal(H(:,:,1), [0 0;h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 s], [1 1;1 1])); + +clear H;H(2,2,2)=8;H(2,1,1)=h; +assert_checkequal(H(:,:,1), [0 0;h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 8], [1 1;1 1])); + +clear H;H(2,2,2)=8;H(2,1,1)=h; +H(:,:,1)=[]; +assert_checkequal(H, rlist([0 0;0 8], [1 1;1 1])); + +clear H;H(2,2,2)=8;H(2,1,1)=h; +H2=H(2,:,:);H(1,:,:)=[]; +assert_checkequal(H, H2); + +clear H;H(2,2,2)=8;H(2,1,1)=h; +H2=H(:,2,:);H(:,1,:)=[]; +assert_checkequal(H, H2); + +clear H;H(2,2,2)=h;H=H+1; +assert_checkequal(H(:,:,1), rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [1 1;1 h+1]); + +clear H;H(2,2,2)=h;H=1+H; +assert_checkequal(H(:,:,1), rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [1 1;1 h+1]); + +clear H;H(2,2,2)=h;H=H+s; +assert_checkequal(H(:,:,1), rlist([s s;s s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [s s;s h+s]); + +clear H;H(2,2,2)=h;H=s+H; +assert_checkequal(H(:,:,1), rlist([s s; s s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [s s;s h+s]); + +clear H;H(2,2,2)=h;H=H-1; +assert_checkequal(H(:,:,1), -1*rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [-1 -1;-1 h-1]); + +clear H;H(2,2,2)=h;H=1-H; +assert_checkequal(H(:,:,1), rlist([1 1;1 1], [1 1;1 1])); +assert_checkequal(H(:,:,2), [1 1;1 1-h]); + +clear H;H(2,2,2)=h;H=H-s; +assert_checkequal(H(:,:,1), rlist([-s -s;-s -s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [-s -s;-s h-s]); + +clear H;H(2,2,2)=h;H=s-H; +assert_checkequal(H(:,:,1), rlist([s s;s s], [1 1;1 1])); +assert_checkequal(H(:,:,2), [s s;s -h+s]); + +clear H;H(2,2,2)=s;H(2,1,1)=h;H=H+H; +assert_checkequal(H(:,:,1), [0 0;h+h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 s+s], [1 1;1 1])); + +clear H;H(2,2,2)=s;H(2,1,1)=h;H=H-H; +assert_checkequal(H(:,:,1), [0 0;h-h 0]); +assert_checkequal(H(:,:,2), rlist([0 0;0 0], [1 1;1 1])); + +// * +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H*h; +assert_checkequal(H(:,:,1), [s*h;s*h]); +assert_checkequal(H(:,:,2), [h*h; 0/1]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H*2; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=2*H; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H*s; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=s*H; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); + +// .* +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*h; +assert_checkequal(H(:,:,1), [s*h;s*h]); +assert_checkequal(H(:,:,2), [h*h;0/1]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=h.*H; +assert_checkequal(H(:,:,1), [s*h;s*h]); +assert_checkequal(H(:,:,2), [h*h;0/1]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*2; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=2 .*H; +assert_checkequal(H(:,:,1), rlist([s*2;s*2], [1;1])); +assert_checkequal(H(:,:,2), [h*2;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*s; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=s.*H; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*s;0]); + +clear H;H(1,1,2)=h;H(1:2,1,1)=%s;H=H.*H; +assert_checkequal(H(:,:,1), rlist([s*s;s*s], [1;1])); +assert_checkequal(H(:,:,2), [h*h;0]); + + diff --git a/modules/overloading/tests/unit_tests/sparse.dia.ref b/modules/overloading/tests/unit_tests/sparse.dia.ref new file mode 100755 index 000000000..ceb68f5c5 --- /dev/null +++ b/modules/overloading/tests/unit_tests/sparse.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Michael Baudin +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +A = spzeros(3,2); +A(3,1) = 2; +string(A) + ans = + +!(3,2) sparse matrix ! +! ! +!(3,1) 2 ! diff --git a/modules/overloading/tests/unit_tests/sparse.tst b/modules/overloading/tests/unit_tests/sparse.tst new file mode 100755 index 000000000..85868ca28 --- /dev/null +++ b/modules/overloading/tests/unit_tests/sparse.tst @@ -0,0 +1,13 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - DIGITEO - Michael Baudin +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +A = spzeros(3,2); +A(3,1) = 2; +string(A) + |