diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/data_structures/tests | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/data_structures/tests')
86 files changed, 3895 insertions, 0 deletions
diff --git a/modules/data_structures/tests/benchmarks/arguments.tst b/modules/data_structures/tests/benchmarks/arguments.tst new file mode 100755 index 000000000..9b51c70c9 --- /dev/null +++ b/modules/data_structures/tests/benchmarks/arguments.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Clement DAVID +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//============================================================================== +// Pass raw values as rhs / lhs +//============================================================================== + +// <-- BENCH NB RUN : 10 --> + +stacksize("max"); + +foo1 = zeros(4096,4096); +foo2 = zeros(4096,4096); +foo3 = zeros(4096,4096); + +function foo3=computation(foo1, foo2) + foo3 = foo1 + foo2 +endfunction + +// <-- BENCH START --> +foo3 = computation(foo1, foo2); +// <-- BENCH END --> + diff --git a/modules/data_structures/tests/benchmarks/arguments_resize.tst b/modules/data_structures/tests/benchmarks/arguments_resize.tst new file mode 100755 index 000000000..dbadb5456 --- /dev/null +++ b/modules/data_structures/tests/benchmarks/arguments_resize.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Clement DAVID +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//============================================================================== +// Pass raw values as rhs / lhs +//============================================================================== + +// <-- BENCH NB RUN : 10 --> + +stacksize("max"); + +foo1 = zeros(4096,4096); +foo2 = zeros(4096,4096); +foo3 = []; + +function foo3=computation(foo1, foo2) + foo3 = foo1 + foo2 +endfunction + +// <-- BENCH START --> +foo3 = computation(foo1, foo2); +// <-- BENCH END --> + diff --git a/modules/data_structures/tests/benchmarks/arguments_tlist.tst b/modules/data_structures/tests/benchmarks/arguments_tlist.tst new file mode 100755 index 000000000..87cc82b97 --- /dev/null +++ b/modules/data_structures/tests/benchmarks/arguments_tlist.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Clement DAVID +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//============================================================================== +// Pass tlist as rhs / lhs, let scilab reuse the allocated space +//============================================================================== + +// <-- BENCH NB RUN : 10 --> + +stacksize("max"); + +data = tlist(["mydata" "foo1" "foo2" "foo3"], [], [], []); + +data.foo1 = zeros(4096,4096); +data.foo2 = zeros(4096,4096); +data.foo3 = zeros(4096,4096); + +function data=computation(data) + data.foo3 = data.foo1 + data.foo2 +endfunction + +// <-- BENCH START --> +data = computation(data); +// <-- BENCH END --> + diff --git a/modules/data_structures/tests/benchmarks/arguments_tlist_resize.tst b/modules/data_structures/tests/benchmarks/arguments_tlist_resize.tst new file mode 100755 index 000000000..b0c9304fc --- /dev/null +++ b/modules/data_structures/tests/benchmarks/arguments_tlist_resize.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Clement DAVID +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//============================================================================== +// Pass tlist as rhs / lhs +//============================================================================== + +// <-- BENCH NB RUN : 10 --> + +stacksize("max"); + +data = tlist(["mydata" "foo1" "foo2" "foo3"], [], [], []); + +data.foo1 = zeros(4096,4096); +data.foo2 = zeros(4096,4096); + +function data=computation(data) + data.foo3 = data.foo1 + data.foo2 +endfunction + +// <-- BENCH START --> +data = computation(data); +// <-- BENCH END --> + diff --git a/modules/data_structures/tests/nonreg_tests/bug_10830.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_10830.dia.ref new file mode 100755 index 000000000..cee9da903 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_10830.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 10830 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10830 +// +// <-- Short Description --> +// Hypermatrix insertion with a negative index gives a wrong error message. +A=rand(2,2,2); +errmsg = msprintf(gettext("%s: Invalid index #%d in hypermatrix insertion.\n"),"hmops",3); +execstr("A(:,:,0)=[1,2;3,4]","errcatch"); +assert_checktrue(lasterror()==errmsg); +errmsg = msprintf(gettext("%s: Invalid index #%d in hypermatrix insertion.\n"),"hmops",2); +execstr("A(:,0,1)=[1;2]", "errcatch"); +assert_checktrue(lasterror()==errmsg); +errmsg = msprintf(gettext("%s: Invalid index #%d in hypermatrix insertion.\n"),"hmops",1); +execstr("A(0,:,1)=[1 2]", "errcatch"); +assert_checktrue(lasterror()==errmsg); diff --git a/modules/data_structures/tests/nonreg_tests/bug_10830.tst b/modules/data_structures/tests/nonreg_tests/bug_10830.tst new file mode 100755 index 000000000..08125f03d --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_10830.tst @@ -0,0 +1,27 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 10830 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10830 +// +// <-- Short Description --> +// Hypermatrix insertion with a negative (or null) index gives a wrong error message. + +A=rand(2,2,2); +errmsg = msprintf(gettext("%s: Invalid index #%d in hypermatrix insertion.\n"),"hmops",3); +execstr("A(:,:,0)=[1,2;3,4]","errcatch"); +assert_checktrue(lasterror()==errmsg); +errmsg = msprintf(gettext("%s: Invalid index #%d in hypermatrix insertion.\n"),"hmops",2); +execstr("A(:,0,1)=[1;2]", "errcatch"); +assert_checktrue(lasterror()==errmsg); +errmsg = msprintf(gettext("%s: Invalid index #%d in hypermatrix insertion.\n"),"hmops",1); +execstr("A(0,:,1)=[1 2]", "errcatch"); +assert_checktrue(lasterror()==errmsg); diff --git a/modules/data_structures/tests/nonreg_tests/bug_11076.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_11076.dia.ref new file mode 100755 index 000000000..e362ef734 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11076.dia.ref @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 11076 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11076 +// +// <-- Short Description --> +// mlist('r'), tlist('r') returned a wrong error message +msgerr = msprintf(gettext("%s: Can not create a mlist with input argument #%d.\n"), "mlist", 1); +assert_checkerror ("mlist(''r'')", msgerr ); +msgerr = msprintf(gettext("%s: Can not create a tlist with input argument #%d.\n"), "tlist", 1); +assert_checkerror ("tlist(''r'')", msgerr ); diff --git a/modules/data_structures/tests/nonreg_tests/bug_11076.tst b/modules/data_structures/tests/nonreg_tests/bug_11076.tst new file mode 100755 index 000000000..d4babfc64 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11076.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 11076 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11076 +// +// <-- Short Description --> +// mlist('r'), tlist('r') returned a wrong error message + +msgerr = msprintf(gettext("%s: Can not create a mlist with input argument #%d.\n"), "mlist", 1); +assert_checkerror ("mlist(''r'')", msgerr ); + +msgerr = msprintf(gettext("%s: Can not create a tlist with input argument #%d.\n"), "tlist", 1); +assert_checkerror ("tlist(''r'')", msgerr );
\ No newline at end of file diff --git a/modules/data_structures/tests/nonreg_tests/bug_11077.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_11077.dia.ref new file mode 100755 index 000000000..4f2228e62 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11077.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 11077 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11077 +// +// <-- Short Description --> +// rlist() returned an error +rlist() + ans = + diff --git a/modules/data_structures/tests/nonreg_tests/bug_11077.tst b/modules/data_structures/tests/nonreg_tests/bug_11077.tst new file mode 100755 index 000000000..a62b2fb2e --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11077.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 11077 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11077 +// +// <-- Short Description --> +// rlist() returned an error + + +rlist() + + diff --git a/modules/data_structures/tests/nonreg_tests/bug_11227.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_11227.dia.ref new file mode 100755 index 000000000..0f55a952a --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11227.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 11227 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11227 +// +// <-- Short Description --> +// Scilab crashed when trying to use a structure with a non-existing field name containing "%" +// Existing field name +a = struct(); +a("toto%")=2; +assert_checkequal(a("toto%"), 2); +clear a +// Non-existing field name +refMsg = msprintf(gettext("%s: Wrong value for input argument #%d: not a valid field name.\n"),"%st_e",1); +a = struct(); +assert_checkerror("a(""toto%"")", refMsg); diff --git a/modules/data_structures/tests/nonreg_tests/bug_11227.tst b/modules/data_structures/tests/nonreg_tests/bug_11227.tst new file mode 100755 index 000000000..251fd28f6 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11227.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 11227 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11227 +// +// <-- Short Description --> +// Scilab crashed when trying to use a structure with a non-existing field name containing "%" + +// Existing field name +a = struct(); +a("toto%")=2; +assert_checkequal(a("toto%"), 2); + +clear a + +// Non-existing field name +refMsg = msprintf(gettext("%s: Wrong value for input argument #%d: not a valid field name.\n"),"%st_e",1); +a = struct(); +assert_checkerror("a(""toto%"")", refMsg); diff --git a/modules/data_structures/tests/nonreg_tests/bug_11396.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_11396.dia.ref new file mode 100755 index 000000000..9658c0ce1 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11396.dia.ref @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 11396 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11396 +// +// <-- Short Description --> +// Operation toto([])=[] with toto being an mlist fails. +function a=%s_i_toto(i,b,a), + if i<>[]&b<>[] then error("Invalid index");end; +endfunction +A=mlist(["toto","a"],1:4); +B=A; +A([])=[]; +assert_checkequal(A,B); diff --git a/modules/data_structures/tests/nonreg_tests/bug_11396.tst b/modules/data_structures/tests/nonreg_tests/bug_11396.tst new file mode 100755 index 000000000..5b66c6f5b --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_11396.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - INRIA - Serge Steer +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 11396 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=11396 +// +// <-- Short Description --> +// Operation toto([])=[] with toto being an mlist fails. + + +function a=%s_i_toto(i,b,a), + if i<>[]&b<>[] then error("Invalid index");end; +endfunction + + + +A=mlist(["toto","a"],1:4); +B=A; +A([])=[]; +assert_checkequal(A,B); + diff --git a/modules/data_structures/tests/nonreg_tests/bug_1322.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_1322.dia.ref new file mode 100755 index 000000000..6835e48eb --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1322.dia.ref @@ -0,0 +1,40 @@ +// ============================================================================= +// 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 1322 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1322 +// +// <-- Short Description --> +//if on call a function stored in tlist to produce more than one output +//argument the containing tlist is damaged when the function returns. +//simple test +function [d, s,p] = data_sum_1(val);d=val; s=argn(1);p=88;endfunction; +tlist1 = tlist(['x';'data';'fn'], 5, data_sum_1); +[d1,s1,p1] = tlist1.fn(4); +if d1<>4|s1<>3|p1<>88 then bugmes();quit;end +[d1,s1] = tlist1.fn(4); +if d1<>4|s1<>2 then bugmes();quit;end +d1 = tlist1.fn(4); +if d1<>4 then bugmes();quit;end +//complex test +function tlst = set_data(tlst, num),tlst.data = num;endfunction; +function [tlst, d] = get_data(tlst),d = tlst.data;endfunction; +function [tlst, s] = data_sum_2(tlst), + [tlst.tlist_data, s1] =tlst.tlist_data.get_fn(tlst.tlist_data); + s = s1 + tlst.data; + tlst.data = s; +endfunction; +//initialization of tlist objects containing references to functions +tlist2 = tlist(['x';'data';'set_fn';'get_fn'], [], set_data,get_data); +tlist1 = tlist(['x';'tlist_data';'data';'sum_fn'], tlist2, 5,data_sum_2); +tlist1.tlist_data =tlist1.tlist_data.set_fn(tlist1.tlist_data, 3); +tlist_data=tlist1.tlist_data; +//problem when executing the member function directly +[tlist1, tot2] = tlist1.sum_fn(tlist1); +if tot2<>8|tlist1.data<>8 then bugmes();quit;end +if or(tlist1.tlist_data<>tlist_data) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1322.tst b/modules/data_structures/tests/nonreg_tests/bug_1322.tst new file mode 100755 index 000000000..38063e2cd --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1322.tst @@ -0,0 +1,50 @@ +// ============================================================================= +// 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 1322 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1322 +// +// <-- Short Description --> +//if on call a function stored in tlist to produce more than one output +//argument the containing tlist is damaged when the function returns. + +//simple test + +function [d, s,p] = data_sum_1(val);d=val; s=argn(1);p=88;endfunction; +tlist1 = tlist(['x';'data';'fn'], 5, data_sum_1); +[d1,s1,p1] = tlist1.fn(4); +if d1<>4|s1<>3|p1<>88 then pause,end +[d1,s1] = tlist1.fn(4); +if d1<>4|s1<>2 then pause,end + +d1 = tlist1.fn(4); +if d1<>4 then pause,end + +//complex test + +function tlst = set_data(tlst, num),tlst.data = num;endfunction; +function [tlst, d] = get_data(tlst),d = tlst.data;endfunction; +function [tlst, s] = data_sum_2(tlst), + [tlst.tlist_data, s1] =tlst.tlist_data.get_fn(tlst.tlist_data); + s = s1 + tlst.data; + tlst.data = s; +endfunction; + +//initialization of tlist objects containing references to functions +tlist2 = tlist(['x';'data';'set_fn';'get_fn'], [], set_data,get_data); +tlist1 = tlist(['x';'tlist_data';'data';'sum_fn'], tlist2, 5,data_sum_2); + +tlist1.tlist_data =tlist1.tlist_data.set_fn(tlist1.tlist_data, 3); +tlist_data=tlist1.tlist_data; +//problem when executing the member function directly +[tlist1, tot2] = tlist1.sum_fn(tlist1); +if tot2<>8|tlist1.data<>8 then pause,end +if or(tlist1.tlist_data<>tlist_data) then pause,end + diff --git a/modules/data_structures/tests/nonreg_tests/bug_1604.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_1604.dia.ref new file mode 100755 index 000000000..493c028a7 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1604.dia.ref @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 1604 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1604 +// +// <-- Short Description --> +//Bug in parser while manipulating tlist inside list. +//Note that the bug is only visible/reproducible in release mode under +//Windows. It should also happen in debug but can't be easily seen... +t=list(gca());//create the data +R = t(1).data_bounds(:,1); //crash +if R<> [0;1] then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1604.tst b/modules/data_structures/tests/nonreg_tests/bug_1604.tst new file mode 100755 index 000000000..33f66c866 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1604.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - INRIA - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- TEST WITH GRAPHIC --> +// +// <-- Non-regression test for bug 1604 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1604 +// +// <-- Short Description --> +//Bug in parser while manipulating tlist inside list. +//Note that the bug is only visible/reproducible in release mode under +//Windows. It should also happen in debug but can't be easily seen... + + +t=list(gca());//create the data +R = t(1).data_bounds(:,1); //crash +if R<> [0;1] then pause,end + diff --git a/modules/data_structures/tests/nonreg_tests/bug_1712.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_1712.dia.ref new file mode 100755 index 000000000..cbfe66d94 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1712.dia.ref @@ -0,0 +1,34 @@ +// <-- Non-regression test for bug 1712 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1712 +// +// <-- Short Description --> +// Logical binary operations &,| with hypermatrices fail, as shown in the +// following examples. (The unary operation ~ succeeds.) +// +// -->hm=hypermat([2 2 2],1:8) +// +// -->hm>min(hm) & hm<max(hm) +// !--error 4 +// undefined variable : %l_h_l +// +// -->hm==min(hm) | hm==max(hm) +// !--error 4 +// undefined variable : %l_g_l +// +// -->~(hm==min(hm)) +// ans = +// +// (:,:,1) +// +// ! F T ! +// ! T T ! +// ... +// Copyright INRIA +// Scilab Project - Pierre MARECHAL +// Copyright INRIA 2005 +// Date : 6 fevrier 2005 +//hm = hypermat([2 2 2],1:8); +//if execstr('hm>min(hm) & hm<max(hm)','errcatch') <>0 then bugmes();quit;end +//if execstr('hm==min(hm) | hm==max(hm)','errcatch') <>0 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1712.tst b/modules/data_structures/tests/nonreg_tests/bug_1712.tst new file mode 100755 index 000000000..a160f3094 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1712.tst @@ -0,0 +1,38 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005-2008 - INRIA - Pierre MARECHAL <pierre.marechal@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 1712 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1712 +// +// <-- Short Description --> +// Logical binary operations &,| with hypermatrices fail, as shown in the +// following examples. (The unary operation ~ succeeds.) +// +// -->hm=hypermat([2 2 2],1:8) +// +// -->hm>min(hm) & hm<max(hm) +// !--error 4 +// undefined variable : %l_h_l +// +// -->hm==min(hm) | hm==max(hm) +// !--error 4 +// undefined variable : %l_g_l +// +// -->~(hm==min(hm)) +// ans = +// +// (:,:,1) +// +// ! F T ! +// ! T T ! +// ... + +//hm = hypermat([2 2 2],1:8); +//if execstr('hm>min(hm) & hm<max(hm)','errcatch') <>0 then pause,end +//if execstr('hm==min(hm) | hm==max(hm)','errcatch') <>0 then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1772.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_1772.dia.ref new file mode 100755 index 000000000..35f66df03 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1772.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 1772 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1772 +// +// <-- Short Description --> +// There is a problem while inserting an object of type list in an undefined struct +// field +S.x=1; +if execstr("S.y.z=list();","errcatch") <> 0 then bugmes();quit;end +if S.y.z<>list() then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1772.tst b/modules/data_structures/tests/nonreg_tests/bug_1772.tst new file mode 100755 index 000000000..ef847fe17 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1772.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 1772 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1772 +// +// <-- Short Description --> +// There is a problem while inserting an object of type list in an undefined struct +// field + +S.x=1; +if execstr("S.y.z=list();","errcatch") <> 0 then pause,end +if S.y.z<>list() then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1784.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_1784.dia.ref new file mode 100755 index 000000000..1dfcf90de --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1784.dia.ref @@ -0,0 +1,20 @@ +// <-- Non-regression test for bug 1784 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1784 +// +// <-- Short Description --> +// Problem while inserting a matrix in an N-D matrix +// Copyright INRIA +// Scilab Project - Serge Steer +// Copyright INRIA 2005 +// Date : 23 janvier 2006 +A = hypermat([3,3,2]); +try + A(1,1:3,1:3)=[1 2 3;4 5 6;7 8 9]; +catch + if %T then bugmes();quit;end + return; +end +if or(A<>hypermat([3,3,3],[1;0;0;4;0;0;7;0;0;2;0;0;5;0;0;8;0;0;3;0;0; ... + 6;0;0;9;0;0])) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1784.tst b/modules/data_structures/tests/nonreg_tests/bug_1784.tst new file mode 100755 index 000000000..e1bf9e1a4 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1784.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2005-2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 1784 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1784 +// +// <-- Short Description --> +// Problem while inserting a matrix in an N-D matrix + +A = hypermat([3,3,2]); + +try + A(1,1:3,1:3)=[1 2 3;4 5 6;7 8 9]; +catch + if %T then pause,end + return; +end + +if or(A<>hypermat([3,3,3],[1;0;0;4;0;0;7;0;0;2;0;0;5;0;0;8;0;0;3;0;0; ... + 6;0;0;9;0;0])) then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1956.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_1956.dia.ref new file mode 100755 index 000000000..8347d9a1f --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1956.dia.ref @@ -0,0 +1,27 @@ +// <-- Non-regression test for bug 1956 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1956 +// +// <-- Short Description --> +// this works for example: +// a=10; // a constant +// for i=1:2 +// d(i)=a; +// end +// but it doesn't work if 'a' is a structure. +// I find a solution for a structure: +// a.b=[1 2 3]; +// a.c=[4 5 6] +// but it's not smart and clear code... +// Copyright INRIA +// Scilab Project - Serge Steer +// Copyright INRIA 2006 +// Date : 4 mai 2006 +clear a d +a.b = [1 2 3]; +d(1) = a; +if or(d<>a) then bugmes();quit;end +d(2)=a; +if or(d(1)<>a) then bugmes();quit;end +if or(d(2)<>a) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_1956.tst b/modules/data_structures/tests/nonreg_tests/bug_1956.tst new file mode 100755 index 000000000..61ec5bff9 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_1956.tst @@ -0,0 +1,32 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 1956 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=1956 +// +// <-- Short Description --> +// this works for example: +// a=10; // a constant +// for i=1:2 +// d(i)=a; +// end +// but it doesn't work if 'a' is a structure. +// I find a solution for a structure: +// a.b=[1 2 3]; +// a.c=[4 5 6] +// but it's not smart and clear code... + +clear a d +a.b = [1 2 3]; +d(1) = a; +if or(d<>a) then pause,end + +d(2)=a; +if or(d(1)<>a) then pause,end +if or(d(2)<>a) then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_2081.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_2081.dia.ref new file mode 100755 index 000000000..92cb2b2ce --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_2081.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 2081 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2081 +// +// <-- Short Description --> +//impossible matrix insertion into hypermatrix element of a tlist +tl = tlist(["test","cube"],[]); +tl.cube = hypermat([2,2,2],[1:8]); +tl.cube(:,:,1) = ones(2,2); +if or(tl.cube(:)<>[1;1;1;1;5;6;7;8]) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_2081.tst b/modules/data_structures/tests/nonreg_tests/bug_2081.tst new file mode 100755 index 000000000..8640f07ec --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_2081.tst @@ -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 2081 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2081 +// +// <-- Short Description --> +//impossible matrix insertion into hypermatrix element of a tlist + + +tl = tlist(["test","cube"],[]); +tl.cube = hypermat([2,2,2],[1:8]); +tl.cube(:,:,1) = ones(2,2); +if or(tl.cube(:)<>[1;1;1;1;5;6;7;8]) then pause,end + + diff --git a/modules/data_structures/tests/nonreg_tests/bug_2588.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_2588.dia.ref new file mode 100755 index 000000000..f57669a66 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_2588.dia.ref @@ -0,0 +1,49 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2009 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 2588 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2588 +// +// <-- Short Description --> +//Calling a function with no input arugment contained in an mlist +//generates an error +// <-- ENGLISH IMPOSED --> +M=[]; +function y=foo(a) + if argn(2)==0 then + y=%s + else + y=a + end +endfunction +M.fun=foo; +if M.fun()+1<>%s+1 then bugmes();quit;end +if M.fun(33)+1<>34 then bugmes();quit;end +clear foo; +function [x,y]=foo(a,b) + x=a*b + y=a-b +endfunction +M.fun=foo; +[u,v]=M.fun(2,3); +if u<>2*3|v<>2-3 then bugmes();quit;end +[u]=M.fun(2,3); +if u<>2*3 then bugmes();quit;end +N=[]; +N.x=M; +if N.x.fun(2,3)<>2*3 then bugmes();quit;end +%fptr_i_s=generic_i_s; +M.fun=sin; +if M.fun(%pi)<>sin(%pi) then bugmes();quit;end; +%fptr_i_s=generic_i_s;M=[]; +ieee(0); +M.fun=ieee; +if M.fun()<>0 then bugmes();quit;end +A=rand(2,2); +M.fun=A; +if M.fun()<>A then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_2588.tst b/modules/data_structures/tests/nonreg_tests/bug_2588.tst new file mode 100755 index 000000000..c71d2af1b --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_2588.tst @@ -0,0 +1,60 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2009 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 2588 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2588 +// +// <-- Short Description --> +//Calling a function with no input arugment contained in an mlist +//generates an error +// <-- ENGLISH IMPOSED --> + +M=[]; +function y=foo(a) + if argn(2)==0 then + y=%s + else + y=a + end +endfunction +M.fun=foo; +if M.fun()+1<>%s+1 then pause,end +if M.fun(33)+1<>34 then pause,end +clear foo; +function [x,y]=foo(a,b) + x=a*b + y=a-b +endfunction +M.fun=foo; +[u,v]=M.fun(2,3); +if u<>2*3|v<>2-3 then pause,end +[u]=M.fun(2,3); +if u<>2*3 then pause,end + +N=[]; +N.x=M; +if N.x.fun(2,3)<>2*3 then pause,end + + + +%fptr_i_s=generic_i_s; +M.fun=sin; +if M.fun(%pi)<>sin(%pi) then pause,end; + +%fptr_i_s=generic_i_s;M=[]; +ieee(0); +M.fun=ieee; +if M.fun()<>0 then pause,end + + +A=rand(2,2); +M.fun=A; +if M.fun()<>A then pause,end + + diff --git a/modules/data_structures/tests/nonreg_tests/bug_3005.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_3005.dia.ref new file mode 100755 index 000000000..511941844 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_3005.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 3005 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3005 +// +// <-- Short Description --> +//can't modify a hypermatrix stored into a list. +a = list(33,ones(2,2,2)); +if execstr('a(2)(2,2,2) = 3','errcatch')<>0 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_3005.tst b/modules/data_structures/tests/nonreg_tests/bug_3005.tst new file mode 100755 index 000000000..7032b11ba --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_3005.tst @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2006-2008 - INRIA - Serge STEER <serge.steer@inria.fr> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 3005 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3005 +// +// <-- Short Description --> +//can't modify a hypermatrix stored into a list. +a = list(33,ones(2,2,2)); +if execstr('a(2)(2,2,2) = 3','errcatch')<>0 then pause,end + + diff --git a/modules/data_structures/tests/nonreg_tests/bug_3135.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_3135.dia.ref new file mode 100755 index 000000000..32631acb1 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_3135.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 3135 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3135 +// +// <-- Short Description --> +//Problem with extraction and hypermatrices, especially when using patterns with a dollar +a=hypermat([3,15,10]); +for i=1:15 + if or(size(a(:,i:3:$,:))<>size(a(:,i:3:15,:))) then bugmes();quit;end +end +for i=1:15 + if or(size(a(:,i:2:$,:))<>size(a(:,i:2:15,:))) then bugmes();quit;end +end +for i=1:15 + if or(size(a(:,i:$,:))<>size(a(:,i:15,:))) then bugmes();quit;end +end diff --git a/modules/data_structures/tests/nonreg_tests/bug_3135.tst b/modules/data_structures/tests/nonreg_tests/bug_3135.tst new file mode 100755 index 000000000..7de476d43 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_3135.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// 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 3135 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3135 +// +// <-- Short Description --> +//Problem with extraction and hypermatrices, especially when using patterns with a dollar + +a=hypermat([3,15,10]); +for i=1:15 + if or(size(a(:,i:3:$,:))<>size(a(:,i:3:15,:))) then pause,end +end +for i=1:15 + if or(size(a(:,i:2:$,:))<>size(a(:,i:2:15,:))) then pause,end +end +for i=1:15 + if or(size(a(:,i:$,:))<>size(a(:,i:15,:))) then pause,end +end diff --git a/modules/data_structures/tests/nonreg_tests/bug_3459.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_3459.dia.ref new file mode 100755 index 000000000..997490aef --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_3459.dia.ref @@ -0,0 +1,57 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 3459 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3459 +// +// <-- Short Description --> +// -->l(2).row1(2)=M.row1(1) +// l = +// +// list with entries: +// 1: 1 +// !--error 246 +// Function not defined for given argument type(s). +function M=%to_e(varargin) + M = varargin($), + select varargin(1) + case 'row2' then + M.N = M.N(2, eye()) + M.V = M.V(2, eye()) + case 'row1' then + M.N = M.N(1, eye()) + M.V = M.V(1, eye()) + else + M.N = M.N(varargin(1:$ - 1)) + M.V = M.V(varargin(1:$ - 1)) + end +endfunction +%to_6=%to_e + %to_6 = + +[M]=%to_6(varargin) +function M=%to_i_to(varargin) + M=varargin($);N=varargin($-1) + select varargin(1) + case 'row2' + M.N(2,:)=N.N + M.V(2,:)=N.V + case 'row1' + M.N(1,:)=N.N + M.V(1,:)=N.V + else + M.N(varargin(1:$-2))=N.N + M.V(varargin(1:$-2))=N.V + end +endfunction +M = mlist(['to','V','N'],[1 2 3;4 5 6],['a','b','c';'d','e','f']); +M.row1(2) = M.row2(1); +l = list(1,M,2); +l(2).row1(2) = M.row1(1); +if ~and(l(2).row1(2) == M.row1(1)) then bugmes();quit;end +if ~and(M.row1(2) == M.row2(1)) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_3459.tst b/modules/data_structures/tests/nonreg_tests/bug_3459.tst new file mode 100755 index 000000000..ce8ab8564 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_3459.tst @@ -0,0 +1,63 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2008 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + + +// <-- Non-regression test for bug 3459 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3459 +// +// <-- Short Description --> +// -->l(2).row1(2)=M.row1(1) +// l = +// +// list with entries: +// 1: 1 +// !--error 246 +// Function not defined for given argument type(s). + + +function M=%to_e(varargin) + M = varargin($), + select varargin(1) + case 'row2' then + M.N = M.N(2, eye()) + M.V = M.V(2, eye()) + case 'row1' then + M.N = M.N(1, eye()) + M.V = M.V(1, eye()) + else + M.N = M.N(varargin(1:$ - 1)) + M.V = M.V(varargin(1:$ - 1)) + end +endfunction + + +%to_6=%to_e + +function M=%to_i_to(varargin) + M=varargin($);N=varargin($-1) + select varargin(1) + case 'row2' + M.N(2,:)=N.N + M.V(2,:)=N.V + case 'row1' + M.N(1,:)=N.N + M.V(1,:)=N.V + else + M.N(varargin(1:$-2))=N.N + M.V(varargin(1:$-2))=N.V + end +endfunction + +M = mlist(['to','V','N'],[1 2 3;4 5 6],['a','b','c';'d','e','f']); +M.row1(2) = M.row2(1); +l = list(1,M,2); +l(2).row1(2) = M.row1(1); + +if ~and(l(2).row1(2) == M.row1(1)) then pause,end +if ~and(M.row1(2) == M.row2(1)) then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_4015.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_4015.dia.ref new file mode 100755 index 000000000..ddb94c909 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_4015.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// 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 4015 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4015 +// +// <-- Short Description --> +// "Flip left to right" x = x(:,$:-1:1,:) no longer works on hypermatrices. +// This used to work in version 4. +x=matrix(1:24,[2 3 4]); +ierr = execstr("x = x(:,$:-1:1,:);","errcatch"); +if ierr<>0 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_4015.tst b/modules/data_structures/tests/nonreg_tests/bug_4015.tst new file mode 100755 index 000000000..6a43945f7 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_4015.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// 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 4015 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4015 +// +// <-- Short Description --> +// "Flip left to right" x = x(:,$:-1:1,:) no longer works on hypermatrices. +// This used to work in version 4. + +x=matrix(1:24,[2 3 4]); +ierr = execstr("x = x(:,$:-1:1,:);","errcatch"); +if ierr<>0 then pause; end + diff --git a/modules/data_structures/tests/nonreg_tests/bug_424.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_424.dia.ref new file mode 100755 index 000000000..21bee8ada --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_424.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 424 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=424 +// +// <-- Short Description --> +// hypermatrix insertion problem +if execstr("S=[];for k=1:5,S(1:2,1:3,k)=rand(2,3);end","errcatch")<>0 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_424.tst b/modules/data_structures/tests/nonreg_tests/bug_424.tst new file mode 100755 index 000000000..95020e453 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_424.tst @@ -0,0 +1,17 @@ +// ============================================================================= +// 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 424 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=424 +// +// <-- Short Description --> +// hypermatrix insertion problem + +if execstr("S=[];for k=1:5,S(1:2,1:3,k)=rand(2,3);end","errcatch")<>0 then pause; end + diff --git a/modules/data_structures/tests/nonreg_tests/bug_475.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_475.dia.ref new file mode 100755 index 000000000..19a872db1 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_475.dia.ref @@ -0,0 +1,31 @@ +// <-- Non-regression test for bug 475 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=475 +// +// <-- Short Description --> +// Bug Report Id: 120442003624175150 +// m=min(a) and m=max(a) give correct results +// +// +// On Scilab CVS with " min(), max() " function +// The Error Messages are: +// !--error 59 +// incorrect # of outputs in the function +// arguments are : +// x +// +// Commands: a=hypermat([3,3,1],uint16(1:9)); [m,k]=max(a) +// +// or +// +// a=hypermat([3,3,1],uint16(1:9)); [m,k]=min(a) +// +// Enrico Segre on Linux version RH9 distribution with gnome as window manager +// Israel July 24, 2003 at 17:51:50 +a = hypermat([3,3,1],uint16(1:9)); +result = execstr("[m,k]=max(a)","errcatch","n"); +if result <> 0 then bugmes();quit;end +if result == 0 then + if execstr("[m,k]=min(a)","errcatch","n") <> 0 then bugmes();quit;end +end diff --git a/modules/data_structures/tests/nonreg_tests/bug_475.tst b/modules/data_structures/tests/nonreg_tests/bug_475.tst new file mode 100755 index 000000000..904fcb147 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_475.tst @@ -0,0 +1,42 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 475 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=475 +// +// <-- Short Description --> +// Bug Report Id: 120442003624175150 +// m=min(a) and m=max(a) give correct results +// +// +// On Scilab CVS with " min(), max() " function +// The Error Messages are: +// !--error 59 +// incorrect # of outputs in the function +// arguments are : +// x +// +// Commands: a=hypermat([3,3,1],uint16(1:9)); [m,k]=max(a) +// +// or +// +// a=hypermat([3,3,1],uint16(1:9)); [m,k]=min(a) +// +// Enrico Segre on Linux version RH9 distribution with gnome as window manager +// Israel July 24, 2003 at 17:51:50 + +a = hypermat([3,3,1],uint16(1:9)); + +result = execstr("[m,k]=max(a)","errcatch","n"); + +if result <> 0 then pause,end + +if result == 0 then + if execstr("[m,k]=min(a)","errcatch","n") <> 0 then pause,end +end diff --git a/modules/data_structures/tests/nonreg_tests/bug_476.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_476.dia.ref new file mode 100755 index 000000000..6693b7758 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_476.dia.ref @@ -0,0 +1,39 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 476 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=476 +// +// <-- Short Description --> +// Bug Report Id: 120442003624185651 +// +// +// On Scilab CVS with " %hm_find " function +// The Error Messages are: +// wrong result +// Commands: -->a=hypermat([3,3,1],int8(1:9)); +// +// -->[i,j]=find(a==5) +// j = +// +// 1. +// i = +// +// 0. +// +// -->[i,j,k]=find(a==5) +// k = +// +// 1. +// ... +//correct=%F +a = hypermat([3,3,1],int8(1:9)); +[i,j] = find(a==5); +[k,l,m] = find(a==5); +assert_checkequal(m, 1); +assert_checkfalse((i==k)<>(j==l)); diff --git a/modules/data_structures/tests/nonreg_tests/bug_476.tst b/modules/data_structures/tests/nonreg_tests/bug_476.tst new file mode 100755 index 000000000..94d2fb214 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_476.tst @@ -0,0 +1,42 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 476 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=476 +// +// <-- Short Description --> +// Bug Report Id: 120442003624185651 +// +// +// On Scilab CVS with " %hm_find " function +// The Error Messages are: +// wrong result +// Commands: -->a=hypermat([3,3,1],int8(1:9)); +// +// -->[i,j]=find(a==5) +// j = +// +// 1. +// i = +// +// 0. +// +// -->[i,j,k]=find(a==5) +// k = +// +// 1. +// ... + +//correct=%F +a = hypermat([3,3,1],int8(1:9)); +[i,j] = find(a==5); +[k,l,m] = find(a==5); + +assert_checkequal(m, 1); +assert_checkfalse((i==k)<>(j==l)); diff --git a/modules/data_structures/tests/nonreg_tests/bug_477.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_477.dia.ref new file mode 100755 index 000000000..38b533e18 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_477.dia.ref @@ -0,0 +1,41 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 477 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=477 +// +// <-- Short Description --> +// Bug Report Id: 12044200362419444 +// %hm_maxi and %hm_mini are indeed currently defined with a _single_ return argument. IMHO they should be extended analogously to max, min and %hm_find, returning optionally either a vector of indices of the max/min. +// +// On Scilab CVS with " %hm_maxi, %hm_mini " function +// The Error Messages are: +// -->a=hypermat([3,3,1],1:9); +// +// -->[m]=max(a) +// i = +// +// 9. +// +// -->[m,i]=max(a) +// !--error 59 +// incorrect # of outputs in the function +// arguments are : +// x +// +// -->[m,i,j,k]=max(a) +// !--error 78 +// ... +a = hypermat([1,3,3],1:9); +assert_checkequal(max(a), 9); +result = execstr("[n,i]=max(a)","errcatch","n"); +assert_checkequal(result, 0); +assert_checkequal(n, 9); +assert_checkfalse(or(i<>[1,3,3])); +errmsg=msprintf(_("%s: Wrong number of output argument(s): %d to %d expected.\n"), "max", 1, 2); +assert_checkerror("[m,i,j,k]=max(a)", errmsg, 78); diff --git a/modules/data_structures/tests/nonreg_tests/bug_477.tst b/modules/data_structures/tests/nonreg_tests/bug_477.tst new file mode 100755 index 000000000..646775940 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_477.tst @@ -0,0 +1,44 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 477 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=477 +// +// <-- Short Description --> +// Bug Report Id: 12044200362419444 +// %hm_maxi and %hm_mini are indeed currently defined with a _single_ return argument. IMHO they should be extended analogously to max, min and %hm_find, returning optionally either a vector of indices of the max/min. +// +// On Scilab CVS with " %hm_maxi, %hm_mini " function +// The Error Messages are: +// -->a=hypermat([3,3,1],1:9); +// +// -->[m]=max(a) +// i = +// +// 9. +// +// -->[m,i]=max(a) +// !--error 59 +// incorrect # of outputs in the function +// arguments are : +// x +// +// -->[m,i,j,k]=max(a) +// !--error 78 +// ... + +a = hypermat([1,3,3],1:9); +assert_checkequal(max(a), 9); + +result = execstr("[n,i]=max(a)","errcatch","n"); +assert_checkequal(result, 0); +assert_checkequal(n, 9); +assert_checkfalse(or(i<>[1,3,3])); +errmsg=msprintf(_("%s: Wrong number of output argument(s): %d to %d expected.\n"), "max", 1, 2); +assert_checkerror("[m,i,j,k]=max(a)", errmsg, 78); diff --git a/modules/data_structures/tests/nonreg_tests/bug_480.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_480.dia.ref new file mode 100755 index 000000000..97748f257 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_480.dia.ref @@ -0,0 +1,36 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 480 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=480 +// +// <-- Short Description --> +// Bug Report Id: 12070200362710754 +// [u]intN() and iconvert() do not handle hypermatrices. It would be nice if they would. +// There is a workaround - +// hypermat(a.dims,int8(a.entries)) - but it is somehow a detour. +// +// On Scilab CVS with " intN(), iconvert() " function +// The Error Messages are: +// -->a=hypermat([3,3,1],1:9); +// +// -->int8(a) +// !--error 53 +// invalid input (waiting for real or complex matrix) +// +// Commands: +// +// Enrico Segre on Linux version distribution RH9 with as window manager +// Israel July 27, 2003 at 10:7:54 +a=hypermat([1,3,3],1:9); +assert_checktrue(execstr("int8(a)", "errcatch")==0) + ans = + + T +toto = (hypermat(a.dims,int8(a.entries)) == int8(a)); +assert_checkfalse(~(and(toto(:,:,1)))); diff --git a/modules/data_structures/tests/nonreg_tests/bug_480.tst b/modules/data_structures/tests/nonreg_tests/bug_480.tst new file mode 100755 index 000000000..7d3b4f3dc --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_480.tst @@ -0,0 +1,35 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 480 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=480 +// +// <-- Short Description --> +// Bug Report Id: 12070200362710754 +// [u]intN() and iconvert() do not handle hypermatrices. It would be nice if they would. +// There is a workaround - +// hypermat(a.dims,int8(a.entries)) - but it is somehow a detour. +// +// On Scilab CVS with " intN(), iconvert() " function +// The Error Messages are: +// -->a=hypermat([3,3,1],1:9); +// +// -->int8(a) +// !--error 53 +// invalid input (waiting for real or complex matrix) +// +// Commands: +// +// Enrico Segre on Linux version distribution RH9 with as window manager +// Israel July 27, 2003 at 10:7:54 + +a=hypermat([1,3,3],1:9); +assert_checktrue(execstr("int8(a)", "errcatch")==0) +toto = (hypermat(a.dims,int8(a.entries)) == int8(a)); +assert_checkfalse(~(and(toto(:,:,1)))); diff --git a/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref new file mode 100755 index 000000000..213f3dfeb --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_5588.dia.ref @@ -0,0 +1,63 @@ +// ============================================================================= +// 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 5588 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5588 +// +// <-- Short Description --> +// null() of a tlist() field shifts all remaining values with respect to +// field names. +// tlist null assignment indexed by a name +clear %0_i_a %0_i_A +t=tlist(["a","b","c"],10,"foo"); +if execstr("t.b=null()","errcatch")==0 then bugmes();quit;end +function t=%0_i_a(i,void,t) + f=getfield(1,t); + k=find(f==i); + if k<>[] then + f(k)=[]; + setfield(k,null(),t); + setfield(1,f,t); + end +endfunction +if execstr("t.b=null()","errcatch")<>0 then bugmes();quit;end +if or(t<>tlist(["a","c"],"foo")) then bugmes();quit;end +// tlist null assignment indexed by a number +t=tlist(["a","b","c"],10,"foo"); +if execstr("t(2)=null()","errcatch")<>0 then bugmes();quit;end +if or(t<>tlist(["a","b","c"],"foo")) then bugmes();quit;end +//struct null assignment indexed by a name +T.x="foo";T.y=33; +if execstr("T.dims=null()","errcatch")==0 then bugmes();quit;end +if execstr("T(1,1)=null()","errcatch")==0 then bugmes();quit;end +if execstr("T.x=null()","errcatch")<>0 then bugmes();quit;end +T1.y=33; +if or(T<>T1) then bugmes();quit;end +T1.x="foo"; +if execstr("T(1)=null()","errcatch")==0 then bugmes();quit;end +//cell null assignment +c=makecell([1,2],1,"xyz"); +if execstr("c(1,1)=null()","errcatch")==0 then bugmes();quit;end +if execstr("c.dims=null()","errcatch")==0 then bugmes();quit;end +//sublist null assigment indexed by a name +L=tlist(["foo","x","y"],mlist(["A","b","c"],10,"zoo"),1:5); +if execstr("L.x.b=null()","errcatch")==0 then bugmes();quit;end +%0_i_A=%0_i_a; +if execstr("L.x.b=null()","errcatch")<>0 then bugmes();quit;end +if or(L<>tlist(["foo","x","y"],mlist(["A","c"],"zoo"),1:5)) then bugmes();quit;end +//sublist null assigment indexed by a number +clear %0_i_A +L=mlist(["foo","x","y"],tlist(["A","b","c"],10,"zoo"),1:5); +if execstr("L.x(2)=null()","errcatch")<>0 then bugmes();quit;end +if or(L<>mlist(["foo","x","y"],tlist(["A","b","c"],"zoo"),1:5)) then bugmes();quit;end +//try a more complex context +L=tlist(["foo","x","y"],list(33,mlist(["A","b","c"],10,"zoo")),1:5); +%0_i_A=%0_i_a; +if execstr("L.x(2).b=null()","errcatch")<>0 then bugmes();quit;end +if or(L<>tlist(["foo","x","y"],list(33,mlist(["A","c"],"zoo")),1:5)) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_5588.tst b/modules/data_structures/tests/nonreg_tests/bug_5588.tst new file mode 100755 index 000000000..7ee951a49 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_5588.tst @@ -0,0 +1,75 @@ +// ============================================================================= +// 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 5588 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5588 +// +// <-- Short Description --> +// null() of a tlist() field shifts all remaining values with respect to +// field names. + +// tlist null assignment indexed by a name +clear %0_i_a %0_i_A +t=tlist(["a","b","c"],10,"foo"); +if execstr("t.b=null()","errcatch")==0 then pause,end +function t=%0_i_a(i,void,t) + f=getfield(1,t); + k=find(f==i); + if k<>[] then + f(k)=[]; + setfield(k,null(),t); + setfield(1,f,t); + end +endfunction +if execstr("t.b=null()","errcatch")<>0 then pause,end +if or(t<>tlist(["a","c"],"foo")) then pause,end + +// tlist null assignment indexed by a number +t=tlist(["a","b","c"],10,"foo"); +if execstr("t(2)=null()","errcatch")<>0 then pause,end +if or(t<>tlist(["a","b","c"],"foo")) then pause,end + +//struct null assignment indexed by a name +T.x="foo";T.y=33; +if execstr("T.dims=null()","errcatch")==0 then pause,end +if execstr("T(1,1)=null()","errcatch")==0 then pause,end + +if execstr("T.x=null()","errcatch")<>0 then pause,end +T1.y=33; +if or(T<>T1) then pause,end +T1.x="foo"; +if execstr("T(1)=null()","errcatch")==0 then pause,end + + +//cell null assignment +c=makecell([1,2],1,"xyz"); +if execstr("c(1,1)=null()","errcatch")==0 then pause,end +if execstr("c.dims=null()","errcatch")==0 then pause,end + +//sublist null assigment indexed by a name +L=tlist(["foo","x","y"],mlist(["A","b","c"],10,"zoo"),1:5); +if execstr("L.x.b=null()","errcatch")==0 then pause,end +%0_i_A=%0_i_a; +if execstr("L.x.b=null()","errcatch")<>0 then pause,end +if or(L<>tlist(["foo","x","y"],mlist(["A","c"],"zoo"),1:5)) then pause,end + +//sublist null assigment indexed by a number +clear %0_i_A +L=mlist(["foo","x","y"],tlist(["A","b","c"],10,"zoo"),1:5); +if execstr("L.x(2)=null()","errcatch")<>0 then pause,end +if or(L<>mlist(["foo","x","y"],tlist(["A","b","c"],"zoo"),1:5)) then pause,end + +//try a more complex context +L=tlist(["foo","x","y"],list(33,mlist(["A","b","c"],10,"zoo")),1:5); +%0_i_A=%0_i_a; +if execstr("L.x(2).b=null()","errcatch")<>0 then pause,end + +if or(L<>tlist(["foo","x","y"],list(33,mlist(["A","c"],"zoo")),1:5)) then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_5612.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_5612.dia.ref new file mode 100755 index 000000000..487b86d36 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_5612.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 5612 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5612 +// +// <-- Short Description --> +// There is no way for deleting a structure field. +s = struct("txt","Hello","num",%pi,"pol",%z^2+1); +if or(getfield(1,s)<>["st", "dims", "txt", "num", "pol"]) then bugmes();quit;end +// Delete the field called 'num' +s.num = null(); +// Check that 'num' field has been deleted +if or(getfield(1,s)<>["st", "dims", "txt", "pol"]) then bugmes();quit;end +// Check that remaining fields have the right value +if s.txt<>"Hello" then bugmes();quit;end +if s.pol<>%z^2+1 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_5612.tst b/modules/data_structures/tests/nonreg_tests/bug_5612.tst new file mode 100755 index 000000000..ec4a44e4b --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_5612.tst @@ -0,0 +1,32 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 5612 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5612 +// +// <-- Short Description --> +// There is no way for deleting a structure field. + +s = struct("txt","Hello","num",%pi,"pol",%z^2+1); + +if or(getfield(1,s)<>["st", "dims", "txt", "num", "pol"]) then pause; end + +// Delete the field called 'num' +s.num = null(); + +// Check that 'num' field has been deleted +if or(getfield(1,s)<>["st", "dims", "txt", "pol"]) then pause; end + +// Check that remaining fields have the right value +if s.txt<>"Hello" then pause; end +if s.pol<>%z^2+1 then pause; end + + diff --git a/modules/data_structures/tests/nonreg_tests/bug_568.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_568.dia.ref new file mode 100755 index 000000000..fcfe9a9be --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_568.dia.ref @@ -0,0 +1,25 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 568 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=568 +// +// <-- Short Description --> +// when I have defined a variable like this : +// -->aa=zeros(4,4,11); +// I can't insert a part of this hypermatrix in a indexed +// undefined variable bb. +// -->bb(1,1,:)=aa(1,1,:) ; +// This appears in all operating system and version 2.7, 2.7.2 +// and 2.8 alpha +// +// fixed in CVS version +// exec( "/home/huynh/poubelle/testNonReg/bug568.sce"); +// exec("e:\testNonReg\bug568.sce"); +aa=zeros(4,4,11); +if execstr('bb(1,1,:)=aa(1,1,:)','errcatch') <> 15 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_568.tst b/modules/data_structures/tests/nonreg_tests/bug_568.tst new file mode 100755 index 000000000..79aa138da --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_568.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 568 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=568 +// +// <-- Short Description --> +// when I have defined a variable like this : +// -->aa=zeros(4,4,11); +// I can't insert a part of this hypermatrix in a indexed +// undefined variable bb. +// -->bb(1,1,:)=aa(1,1,:) ; +// This appears in all operating system and version 2.7, 2.7.2 +// and 2.8 alpha +// +// fixed in CVS version + + +// exec( "/home/huynh/poubelle/testNonReg/bug568.sce"); +// exec("e:\testNonReg\bug568.sce"); + +aa=zeros(4,4,11); +if execstr('bb(1,1,:)=aa(1,1,:)','errcatch') <> 15 then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_570.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_570.dia.ref new file mode 100755 index 000000000..a7e6b2029 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_570.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 570 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=570 +// +// <-- Short Description --> +// missing overload for string hypermatrix insertion? +// See bug 566 +if execstr('a(2,3,2)=''x''','errcatch') <> 0 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_570.tst b/modules/data_structures/tests/nonreg_tests/bug_570.tst new file mode 100755 index 000000000..72557fdb5 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_570.tst @@ -0,0 +1,18 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 570 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=570 +// +// <-- Short Description --> +// missing overload for string hypermatrix insertion? +// See bug 566 + + +if execstr('a(2,3,2)=''x''','errcatch') <> 0 then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_6639.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_6639.dia.ref new file mode 100755 index 000000000..d1b09d85e --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_6639.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. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 6639 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6639 +// +// <-- Short Description --> +// "hypermat" did not remove higher dimensions equal to 1 +a=hypermat([3,2,1]); +if type(a)<>1 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_6639.tst b/modules/data_structures/tests/nonreg_tests/bug_6639.tst new file mode 100755 index 000000000..a66a50aa7 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_6639.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. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 6639 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6639 +// +// <-- Short Description --> +// "hypermat" did not remove higher dimensions equal to 1 +a=hypermat([3,2,1]); +if type(a)<>1 then pause,end diff --git a/modules/data_structures/tests/nonreg_tests/bug_6792.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_6792.dia.ref new file mode 100755 index 000000000..9cfd2c609 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_6792.dia.ref @@ -0,0 +1,36 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA -Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 6792 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6792 +// +// <-- Short Description --> +// mis-interpretation of macro arguments when the macro call appears in an list extraction +function [x,y]=fun(varargin), x=varargin,y=size(varargin),endfunction +function y=%foo_e(name,ml),y=fun,endfunction +function y=%bar_e(name,ml),y=type,endfunction +M=mlist(['foo']); +N=mlist(['bar']); +M1=mlist(['foo','meth'],fun); +[x,y]=M.meth(['hello' 'world']); +if or(x<>list(['hello' 'world']))|y<>1 then bugmes();quit;end +[x,y]=M1.meth(['hello' 'world']); +if or(x<>list(['hello' 'world']))|y<>1 then bugmes();quit;end +[x,y]=M.meth('xx',list(1,2,3)); +if or(x<>list('xx',list(1,2,3)))|y<>2 then bugmes();quit;end +[x,y]=M1.meth('xx',list(1,2,3)); +if or(x<>list('xx',list(1,2,3)))|y<>2 then bugmes();quit;end +[x,y]=M.meth('xx',1,2,3); +if or(x<>list('xx',1,2,3))|y<>4 then bugmes();quit;end +[x,y]=M1.meth('xx',1,2,3); +if or(x<>list('xx',1,2,3))|y<>4 then bugmes();quit;end +// extraction returns a built-in +t=N.foo(123); +if (t<>1) then bugmes();quit;end +t=N.foo(['a' 'b']); +if (t<>10) then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_6792.tst b/modules/data_structures/tests/nonreg_tests/bug_6792.tst new file mode 100755 index 000000000..cc9866d15 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_6792.tst @@ -0,0 +1,44 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - INRIA -Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 6792 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6792 +// +// <-- Short Description --> +// mis-interpretation of macro arguments when the macro call appears in an list extraction +function [x,y]=fun(varargin), x=varargin,y=size(varargin),endfunction +function y=%foo_e(name,ml),y=fun,endfunction +function y=%bar_e(name,ml),y=type,endfunction + +M=mlist(['foo']); +N=mlist(['bar']); +M1=mlist(['foo','meth'],fun); + +[x,y]=M.meth(['hello' 'world']); +if or(x<>list(['hello' 'world']))|y<>1 then pause,end +[x,y]=M1.meth(['hello' 'world']); +if or(x<>list(['hello' 'world']))|y<>1 then pause,end + +[x,y]=M.meth('xx',list(1,2,3)); +if or(x<>list('xx',list(1,2,3)))|y<>2 then pause,end + +[x,y]=M1.meth('xx',list(1,2,3)); +if or(x<>list('xx',list(1,2,3)))|y<>2 then pause,end + +[x,y]=M.meth('xx',1,2,3); +if or(x<>list('xx',1,2,3))|y<>4 then pause,end + +[x,y]=M1.meth('xx',1,2,3); +if or(x<>list('xx',1,2,3))|y<>4 then pause,end + +// extraction returns a built-in +t=N.foo(123); +if (t<>1) then pause, end +t=N.foo(['a' 'b']); +if (t<>10) then pause, end
\ No newline at end of file diff --git a/modules/data_structures/tests/nonreg_tests/bug_6988.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_6988.dia.ref new file mode 100755 index 000000000..974c15d8d --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_6988.dia.ref @@ -0,0 +1,35 @@ +// ============================================================================= +// 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 6988 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6988 +// +// <-- Short Description --> +// Error messages in modules/data_structures/src/c/hmops.c are not standard. +M = hypermat([2 3 2 2],1:24) + M = + +(:,:,1,1) + + 1. 3. 5. + 2. 4. 6. +(:,:,2,1) + + 7. 9. 11. + 8. 10. 12. +(:,:,1,2) + + 13. 15. 17. + 14. 16. 18. +(:,:,2,2) + + 19. 21. 23. + 20. 22. 24. +errmsg1=msprintf(_("%s: Wrong number of input arguments: at most %d expected.\n"),"hmops",4); +assert_checkerror("M(:,:,1,2,3)",errmsg1); diff --git a/modules/data_structures/tests/nonreg_tests/bug_6988.tst b/modules/data_structures/tests/nonreg_tests/bug_6988.tst new file mode 100755 index 000000000..5ab5daf3f --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_6988.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// 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 6988 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6988 +// +// <-- Short Description --> +// Error messages in modules/data_structures/src/c/hmops.c are not standard. + +M = hypermat([2 3 2 2],1:24) +errmsg1=msprintf(_("%s: Wrong number of input arguments: at most %d expected.\n"),"hmops",4); +assert_checkerror("M(:,:,1,2,3)",errmsg1); diff --git a/modules/data_structures/tests/nonreg_tests/bug_7181.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_7181.dia.ref new file mode 100755 index 000000000..42829599f --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_7181.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 7181 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7181 +// +// <-- Short Description --> +// The display of a struct having no fields does not work. +// Create a struct +s = struct("txt","Hello","num",%pi,"pol",%z^2+1); +// Remove all fields +s.txt = null(); +s.num = null(); +s.pol = null(); +disp(s) + +1x1 struct array with no fields. diff --git a/modules/data_structures/tests/nonreg_tests/bug_7181.tst b/modules/data_structures/tests/nonreg_tests/bug_7181.tst new file mode 100755 index 000000000..94fbee954 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_7181.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Vincent COUVERT +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 7181 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7181 +// +// <-- Short Description --> +// The display of a struct having no fields does not work. + +// Create a struct +s = struct("txt","Hello","num",%pi,"pol",%z^2+1); + +// Remove all fields +s.txt = null(); +s.num = null(); +s.pol = null(); + +disp(s)
\ No newline at end of file diff --git a/modules/data_structures/tests/nonreg_tests/bug_7525.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_7525.dia.ref new file mode 100755 index 000000000..fde047699 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_7525.dia.ref @@ -0,0 +1,16 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 7525 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7525 +// +// <-- Short Description --> +// Scilab failed to assign 2-d matrices into 3-d matrices, on Windows. +x = zeros(2, 2, 3); +if execstr("x(:, :, 1) = [1 0; 0 1];", "errcatch") <> 0 then bugmes();quit;end diff --git a/modules/data_structures/tests/nonreg_tests/bug_7525.tst b/modules/data_structures/tests/nonreg_tests/bug_7525.tst new file mode 100755 index 000000000..078871c6b --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_7525.tst @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 7525 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7525 +// +// <-- Short Description --> +// Scilab failed to assign 2-d matrices into 3-d matrices, on Windows. + +x = zeros(2, 2, 3); +if execstr("x(:, :, 1) = [1 0; 0 1];", "errcatch") <> 0 then pause, end diff --git a/modules/data_structures/tests/nonreg_tests/bug_8856.dia.ref b/modules/data_structures/tests/nonreg_tests/bug_8856.dia.ref new file mode 100755 index 000000000..514d81056 --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_8856.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 8856 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8856 +// +// <-- Short Description --> +// [k,l,m,...]=find(a==5) works if a is a matrix (not an hypermat) +a = rand(2,2); +[i,j,k]=find(a>0.5); +assert_checkequal(and(k), %t); diff --git a/modules/data_structures/tests/nonreg_tests/bug_8856.tst b/modules/data_structures/tests/nonreg_tests/bug_8856.tst new file mode 100755 index 000000000..e68be593e --- /dev/null +++ b/modules/data_structures/tests/nonreg_tests/bug_8856.tst @@ -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 8856 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=8856 +// +// <-- Short Description --> +// [k,l,m,...]=find(a==5) works if a is a matrix (not an hypermat) + +a = rand(2,2); +[i,j,k]=find(a>0.5); +assert_checkequal(and(k), %t); diff --git a/modules/data_structures/tests/unit_tests/fieldnames.dia.ref b/modules/data_structures/tests/unit_tests/fieldnames.dia.ref new file mode 100755 index 000000000..1679d9069 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/fieldnames.dia.ref @@ -0,0 +1,38 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- ENGLISH IMPOSED --> +// <-- CLI SHELL MODE --> +// unit tests for fieldnames function +// ============================================================================= +if fieldnames(1)<>[] then bugmes();quit;end +my_struct = struct("field_1",123,"field_2",456); +if or(fieldnames(my_struct)<>["field_1";"field_2"]) then bugmes();quit;end +clear T; +T.a=rand(2,2); +T.b='s'; +if or(fieldnames(T)<>["a";"b"]) then bugmes();quit;end +if or(fieldnames(1/%s)<>["num";"den";"dt"]) then bugmes();quit;end +M=mlist(['foo','A','B','C'],[],[],[]) + M = + + + M(1) + +!foo A B C ! + + M(2) + + [] + + M(3) + + [] + + M(4) + + [] +if or(fieldnames(M)<>['A';'B';'C']) then bugmes();quit;end diff --git a/modules/data_structures/tests/unit_tests/fieldnames.tst b/modules/data_structures/tests/unit_tests/fieldnames.tst new file mode 100755 index 000000000..ea1bb42d4 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/fieldnames.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - INRIA - Serge.Steer@inria.fr +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- ENGLISH IMPOSED --> +// <-- CLI SHELL MODE --> + +// unit tests for fieldnames function +// ============================================================================= + +if fieldnames(1)<>[] then pause,end + +my_struct = struct("field_1",123,"field_2",456); +if or(fieldnames(my_struct)<>["field_1";"field_2"]) then pause,end + +clear T; +T.a=rand(2,2); +T.b='s'; +if or(fieldnames(T)<>["a";"b"]) then pause,end + + +if or(fieldnames(1/%s)<>["num";"den";"dt"]) then pause,end + +M=mlist(['foo','A','B','C'],[],[],[]) +if or(fieldnames(M)<>['A';'B';'C']) then pause,end diff --git a/modules/data_structures/tests/unit_tests/hypermat.dia.ref b/modules/data_structures/tests/unit_tests/hypermat.dia.ref new file mode 100755 index 000000000..ccff88902 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/hypermat.dia.ref @@ -0,0 +1,115 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +//extraction +Data=list(1:12,(1:12)+rand(1,12)*%i,int32(1:12),(1:12)+%s,rand(1,12)>0.5,string(1:12)); +test=1; +msg='Problem with extraction for hypermatrix of type %s in test %d.%d \n'; +for k=1:size(Data) + data=Data(k);td=typeof(data); + h=hypermat([2 3 2],data); + if h(2,3,2)<>data(12) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h(2,:,2)<>data([8 10 12])) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h($,:,2)<>data([8 10 12])) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h(:,3,2)<>matrix(data([11 12]),-1,1)) then mprintf(msg,test,k); bugmes();quit;end + if or(h(1:2)<>matrix(data([1 2]),-1,1)) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h(1:3)<>matrix(data([1 2 3]),-1,1)) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h(1,2:3)<>data([3 5])) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h(1,4:5)<>data([7 9])) then mprintf(msg,td,test,k); bugmes();quit;end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); +end + test1.1 completed + test1.2 completed + test1.3 completed + test1.4 completed + test1.5 completed + test1.6 completed +//insertion of [] +test=2; +for k=1:size(Data) + data=Data(k);td=typeof(data); + h=hypermat([2 3 2],data);h1=h; + h(2,:,:)=[]; + if or(size(h)<>[1 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h<>h1(1,:,:)) then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data);h1=h; + h(:,1:2,:)=[]; + if or(size(h)<>[2 1 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h<>h1(:,3,:)) then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h(:,:,:)=[]; + if h<>[] then mprintf(msg,td,test,k); bugmes();quit;end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); +end + test2.1 completed + test2.2 completed + test2.3 completed + test2.4 completed + test2.5 completed + test2.6 completed +msg='Problem with insertion for hypermatrix of type %s in test %d.%d \n'; +//insertion of a single element +test=3; +for k=1:size(Data) + data=Data(k);td=typeof(data); + I=data(1); + h=hypermat([2 3 2],data); + h(2,3,2)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(2,3,2)<>I then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h(2,3)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(2,3,1)<>I then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h(2)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(2,1,1)<>I then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h(3)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(1,2,1)<>I then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h(3)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(1,2,1)<>I then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h([3,7])=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(1,2,1)<>I|h(1,1,2)<>I then mprintf(msg,td,test,k); bugmes();quit;end + h=hypermat([2 3 2],data); + h(13:15)=I; + if type(h)<>type(data) then mprintf(msg,td,test,k); bugmes();quit;end + if or(size(h)<>[15,1]) then mprintf(msg,td,test,k); bugmes();quit;end + if or(h(13:15)<>I) then mprintf(msg,td,test,k); bugmes();quit;end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); +end + test3.1 completed + test3.2 completed + test3.3 completed + test3.4 completed + test3.5 completed + test3.6 completed +//extension of a 2D matrix to a 3D one +test=4; +for k=1:size(Data) + data=matrix(Data(k),3,-1);td=typeof(data); + I=data(1,1); + h=data; + h(3,4,2)=I; + if or(size(h)<>[3 4 2]) then mprintf(msg,td,test,k); bugmes();quit;end + if h(:,:,1)<>data then mprintf(msg,td,test,k); bugmes();quit;end + d=[];d(3,4)=I; + if h(:,:,2)<>d then mprintf(msg,td,test,k); bugmes();quit;end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); +end + test4.1 completed + test4.2 completed + test4.3 completed + test4.4 completed + test4.5 completed + test4.6 completed diff --git a/modules/data_structures/tests/unit_tests/hypermat.tst b/modules/data_structures/tests/unit_tests/hypermat.tst new file mode 100755 index 000000000..ecda38b23 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/hypermat.tst @@ -0,0 +1,109 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +//extraction +Data=list(1:12,(1:12)+rand(1,12)*%i,int32(1:12),(1:12)+%s,rand(1,12)>0.5,string(1:12)); + +test=1; +msg='Problem with extraction for hypermatrix of type %s in test %d.%d \n'; +for k=1:size(Data) + data=Data(k);td=typeof(data); + h=hypermat([2 3 2],data); + if h(2,3,2)<>data(12) then mprintf(msg,td,test,k); pause,end + if or(h(2,:,2)<>data([8 10 12])) then mprintf(msg,td,test,k); pause,end + if or(h($,:,2)<>data([8 10 12])) then mprintf(msg,td,test,k); pause,end + if or(h(:,3,2)<>matrix(data([11 12]),-1,1)) then mprintf(msg,test,k); pause,end + if or(h(1:2)<>matrix(data([1 2]),-1,1)) then mprintf(msg,td,test,k); pause,end + if or(h(1:3)<>matrix(data([1 2 3]),-1,1)) then mprintf(msg,td,test,k); pause,end + if or(h(1,2:3)<>data([3 5])) then mprintf(msg,td,test,k); pause,end + if or(h(1,4:5)<>data([7 9])) then mprintf(msg,td,test,k); pause,end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); +end +//insertion of [] +test=2; +for k=1:size(Data) + data=Data(k);td=typeof(data); + h=hypermat([2 3 2],data);h1=h; + h(2,:,:)=[]; + if or(size(h)<>[1 3 2]) then mprintf(msg,td,test,k); pause,end + if or(h<>h1(1,:,:)) then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data);h1=h; + h(:,1:2,:)=[]; + if or(size(h)<>[2 1 2]) then mprintf(msg,td,test,k); pause,end + if or(h<>h1(:,3,:)) then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h(:,:,:)=[]; + if h<>[] then mprintf(msg,td,test,k); pause,end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); + +end + + +msg='Problem with insertion for hypermatrix of type %s in test %d.%d \n'; +//insertion of a single element +test=3; +for k=1:size(Data) + data=Data(k);td=typeof(data); + I=data(1); + h=hypermat([2 3 2],data); + h(2,3,2)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); pause,end + if h(2,3,2)<>I then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h(2,3)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); pause,end + if h(2,3,1)<>I then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h(2)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); pause,end + if h(2,1,1)<>I then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h(3)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); pause,end + if h(1,2,1)<>I then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h(3)=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); pause,end + if h(1,2,1)<>I then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h([3,7])=I; + if or(size(h)<>[2 3 2]) then mprintf(msg,td,test,k); pause,end + if h(1,2,1)<>I|h(1,1,2)<>I then mprintf(msg,td,test,k); pause,end + + h=hypermat([2 3 2],data); + h(13:15)=I; + if type(h)<>type(data) then mprintf(msg,td,test,k); pause,end + if or(size(h)<>[15,1]) then mprintf(msg,td,test,k); pause,end + if or(h(13:15)<>I) then mprintf(msg,td,test,k); pause,end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); + +end + +//extension of a 2D matrix to a 3D one +test=4; +for k=1:size(Data) + data=matrix(Data(k),3,-1);td=typeof(data); + I=data(1,1); + h=data; + h(3,4,2)=I; + if or(size(h)<>[3 4 2]) then mprintf(msg,td,test,k); pause,end + if h(:,:,1)<>data then mprintf(msg,td,test,k); pause,end + d=[];d(3,4)=I; + if h(:,:,2)<>d then mprintf(msg,td,test,k); pause,end + msgToPrint=msprintf(' test%d.%d completed\n',test,k);write(%io(2),msgToPrint); +end + + + diff --git a/modules/data_structures/tests/unit_tests/isfield.dia.ref b/modules/data_structures/tests/unit_tests/isfield.dia.ref new file mode 100755 index 000000000..a14a4146d --- /dev/null +++ b/modules/data_structures/tests/unit_tests/isfield.dia.ref @@ -0,0 +1,48 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org> +// Copyright (C) 2011 - DIGITEO - Vincent COUVERT <vincent.couvert@scilab.org> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// unit tests for isfield function +// ============================================================================= +my_struct = struct("field_1",123,"field_2",456); +// syntax +ierr = execstr("isfield()","errcatch"); +if ierr == 0 then bugmes();quit;end +if lasterror() <> msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"isfield",2) then bugmes();quit;end +ierr = execstr("isfield(my_struct)","errcatch"); +if ierr == 0 then bugmes();quit;end +if lasterror() <> msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"isfield",2) then bugmes();quit;end +ierr = execstr("isfield(my_struct,''field_1'',''field_2'')","errcatch"); +if ierr == 0 then bugmes();quit;end +ierr = execstr("isfield(my_struct,2)","errcatch"); +if ierr == 0 then bugmes();quit;end +if lasterror() <> msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"isfield",2) then bugmes();quit;end +my_struct = ["field_1","field_2"]; +ierr = execstr("isfield(my_struct,''field_1'')","errcatch"); +if ierr == 0 then bugmes();quit;end +if lasterror() <> msprintf(gettext("%s: Wrong type for input argument #%d: struct array or tlist or mlist expected.\n"),"isfield",1) then bugmes();quit;end +// Fonctionnality +my_struct = struct("field_1",123,"field_2",456,"field_4",789); +if ~ isfield(my_struct,"field_1") then bugmes();quit;end +if ~ isfield(my_struct,"field_2") then bugmes();quit;end +if isfield(my_struct,"field_3") then bugmes();quit;end +if ~ isfield(my_struct,"field_4") then bugmes();quit;end +fields = [ "field_1" "field_2" ; "field_3" "field_4" ; "field_3" "field_4" ]; +ref = [ %T %T ; %F %T ; %F %T ]; +if or( isfield( my_struct , fields ) <> ref ) then bugmes();quit;end +fields = [ "field_1" "field_2" "field_3" "field_4" "field_3" "field_4" ]; +ref = [ %T %T %F %T %F %T ]; +if or( isfield( my_struct , fields ) <> ref ) then bugmes();quit;end +fields = [ "field_1" ; "field_2" ; "field_3" ; "field_4" ; "field_3" ; "field_4" ]; +ref = [ %T ; %T ; %F ; %T ; %F ; %T ]; +if or( isfield( my_struct , fields ) <> ref ) then bugmes();quit;end +fields = [ "field_1" "field_2" "field_3" ; "field_4" "field_3" "field_4" ]; +ref = [ %T %T %F ; %T %F %T ]; +if or( isfield( my_struct , fields ) <> ref ) then bugmes();quit;end +s = tlist(["test" "t" "n","","p"], "Hello", %pi, "anonymous", (1-%z)^3); +a=isfield(s, ["b" "t" ""]); +assert_checkequal(a, [%f %t %t]); diff --git a/modules/data_structures/tests/unit_tests/isfield.tst b/modules/data_structures/tests/unit_tests/isfield.tst new file mode 100755 index 000000000..1d1a5c2d7 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/isfield.tst @@ -0,0 +1,71 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org> +// Copyright (C) 2011 - DIGITEO - Vincent COUVERT <vincent.couvert@scilab.org> +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// unit tests for isfield function +// ============================================================================= + +my_struct = struct("field_1",123,"field_2",456); + +// syntax + +ierr = execstr("isfield()","errcatch"); +if ierr == 0 then pause,end +if lasterror() <> msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"isfield",2) then pause, end + +ierr = execstr("isfield(my_struct)","errcatch"); +if ierr == 0 then pause,end +if lasterror() <> msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"isfield",2) then pause, end + +ierr = execstr("isfield(my_struct,''field_1'',''field_2'')","errcatch"); +if ierr == 0 then pause,end + +ierr = execstr("isfield(my_struct,2)","errcatch"); +if ierr == 0 then pause,end +if lasterror() <> msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"),"isfield",2) then pause, end + +my_struct = ["field_1","field_2"]; + +ierr = execstr("isfield(my_struct,''field_1'')","errcatch"); +if ierr == 0 then pause,end +if lasterror() <> msprintf(gettext("%s: Wrong type for input argument #%d: struct array or tlist or mlist expected.\n"),"isfield",1) then pause, end + +// Fonctionnality + +my_struct = struct("field_1",123,"field_2",456,"field_4",789); + +if ~ isfield(my_struct,"field_1") then pause, end +if ~ isfield(my_struct,"field_2") then pause, end +if isfield(my_struct,"field_3") then pause, end +if ~ isfield(my_struct,"field_4") then pause, end + +fields = [ "field_1" "field_2" ; "field_3" "field_4" ; "field_3" "field_4" ]; +ref = [ %T %T ; %F %T ; %F %T ]; +if or( isfield( my_struct , fields ) <> ref ) then pause, end + + +fields = [ "field_1" "field_2" "field_3" "field_4" "field_3" "field_4" ]; +ref = [ %T %T %F %T %F %T ]; +if or( isfield( my_struct , fields ) <> ref ) then pause, end + + +fields = [ "field_1" ; "field_2" ; "field_3" ; "field_4" ; "field_3" ; "field_4" ]; +ref = [ %T ; %T ; %F ; %T ; %F ; %T ]; +if or( isfield( my_struct , fields ) <> ref ) then pause, end + + +fields = [ "field_1" "field_2" "field_3" ; "field_4" "field_3" "field_4" ]; +ref = [ %T %T %F ; %T %F %T ]; +if or( isfield( my_struct , fields ) <> ref ) then pause, end + + +s = tlist(["test" "t" "n","","p"], "Hello", %pi, "anonymous", (1-%z)^3); +a=isfield(s, ["b" "t" ""]); +assert_checkequal(a, [%f %t %t]); + diff --git a/modules/data_structures/tests/unit_tests/list.dia.ref b/modules/data_structures/tests/unit_tests/list.dia.ref new file mode 100755 index 000000000..0375d599c --- /dev/null +++ b/modules/data_structures/tests/unit_tests/list.dia.ref @@ -0,0 +1,61 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014-2014 - Scilab Enterprises - Bruno JOFRET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// test de creation des listes avec des elements null() +l = list(,); +m = l(1); +n = l(2); +assert_checkfalse(isdef("m")); +assert_checkfalse(isdef("n")); +l = list(1,); +n = l(2); +assert_checkfalse(isdef("n")); +assert_checkequal(l(1), 1); +l = list(,1); +m = l(1); +assert_checkfalse(isdef("m")); +assert_checkequal(l(2), 1); +l = list(,,); +m = l(1); +n = l(2); +p = l(3); +assert_checkfalse(isdef("m")); +assert_checkfalse(isdef("n")); +assert_checkfalse(isdef("p")); +l = list(1,,); +n = l(2); +p = l(3); +assert_checkequal(l(1), 1); +assert_checkfalse(isdef("n")); +assert_checkfalse(isdef("p")); +l = list(,1,); +m = l(1); +p = l(3); +assert_checkfalse(isdef("m")); +assert_checkequal(l(2), 1); +assert_checkfalse(isdef("p")); +l = list(,,1); +m = l(1); +n = l(2); +assert_checkfalse(isdef("m")); +assert_checkfalse(isdef("n")); +assert_checkequal(l(3), 1); +l = list(1,1,); +p = l(3); +assert_checkequal(l(1), 1); +assert_checkequal(l(2), 1); +assert_checkfalse(isdef("p")); +l = list(1,,1); +n = l(2); +assert_checkequal(l(1), 1); +assert_checkfalse(isdef("n")); +assert_checkequal(l(3), 1); +l = list(,1,1); +m = l(1); +assert_checkfalse(isdef("m")); +assert_checkequal(l(2), 1); +assert_checkequal(l(3), 1); diff --git a/modules/data_structures/tests/unit_tests/list.tst b/modules/data_structures/tests/unit_tests/list.tst new file mode 100755 index 000000000..3971a428d --- /dev/null +++ b/modules/data_structures/tests/unit_tests/list.tst @@ -0,0 +1,72 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2014-2014 - Scilab Enterprises - Bruno JOFRET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +// test de creation des listes avec des elements null() + +l = list(,); +m = l(1); +n = l(2); +assert_checkfalse(isdef("m")); +assert_checkfalse(isdef("n")); + +l = list(1,); +n = l(2); +assert_checkfalse(isdef("n")); +assert_checkequal(l(1), 1); + +l = list(,1); +m = l(1); +assert_checkfalse(isdef("m")); +assert_checkequal(l(2), 1); + +l = list(,,); +m = l(1); +n = l(2); +p = l(3); +assert_checkfalse(isdef("m")); +assert_checkfalse(isdef("n")); +assert_checkfalse(isdef("p")); + +l = list(1,,); +n = l(2); +p = l(3); +assert_checkequal(l(1), 1); +assert_checkfalse(isdef("n")); +assert_checkfalse(isdef("p")); + +l = list(,1,); +m = l(1); +p = l(3); +assert_checkfalse(isdef("m")); +assert_checkequal(l(2), 1); +assert_checkfalse(isdef("p")); + +l = list(,,1); +m = l(1); +n = l(2); +assert_checkfalse(isdef("m")); +assert_checkfalse(isdef("n")); +assert_checkequal(l(3), 1); + +l = list(1,1,); +p = l(3); +assert_checkequal(l(1), 1); +assert_checkequal(l(2), 1); +assert_checkfalse(isdef("p")); + +l = list(1,,1); +n = l(2); +assert_checkequal(l(1), 1); +assert_checkfalse(isdef("n")); +assert_checkequal(l(3), 1); + +l = list(,1,1); +m = l(1); +assert_checkfalse(isdef("m")); +assert_checkequal(l(2), 1); +assert_checkequal(l(3), 1);
\ No newline at end of file diff --git a/modules/data_structures/tests/unit_tests/listextraction.dia.ref b/modules/data_structures/tests/unit_tests/listextraction.dia.ref new file mode 100755 index 000000000..4dcc9bf84 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/listextraction.dia.ref @@ -0,0 +1,78 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// test des insertions dans les listes +a=1,b=3;c=2;d=[1 2 3];e=[3 4 5];f=[10;20];g=[44 55]; + a = + + 1. +h=5;i=4;a0=10;c0=20;b0=30;g0=[44 55 66; 10 20 30]; +l=list(a);if l(1)<>a then bugmes();quit;end +l=list(a);if l(1)(1)<>a(1) then bugmes();quit;end +l=list(a);if l(1)(1,1)<>a(1,1) then bugmes();quit;end +l=list(a,d,b);if l(2)<>d then bugmes();quit;end +l=list(a,d,b);if l(2)(1:2)<>d(1:2) then bugmes();quit;end +l=list(a,d,b);if l(2)(1,2)<>d(1,2) then bugmes();quit;end +// +l=list(a,list(b,c,d));if l(2)(3)<>d then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(3)<>d(3) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)([3 1])<>d([3 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(1,[3 1])<>d(1,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(:,[3 1])<>d(:,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)($,[$ 1])<>d($,[$ 1]) then bugmes();quit;end +// +l=list(a,list(b,c,d),h);if l(2)(3)<>d then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(3)<>d(3) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)([3 1])<>d([3 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(1,[3 1])<>d(1,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[3 1])<>d(:,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)($,[$ 1])<>d($,[$ 1]) then bugmes();quit;end +// +l=list(a,1/%s);if l(2)<>1/%s then bugmes();quit;end +l=list(a,1/%s);if l(2)('num')<>1 then bugmes();quit;end +l=list(a,1/%s,g);if l(2)('den')(1,1)<>%s then bugmes();quit;end +l=list(a,1/%s,g);if l(2)<>1/%s then bugmes();quit;end +l=list(a,1/%s,g);if l(2)('num')<>1 then bugmes();quit;end +l=list(a,1/%s,g);if l(2)('den')(1,1)<>%s then bugmes();quit;end +a=1:10,b=3:2:33;c=(-10:0)';d=[1 2+%s 3];e=['1';'2';'3';'4']; + a = + + 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. +f=[%t %t %f];g=['12345','abcdefghijk']; +h=rand(3,3);i=eye(10,10);a0=10+%s;c0=20;b0=sparse(eye(30,30)); +l=list(a);if l(1)<>a then bugmes();quit;end +l=list(a);if l(1)(1)<>a(1) then bugmes();quit;end +l=list(a);if l(1)(1,1)<>a(1,1) then bugmes();quit;end +l=list(a,d,b);if l(2)<>d then bugmes();quit;end +l=list(a,d,b);if l(2)(1:2)<>d(1:2) then bugmes();quit;end +l=list(a,d,b);if l(2)(1,2)<>d(1,2) then bugmes();quit;end +// +l=list(a,list(b,c,d));if l(2)(3)<>d then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(3)<>d(3) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)([3 1])<>d([3 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(1,[3 1])<>d(1,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(:,[3 1])<>d(:,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then bugmes();quit;end +l=list(a,list(b,c,d));if l(2)(3)($,[$ 1])<>d($,[$ 1]) then bugmes();quit;end +// +l=list(a,list(b,c,d),h);if l(2)(3)<>d then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(3)<>d(3) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)([3 1])<>d([3 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(1,[3 1])<>d(1,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[3 1])<>d(:,[3 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then bugmes();quit;end +l=list(a,list(b,c,d),h);if l(2)(3)($,[$ 1])<>d($,[$ 1]) then bugmes();quit;end +// +N=[1 2 3]; +l=list(a,N/%s);if l(2)<>N/%s then bugmes();quit;end +l=list(a,N/%s);if l(2)('num')<>N then bugmes();quit;end +l=list(a,N/%s,g);if l(2)('den')(1,1)<>%s then bugmes();quit;end +l=list(a,N/%s,g);if l(2)<>N/%s then bugmes();quit;end +l=list(a,N/%s,g);if l(2)('num')<>N then bugmes();quit;end +l=list(a,N/%s,g);if l(2)('den')(1,1)<>%s then bugmes();quit;end diff --git a/modules/data_structures/tests/unit_tests/listextraction.tst b/modules/data_structures/tests/unit_tests/listextraction.tst new file mode 100755 index 000000000..0f5c30853 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/listextraction.tst @@ -0,0 +1,79 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +// test des insertions dans les listes +a=1,b=3;c=2;d=[1 2 3];e=[3 4 5];f=[10;20];g=[44 55]; +h=5;i=4;a0=10;c0=20;b0=30;g0=[44 55 66; 10 20 30]; + + +l=list(a);if l(1)<>a then pause,end +l=list(a);if l(1)(1)<>a(1) then pause,end +l=list(a);if l(1)(1,1)<>a(1,1) then pause,end +l=list(a,d,b);if l(2)<>d then pause,end +l=list(a,d,b);if l(2)(1:2)<>d(1:2) then pause,end +l=list(a,d,b);if l(2)(1,2)<>d(1,2) then pause,end +// +l=list(a,list(b,c,d));if l(2)(3)<>d then pause,end +l=list(a,list(b,c,d));if l(2)(3)(3)<>d(3) then pause,end +l=list(a,list(b,c,d));if l(2)(3)([3 1])<>d([3 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)(1,[3 1])<>d(1,[3 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)(:,[3 1])<>d(:,[3 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)($,[$ 1])<>d($,[$ 1]) then pause,end +// +l=list(a,list(b,c,d),h);if l(2)(3)<>d then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(3)<>d(3) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)([3 1])<>d([3 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(1,[3 1])<>d(1,[3 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[3 1])<>d(:,[3 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)($,[$ 1])<>d($,[$ 1]) then pause,end +// +l=list(a,1/%s);if l(2)<>1/%s then pause,end +l=list(a,1/%s);if l(2)('num')<>1 then pause,end +l=list(a,1/%s,g);if l(2)('den')(1,1)<>%s then pause,end +l=list(a,1/%s,g);if l(2)<>1/%s then pause,end +l=list(a,1/%s,g);if l(2)('num')<>1 then pause,end +l=list(a,1/%s,g);if l(2)('den')(1,1)<>%s then pause,end + + +a=1:10,b=3:2:33;c=(-10:0)';d=[1 2+%s 3];e=['1';'2';'3';'4']; +f=[%t %t %f];g=['12345','abcdefghijk']; +h=rand(3,3);i=eye(10,10);a0=10+%s;c0=20;b0=sparse(eye(30,30)); + +l=list(a);if l(1)<>a then pause,end +l=list(a);if l(1)(1)<>a(1) then pause,end +l=list(a);if l(1)(1,1)<>a(1,1) then pause,end +l=list(a,d,b);if l(2)<>d then pause,end +l=list(a,d,b);if l(2)(1:2)<>d(1:2) then pause,end +l=list(a,d,b);if l(2)(1,2)<>d(1,2) then pause,end +// +l=list(a,list(b,c,d));if l(2)(3)<>d then pause,end +l=list(a,list(b,c,d));if l(2)(3)(3)<>d(3) then pause,end +l=list(a,list(b,c,d));if l(2)(3)([3 1])<>d([3 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)(1,[3 1])<>d(1,[3 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)(:,[3 1])<>d(:,[3 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then pause,end +l=list(a,list(b,c,d));if l(2)(3)($,[$ 1])<>d($,[$ 1]) then pause,end +// +l=list(a,list(b,c,d),h);if l(2)(3)<>d then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(3)<>d(3) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)([3 1])<>d([3 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(1,[3 1])<>d(1,[3 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[3 1])<>d(:,[3 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)(:,[$ 1])<>d(:,[$ 1]) then pause,end +l=list(a,list(b,c,d),h);if l(2)(3)($,[$ 1])<>d($,[$ 1]) then pause,end +// +N=[1 2 3]; +l=list(a,N/%s);if l(2)<>N/%s then pause,end +l=list(a,N/%s);if l(2)('num')<>N then pause,end +l=list(a,N/%s,g);if l(2)('den')(1,1)<>%s then pause,end +l=list(a,N/%s,g);if l(2)<>N/%s then pause,end +l=list(a,N/%s,g);if l(2)('num')<>N then pause,end +l=list(a,N/%s,g);if l(2)('den')(1,1)<>%s then pause,end + diff --git a/modules/data_structures/tests/unit_tests/listinsertion.dia.ref b/modules/data_structures/tests/unit_tests/listinsertion.dia.ref new file mode 100755 index 000000000..5900291fc --- /dev/null +++ b/modules/data_structures/tests/unit_tests/listinsertion.dia.ref @@ -0,0 +1,349 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// test des insertions dans les listes +a=1;b=3;c=2;d=[1 2 3];e=[3 4 5];f=[10;20];g=[44 55]; +h=5;i=4;a0=10;c0=20;b0=30;g0=[44 55 66; 10 20 30]; +l=list();l(0)=a;if l<>list(a) then bugmes();quit;end +l=list();l(1)=a;if l<>list(a) then bugmes();quit;end +l=list(a);l(2)=b;if l<>list(a,b) then bugmes();quit;end +l=list(a);l(0)=b;if l<>list(b,a) then bugmes();quit;end +l=list(a);l(1)=c;if l<>list(c) then bugmes();quit;end +l=list(a);l(1)=d;if l<>list(d) then bugmes();quit;end +l=list(d);l(1)=a;if l<>list(a) then bugmes();quit;end +l=list(a);l(1)=null();if l<>list() then bugmes();quit;end +l=list(a,c);l(1)=null();if l<>list(c) then bugmes();quit;end +l=list(a,c);l(2)=null();if l<>list(a) then bugmes();quit;end +l=list(a,c,b);l(2)=null();if l<>list(a,b) then bugmes();quit;end +l=list(a,c,b);l(2)=e;if l<>list(a,e,b) then bugmes();quit;end +l=list(a,e,b);l(2)=a;if l<>list(a,c,b) then bugmes();quit;end +l=list();l(0)=null();if l<>list() then bugmes();quit;end +l=list();l(1)=null();if l<>list() then bugmes();quit;end +// +l=list(a);l(0)=list(c,b);if l<>list(list(c,b),a) then bugmes();quit;end +l=list(a);l(2)=list(c,b);if l<>list(a,list(c,b)) then bugmes();quit;end +l=list(a,list(c,b));l(3)=i;if l<>list(a,list(c,b),i) then bugmes();quit;end +l=list(a,list(c,b),i);l(1)=null();if l<>list(list(c,b),i) then bugmes();quit;end +l=list(a,list(c,b),i);l(2)=null();if l<>list(a,i) then bugmes();quit;end +l=list(a,list(c,b),i);l(3)=null();if l<>list(a,list(c,b)) then bugmes();quit;end +// +l=list(a,list(c,b,i),h);l(2)(2)=a0;if l<>list(a,list(c,a0,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(2)=f;if l<>list(a,list(c,f,i),h) then bugmes();quit;end +l=list(a,list(c,f,i),h);l(2)(2)=b;if l<>list(a,list(c,b,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(3)=a0;if l<>list(a,list(c,b,a0),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(3)=f;if l<>list(a,list(c,b,f),h) then bugmes();quit;end +l=list(a,list(c,b,f),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(0)=a;if l<>list(a,list(a,c,b),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(2)=null();if l<>list(a,list(c,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(1)=null();if l<>list(a,list(b,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(3)=null();if l<>list(a,list(c,b),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(3)=g;if l<>list(a,list(c,b,g),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(0)=e;if l<>list(a,list(e,c,b),h) then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=0;if l<>list(a,list(c,list(0,c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=null();if l<>list(a,list(c,list(c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=g;if l<>list(a,list(c,list(g,c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(0)=g;if l<>list(a,list(c,list(g,a0,c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=g;if l<>list(a,list(c,list(a0,c0,g),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=null();if l<>list(a,list(c,list(a0,c0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(4)=g;if l<>list(a,list(c,list(a0,c0,b0,g),b),h); then +bugmes();quit;end +l=list();l(5)=33; +ll=l; +l=list(a,1/%s);l(2)('num')=33;if l<>list(a,33/%s) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')=%s+1;if l<>list(a,((%s+1)/%s)) then bugmes();quit;end +l=list(a,1/%s);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1)) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1)=33;if l<>list(a,33/%s) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1)=%s+1;if l<>list(a,((%s+1)/%s)) then bugmes();quit;end +l=list(a,1/%s);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1,1)=33;if l<>list(a,33/%s) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1,1)=%s+1;if l<>list(a,((%s+1)/%s)) then bugmes();quit;end +l=list(a,1/%s);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')=33;if l<>list(a,33/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')=%s+1;if l<>list(a,(%s+1)/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1),g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1)=33;if l<>list(a,33/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1)=%s+1;if l<>list(a,(%s+1)/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1,1)=33;if l<>list(a,33/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1,1)=%s+1;if l<>list(a,(%s+1)/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1,2)=33;l(2)('den')(1,2)=%s+1; +if l<>list(a,[1 33]./[%s %s+1],g) then bugmes();quit;end +//a=1;b=3;c=2;d=[1 2 3];e=[3 4 5];f=[10;20];g=[44 55]; +//h=5;i=4;a0=10;c0=20;b0=30;g0=[44 55 66; 10 20 30]; +l=list(a);l(1)(1)=3;x=a;x(1)=3;if l<>list(x) then bugmes();quit;end +l=list(e);l(1)(2)=[];x=e;x(2)=[];if l<>list(x) then bugmes();quit;end +l=list(a);l(1)(1,1)=3;x=a;x(1,1)=3;if l<>list(x) then bugmes();quit;end +l=list(e);l(1)(1,2)=[];x=e;x(1,2)=[];if l<>list(x) then bugmes();quit;end +l=list(a);l(1)(5,5)=3;x=a;x(5,5)=3;if l<>list(x) then bugmes();quit;end +l=list(g0);l(1)(2,3)=3;x=g0;x(2,3)=3;if l<>list(x) then bugmes();quit;end +l=list(b,a);l(2)(1)=3;x=a;x(1)=3;if l<>list(b,x) then bugmes();quit;end +l=list(b,e);l(2)(2)=[];x=e;x(2)=[];if l<>list(b,x) then bugmes();quit;end +l=list(b,a);l(2)(1,1)=3;x=a;x(1,1)=3;if l<>list(b,x) then bugmes();quit;end +l=list(b,e);l(2)(1,2)=[];x=e;x(1,2)=[];if l<>list(b,x) then bugmes();quit;end +l=list(b,a);l(2)(5,5)=3;x=a;x(5,5)=3;if l<>list(b,x) then bugmes();quit;end +l=list(b,g0);l(2)(2,3)=3;x=g0;x(2,3)=3;if l<>list(b,x) then bugmes();quit;end +l=list(b,g0);l(2)(2,2:3)=[1 3];x=g0;x(2,2:3)=[1 3];if l<>list(b,x) then bugmes();quit;end +a=1:10;b=3:2:33;c=(-10:0)';d=[1 2+%s 3];e=['1';'2';'3';'4']; +f=[%t %t %f];g=['12345','abcdefghijk']; +h=rand(3,3);i=eye(10,10);a0=10+%s;c0=20;b0=sparse(eye(30,30)); +l=list();l(0)=a;if l<>list(a) then bugmes();quit;end +l=list();l(1)=a;if l<>list(a) then bugmes();quit;end +l=list(a);l(2)=b;if l<>list(a,b) then bugmes();quit;end +l=list(a);l(0)=b;if l<>list(b,a) then bugmes();quit;end +l=list(a);l(1)=c;if l<>list(c) then bugmes();quit;end +l=list(a);l(1)=d;if l<>list(d) then bugmes();quit;end +l=list(d);l(1)=a;if l<>list(a) then bugmes();quit;end +l=list(a);l(1)=null();if l<>list() then bugmes();quit;end +l=list(a,c);l(1)=null();if l<>list(c) then bugmes();quit;end +l=list(a,c);l(2)=null();if l<>list(a) then bugmes();quit;end +l=list(a,c,b);l(2)=null();if l<>list(a,b) then bugmes();quit;end +l=list(a,c,b);l(2)=e;if l<>list(a,e,b) then bugmes();quit;end +l=list(a,e,b);l(2)=a;if l<>list(a,c,b) then bugmes();quit;end +l=list();l(0)=null();if l<>list() then bugmes();quit;end +l=list();l(1)=null();if l<>list() then bugmes();quit;end +// +l=list(a);l(0)=list(c,b);if l<>list(list(c,b),a) then bugmes();quit;end +l=list(a);l(2)=list(c,b);if l<>list(a,list(c,b)) then bugmes();quit;end +l=list(a,list(c,b));l(3)=i;if l<>list(a,list(c,b),i) then bugmes();quit;end +l=list(a,list(c,b),i);l(1)=null();if l<>list(list(c,b),i) then bugmes();quit;end +l=list(a,list(c,b),i);l(2)=null();if l<>list(a,i) then bugmes();quit;end +l=list(a,list(c,b),i);l(3)=null();if l<>list(a,list(c,b)) then bugmes();quit;end +// +l=list(a,list(c,b,i),h);l(2)(2)=a0;if l<>list(a,list(c,a0,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(2)=f;if l<>list(a,list(c,f,i),h) then bugmes();quit;end +l=list(a,list(c,f,i),h);l(2)(2)=b;if l<>list(a,list(c,b,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(3)=a0;if l<>list(a,list(c,b,a0),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(3)=f;if l<>list(a,list(c,b,f),h) then bugmes();quit;end +l=list(a,list(c,b,f),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(0)=a;if l<>list(a,list(a,c,b),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(2)=null();if l<>list(a,list(c,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(1)=null();if l<>list(a,list(b,i),h) then bugmes();quit;end +l=list(a,list(c,b,i),h);l(2)(3)=null();if l<>list(a,list(c,b),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(3)=g;if l<>list(a,list(c,b,g),h) then bugmes();quit;end +l=list(a,list(c,b),h);l(2)(0)=e;if l<>list(a,list(e,c,b),h) then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=0;if l<>list(a,list(c,list(0,c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=null();if l<>list(a,list(c,list(c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=g;if l<>list(a,list(c,list(g,c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(0)=g;if l<>list(a,list(c,list(g,a0,c0,b0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=g;if l<>list(a,list(c,list(a0,c0,g),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=null();if l<>list(a,list(c,list(a0,c0),b),h); then bugmes();quit;end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(4)=g;if l<>list(a,list(c,list(a0,c0,b0,g),b),h); then bugmes();quit;end +l=list(a,1/%s);l(2)('num')=33;if l<>list(a,33/%s) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')=%s+1;if l<>list(a,((%s+1)/%s)) then bugmes();quit;end +l=list(a,1/%s);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1)) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1)=33;if l<>list(a,33/%s) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1)=%s+1;if l<>list(a,((%s+1)/%s)) then bugmes();quit;end +l=list(a,1/%s);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1,1)=33;if l<>list(a,33/%s) then bugmes();quit;end +l=list(a,1/%s);l(2)('num')(1,1)=%s+1;if l<>list(a,((%s+1)/%s)) then bugmes();quit;end +l=list(a,1/%s);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')=33;if l<>list(a,33/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')=%s+1;if l<>list(a,(%s+1)/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1),g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1)=33;if l<>list(a,33/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1)=%s+1;if l<>list(a,(%s+1)/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1,1)=33;if l<>list(a,33/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1,1)=%s+1;if l<>list(a,(%s+1)/%s,g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then bugmes();quit;end +l=list(a,1/%s,g);l(2)('num')(1,2)=33;l(2)('den')(1,2)=%s+1; +if l<>list(a,[1 33]./[%s %s+1],g) then bugmes();quit;end +//test with field names not defined in the structure here row1 and row2 +function M=%to_e(varargin) + M = varargin($), + select varargin(1) + case 'row2' then + M.N = M.N(2, eye()) + M.V = M.V(2, eye()) + case 'row1' then + M.N = M.N(1, eye()) + M.V = M.V(1, eye()) + else + M.N = M.N(varargin(1:$ - 1)) + M.V = M.V(varargin(1:$ - 1)) + end +endfunction +%to_6=%to_e; +function M=%to_i_to(varargin) + M=varargin($);N=varargin($-1) + select varargin(1) + case 'row2' + M.N(2,:)=N.N + M.V(2,:)=N.V + case 'row1' + M.N(1,:)=N.N + M.V(1,:)=N.V + else + M.N(varargin(1:$-2))=N.N + M.V(varargin(1:$-2))=N.V + end +endfunction +M=mlist(['to','V','N'],[1 2 3;4 5 6],['a','b','c';'d','e','f']); +M.row1(2)=M.row2(1); +assert_checkequal(M.V, [1 4 3;4 5 6]); +assert_checkequal(M.N, ['a','d','c';'d','e','f']); +l=list(1,M,2); +l(2).row1(2)=M.row1(1); +assert_checkequal(l(1), 1); +assert_checkequal(l(2).V, [1 1 3;4 5 6]); +assert_checkequal(l(2).N, ['a','a','c';'d','e','f']); +assert_checkequal(M.V, [1 4 3;4 5 6]); +assert_checkequal(M.N, ['a','d','c';'d','e','f']); +l(1)="foo"; +assert_checkequal(l(1), "foo"); +//test of insertion in structs (a particular mlist) +clear S; +S.a=11; +S(2).a=12; +assert_checkequal(S.a, list(11,12)); +clear S; +S.a=11; +S.a(2,2)=12; +assert_checkequal(S.a, diag([11,12])); +clear S; +S.a=11; +S(2).b=12; +assert_checkequal(S.a, list(11,[])); +assert_checkequal(S.b, list([],12)); +clear S S1 S2; +S.a=11; +S(2).b=12; +S1.a=33; +S1.b='toto'; +S(1)=S1; +assert_checkequal(S.a, list(33,[])); +assert_checkequal(S.b, list("toto",12)); +S(2,2)=S1; +assert_checkequal(S.a, list(33,[],[],33)); +assert_checkequal(S.b, list("toto",12,[],"toto")); +S2.a=-5; +S2.c=8; +S(2,2,2)=S2; +assert_checkequal(S.a, list(33,[],[],33,[],[],[],-5)); +assert_checkequal(S.b, list("toto",12,[],"toto",[],[],[],[])); +assert_checkequal(S.c, list([],[],[],[],[],[],[],8)); +S1=S(:,1,1); +assert_checkequal(S1.a, list(33,[])); +assert_checkequal(S1.b, list("toto",12)); +assert_checkequal(S1.c, list([],[])); +S1=S(1:2,1,1); +assert_checkequal(S1.a, list(33,[])); +assert_checkequal(S1.b, list("toto",12)); +assert_checkequal(S1.c, list([],[])); +S1=S([1 1],1,1); +assert_checkequal(S1.a, list(33,33)); +assert_checkequal(S1.b, list("toto","toto")); +assert_checkequal(S1.c, list([],[])); +S1=S([1 2 1],1,1); +assert_checkequal(S1.a, list(33,[],33)); +assert_checkequal(S1.b, list("toto",12,"toto")); +assert_checkequal(S1.c, list([],[],[])); +S1=S(1,:,1); +assert_checkequal(S1.a, list(33,[])); +assert_checkequal(S1.b, list("toto",[])); +assert_checkequal(S1.c, list([],[])); +S1=S(:,:); +assert_checkequal(S1.a, list(33,[],[],33,[],[],[],-5)); +assert_checkequal(S1.b, list("toto",12,[],"toto",[],[],[],[])); +assert_checkequal(S1.c, list([],[],[],[],[],[],[],8)); +S=struct(); +S.a(2).b=1; +assert_checkequal(S.a.b, list([],1)); +clear S; +S.a(2).b=1; +assert_checkequal(S.a.b, list([],1)); +S=struct(); +S(2).a.b=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, 1); +clear S; +S(2).a.b=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, 1); +clear S; +S(2).a(3).b=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, list([],[], 1)); +// +S = struct("a", "1"); +S(1,1,2).a = "2"; +S(1).b = 2; +assert_checkequal(S.a, list("1", "2")); +assert_checkequal(S.b, list(2, [])); +S(2).a=5; +assert_checkequal(S.a, list("1", 5)); +S(1,3,2).a="foo"; +assert_checkequal(S.a, list("1",[],[],5,[],"foo")); +assert_checkequal(S.b, list(2,[],[],[],[],[])); +S(1,3,2,2).b=[33 44]; +assert_checkequal(S.a, list("1",[],[],5,[],"foo" ,[],[],[],[],[],[])); +assert_checkequal(S.b, list(2,[],[],[],[],[],[],[],[],[],[],[33,44])); +clear S;S(1,2).a=3;S(3).a=44 ; +assert_checkequal(S.a, list([],3,44)); +clear S;S.a=3;S(3).a=44; +assert_checkequal(S.a, list(3,[],44)); +clear S;S(4).a=3; +assert_checkequal(S.a, list([],[],[],3)); +clear S; +S(1).a(1,1:4)=1; +S(1).b(1:3)=5; +assert_checkequal(S.a, [1,1,1,1]); +assert_checkequal(S.b, [5;5;5]); +S=struct(); +S.b(1,1)=3; +assert_checkequal(S.b, 3); +clear S; +S(1,1).a(1,1:4)=1; +S(1,1).b(1,1:3)=5; +assert_checkequal(S.a, [1,1,1,1]); +assert_checkequal(S.b, [5,5,5]); +clear S; +S(1,1).a(1:4)=1; +S(1,1).b(1:3)=5; +assert_checkequal(S.a, [1;1;1;1]); +assert_checkequal(S.b, [5;5;5]); +clear S; +S(1,2).a(1:4)=1; +S(2,1).b(1:3)=5; +assert_checkequal(S.a, list([],[],[1,1,1,1]',[])); +assert_checkequal(S.b, list([],[5,5,5]',[],[])); +clear S; +S(1,2).a(2).b(1,2)=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, list([],[0,1])); +clear S; +S(1,2).a(1,2).b(1,2,3)=4; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, list([], hypermat([1 2 3], [0;0;0;0;0;4]))); +mtlb_mode(%t) +clear S;S(1,2).a=3;S(3).a=44 ; +assert_checkequal(S.a, list([],3,44)); +assert_checkequal(size(S), [1, 3]); +clear S;S.a=3;S(3).a=44; +assert_checkequal(S.a, list(3,[],44)); +assert_checkequal(size(S), [1, 3]); +clear S;S(4).a=3; +assert_checkequal(S.a, list([],[],[],3)); +assert_checkequal(size(S), [1, 4]); +mtlb_mode(%f) diff --git a/modules/data_structures/tests/unit_tests/listinsertion.tst b/modules/data_structures/tests/unit_tests/listinsertion.tst new file mode 100755 index 000000000..0bfdb5c77 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/listinsertion.tst @@ -0,0 +1,419 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +// test des insertions dans les listes +a=1;b=3;c=2;d=[1 2 3];e=[3 4 5];f=[10;20];g=[44 55]; +h=5;i=4;a0=10;c0=20;b0=30;g0=[44 55 66; 10 20 30]; + + +l=list();l(0)=a;if l<>list(a) then pause,end +l=list();l(1)=a;if l<>list(a) then pause,end +l=list(a);l(2)=b;if l<>list(a,b) then pause,end +l=list(a);l(0)=b;if l<>list(b,a) then pause,end +l=list(a);l(1)=c;if l<>list(c) then pause,end +l=list(a);l(1)=d;if l<>list(d) then pause,end +l=list(d);l(1)=a;if l<>list(a) then pause,end +l=list(a);l(1)=null();if l<>list() then pause,end +l=list(a,c);l(1)=null();if l<>list(c) then pause,end +l=list(a,c);l(2)=null();if l<>list(a) then pause,end +l=list(a,c,b);l(2)=null();if l<>list(a,b) then pause,end +l=list(a,c,b);l(2)=e;if l<>list(a,e,b) then pause,end +l=list(a,e,b);l(2)=a;if l<>list(a,c,b) then pause,end + +l=list();l(0)=null();if l<>list() then pause,end +l=list();l(1)=null();if l<>list() then pause,end +// +l=list(a);l(0)=list(c,b);if l<>list(list(c,b),a) then pause,end +l=list(a);l(2)=list(c,b);if l<>list(a,list(c,b)) then pause,end +l=list(a,list(c,b));l(3)=i;if l<>list(a,list(c,b),i) then pause,end +l=list(a,list(c,b),i);l(1)=null();if l<>list(list(c,b),i) then pause,end +l=list(a,list(c,b),i);l(2)=null();if l<>list(a,i) then pause,end +l=list(a,list(c,b),i);l(3)=null();if l<>list(a,list(c,b)) then pause,end +// +l=list(a,list(c,b,i),h);l(2)(2)=a0;if l<>list(a,list(c,a0,i),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(2)=f;if l<>list(a,list(c,f,i),h) then pause,end +l=list(a,list(c,f,i),h);l(2)(2)=b;if l<>list(a,list(c,b,i),h) then pause,end + +l=list(a,list(c,b,i),h);l(2)(3)=a0;if l<>list(a,list(c,b,a0),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(3)=f;if l<>list(a,list(c,b,f),h) then pause,end +l=list(a,list(c,b,f),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then pause,end + +l=list(a,list(c,b),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then pause,end +l=list(a,list(c,b),h);l(2)(0)=a;if l<>list(a,list(a,c,b),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(2)=null();if l<>list(a,list(c,i),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(1)=null();if l<>list(a,list(b,i),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(3)=null();if l<>list(a,list(c,b),h) then pause,end +l=list(a,list(c,b),h);l(2)(3)=g;if l<>list(a,list(c,b,g),h) then pause,end +l=list(a,list(c,b),h);l(2)(0)=e;if l<>list(a,list(e,c,b),h) then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=0;if l<>list(a,list(c,list(0,c0,b0),b),h); then pause,end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=null();if l<>list(a,list(c,list(c0,b0),b),h); then pause,end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=g;if l<>list(a,list(c,list(g,c0,b0),b),h); then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(0)=g;if l<>list(a,list(c,list(g,a0,c0,b0),b),h); then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=g;if l<>list(a,list(c,list(a0,c0,g),b),h); then pause,end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=null();if l<>list(a,list(c,list(a0,c0),b),h); then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(4)=g;if l<>list(a,list(c,list(a0,c0,b0,g),b),h); then +pause,end +l=list();l(5)=33; +ll=l; + +l=list(a,1/%s);l(2)('num')=33;if l<>list(a,33/%s) then pause,end +l=list(a,1/%s);l(2)('num')=%s+1;if l<>list(a,((%s+1)/%s)) then pause,end +l=list(a,1/%s);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1)) then pause,end +l=list(a,1/%s);l(2)('num')(1)=33;if l<>list(a,33/%s) then pause,end +l=list(a,1/%s);l(2)('num')(1)=%s+1;if l<>list(a,((%s+1)/%s)) then pause,end +l=list(a,1/%s);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then pause,end +l=list(a,1/%s);l(2)('num')(1,1)=33;if l<>list(a,33/%s) then pause,end +l=list(a,1/%s);l(2)('num')(1,1)=%s+1;if l<>list(a,((%s+1)/%s)) then pause,end +l=list(a,1/%s);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then pause,end + +l=list(a,1/%s,g);l(2)('num')=33;if l<>list(a,33/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('num')=%s+1;if l<>list(a,(%s+1)/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1),g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1)=33;if l<>list(a,33/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1)=%s+1;if l<>list(a,(%s+1)/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1,1)=33;if l<>list(a,33/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1,1)=%s+1;if l<>list(a,(%s+1)/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then pause,end + +l=list(a,1/%s,g);l(2)('num')(1,2)=33;l(2)('den')(1,2)=%s+1; +if l<>list(a,[1 33]./[%s %s+1],g) then pause,end + + +//a=1;b=3;c=2;d=[1 2 3];e=[3 4 5];f=[10;20];g=[44 55]; +//h=5;i=4;a0=10;c0=20;b0=30;g0=[44 55 66; 10 20 30]; +l=list(a);l(1)(1)=3;x=a;x(1)=3;if l<>list(x) then pause,end +l=list(e);l(1)(2)=[];x=e;x(2)=[];if l<>list(x) then pause,end +l=list(a);l(1)(1,1)=3;x=a;x(1,1)=3;if l<>list(x) then pause,end +l=list(e);l(1)(1,2)=[];x=e;x(1,2)=[];if l<>list(x) then pause,end +l=list(a);l(1)(5,5)=3;x=a;x(5,5)=3;if l<>list(x) then pause,end +l=list(g0);l(1)(2,3)=3;x=g0;x(2,3)=3;if l<>list(x) then pause,end + +l=list(b,a);l(2)(1)=3;x=a;x(1)=3;if l<>list(b,x) then pause,end +l=list(b,e);l(2)(2)=[];x=e;x(2)=[];if l<>list(b,x) then pause,end +l=list(b,a);l(2)(1,1)=3;x=a;x(1,1)=3;if l<>list(b,x) then pause,end +l=list(b,e);l(2)(1,2)=[];x=e;x(1,2)=[];if l<>list(b,x) then pause,end +l=list(b,a);l(2)(5,5)=3;x=a;x(5,5)=3;if l<>list(b,x) then pause,end +l=list(b,g0);l(2)(2,3)=3;x=g0;x(2,3)=3;if l<>list(b,x) then pause,end +l=list(b,g0);l(2)(2,2:3)=[1 3];x=g0;x(2,2:3)=[1 3];if l<>list(b,x) then pause,end + + +a=1:10;b=3:2:33;c=(-10:0)';d=[1 2+%s 3];e=['1';'2';'3';'4']; +f=[%t %t %f];g=['12345','abcdefghijk']; +h=rand(3,3);i=eye(10,10);a0=10+%s;c0=20;b0=sparse(eye(30,30)); + +l=list();l(0)=a;if l<>list(a) then pause,end +l=list();l(1)=a;if l<>list(a) then pause,end +l=list(a);l(2)=b;if l<>list(a,b) then pause,end +l=list(a);l(0)=b;if l<>list(b,a) then pause,end +l=list(a);l(1)=c;if l<>list(c) then pause,end +l=list(a);l(1)=d;if l<>list(d) then pause,end +l=list(d);l(1)=a;if l<>list(a) then pause,end +l=list(a);l(1)=null();if l<>list() then pause,end +l=list(a,c);l(1)=null();if l<>list(c) then pause,end +l=list(a,c);l(2)=null();if l<>list(a) then pause,end +l=list(a,c,b);l(2)=null();if l<>list(a,b) then pause,end +l=list(a,c,b);l(2)=e;if l<>list(a,e,b) then pause,end +l=list(a,e,b);l(2)=a;if l<>list(a,c,b) then pause,end + +l=list();l(0)=null();if l<>list() then pause,end +l=list();l(1)=null();if l<>list() then pause,end +// +l=list(a);l(0)=list(c,b);if l<>list(list(c,b),a) then pause,end +l=list(a);l(2)=list(c,b);if l<>list(a,list(c,b)) then pause,end +l=list(a,list(c,b));l(3)=i;if l<>list(a,list(c,b),i) then pause,end +l=list(a,list(c,b),i);l(1)=null();if l<>list(list(c,b),i) then pause,end +l=list(a,list(c,b),i);l(2)=null();if l<>list(a,i) then pause,end +l=list(a,list(c,b),i);l(3)=null();if l<>list(a,list(c,b)) then pause,end +// +l=list(a,list(c,b,i),h);l(2)(2)=a0;if l<>list(a,list(c,a0,i),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(2)=f;if l<>list(a,list(c,f,i),h) then pause,end +l=list(a,list(c,f,i),h);l(2)(2)=b;if l<>list(a,list(c,b,i),h) then pause,end + +l=list(a,list(c,b,i),h);l(2)(3)=a0;if l<>list(a,list(c,b,a0),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(3)=f;if l<>list(a,list(c,b,f),h) then pause,end +l=list(a,list(c,b,f),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then pause,end + +l=list(a,list(c,b),h);l(2)(3)=i;if l<>list(a,list(c,b,i),h) then pause,end +l=list(a,list(c,b),h);l(2)(0)=a;if l<>list(a,list(a,c,b),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(2)=null();if l<>list(a,list(c,i),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(1)=null();if l<>list(a,list(b,i),h) then pause,end +l=list(a,list(c,b,i),h);l(2)(3)=null();if l<>list(a,list(c,b),h) then pause,end +l=list(a,list(c,b),h);l(2)(3)=g;if l<>list(a,list(c,b,g),h) then pause,end +l=list(a,list(c,b),h);l(2)(0)=e;if l<>list(a,list(e,c,b),h) then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=0;if l<>list(a,list(c,list(0,c0,b0),b),h); then pause,end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=null();if l<>list(a,list(c,list(c0,b0),b),h); then pause,end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(1)=g;if l<>list(a,list(c,list(g,c0,b0),b),h); then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(0)=g;if l<>list(a,list(c,list(g,a0,c0,b0),b),h); then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=g;if l<>list(a,list(c,list(a0,c0,g),b),h); then pause,end +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(3)=null();if l<>list(a,list(c,list(a0,c0),b),h); then pause,end + +l=list(a,list(c,list(a0,c0,b0),b),h); +l(2)(2)(4)=g;if l<>list(a,list(c,list(a0,c0,b0,g),b),h); then pause,end + +l=list(a,1/%s);l(2)('num')=33;if l<>list(a,33/%s) then pause,end +l=list(a,1/%s);l(2)('num')=%s+1;if l<>list(a,((%s+1)/%s)) then pause,end +l=list(a,1/%s);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1)) then pause,end +l=list(a,1/%s);l(2)('num')(1)=33;if l<>list(a,33/%s) then pause,end +l=list(a,1/%s);l(2)('num')(1)=%s+1;if l<>list(a,((%s+1)/%s)) then pause,end +l=list(a,1/%s);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then pause,end +l=list(a,1/%s);l(2)('num')(1,1)=33;if l<>list(a,33/%s) then pause,end +l=list(a,1/%s);l(2)('num')(1,1)=%s+1;if l<>list(a,((%s+1)/%s)) then pause,end +l=list(a,1/%s);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1)) then pause,end + +l=list(a,1/%s,g);l(2)('num')=33;if l<>list(a,33/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('num')=%s+1;if l<>list(a,(%s+1)/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('den')=%s^1+1;if l<>list(a,1/(%s^2+1),g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1)=33;if l<>list(a,33/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1)=%s+1;if l<>list(a,(%s+1)/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('den')(1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1,1)=33;if l<>list(a,33/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('num')(1,1)=%s+1;if l<>list(a,(%s+1)/%s,g) then pause,end +l=list(a,1/%s,g);l(2)('den')(1,1)=%s^1+1;if l<>list(a,1/(%s^2+1),g) then pause,end + +l=list(a,1/%s,g);l(2)('num')(1,2)=33;l(2)('den')(1,2)=%s+1; +if l<>list(a,[1 33]./[%s %s+1],g) then pause,end + +//test with field names not defined in the structure here row1 and row2 + +function M=%to_e(varargin) + M = varargin($), + select varargin(1) + case 'row2' then + M.N = M.N(2, eye()) + M.V = M.V(2, eye()) + case 'row1' then + M.N = M.N(1, eye()) + M.V = M.V(1, eye()) + else + M.N = M.N(varargin(1:$ - 1)) + M.V = M.V(varargin(1:$ - 1)) + end +endfunction + + +%to_6=%to_e; + +function M=%to_i_to(varargin) + M=varargin($);N=varargin($-1) + select varargin(1) + case 'row2' + M.N(2,:)=N.N + M.V(2,:)=N.V + case 'row1' + M.N(1,:)=N.N + M.V(1,:)=N.V + else + M.N(varargin(1:$-2))=N.N + M.V(varargin(1:$-2))=N.V + end +endfunction + +M=mlist(['to','V','N'],[1 2 3;4 5 6],['a','b','c';'d','e','f']); +M.row1(2)=M.row2(1); +assert_checkequal(M.V, [1 4 3;4 5 6]); +assert_checkequal(M.N, ['a','d','c';'d','e','f']); +l=list(1,M,2); +l(2).row1(2)=M.row1(1); +assert_checkequal(l(1), 1); +assert_checkequal(l(2).V, [1 1 3;4 5 6]); +assert_checkequal(l(2).N, ['a','a','c';'d','e','f']); +assert_checkequal(M.V, [1 4 3;4 5 6]); +assert_checkequal(M.N, ['a','d','c';'d','e','f']); +l(1)="foo"; +assert_checkequal(l(1), "foo"); + +//test of insertion in structs (a particular mlist) +clear S; +S.a=11; +S(2).a=12; +assert_checkequal(S.a, list(11,12)); + +clear S; +S.a=11; +S.a(2,2)=12; +assert_checkequal(S.a, diag([11,12])); + +clear S; +S.a=11; +S(2).b=12; +assert_checkequal(S.a, list(11,[])); +assert_checkequal(S.b, list([],12)); + +clear S S1 S2; +S.a=11; +S(2).b=12; + +S1.a=33; +S1.b='toto'; +S(1)=S1; +assert_checkequal(S.a, list(33,[])); +assert_checkequal(S.b, list("toto",12)); + +S(2,2)=S1; +assert_checkequal(S.a, list(33,[],[],33)); +assert_checkequal(S.b, list("toto",12,[],"toto")); + +S2.a=-5; +S2.c=8; + +S(2,2,2)=S2; +assert_checkequal(S.a, list(33,[],[],33,[],[],[],-5)); +assert_checkequal(S.b, list("toto",12,[],"toto",[],[],[],[])); +assert_checkequal(S.c, list([],[],[],[],[],[],[],8)); + +S1=S(:,1,1); +assert_checkequal(S1.a, list(33,[])); +assert_checkequal(S1.b, list("toto",12)); +assert_checkequal(S1.c, list([],[])); + +S1=S(1:2,1,1); +assert_checkequal(S1.a, list(33,[])); +assert_checkequal(S1.b, list("toto",12)); +assert_checkequal(S1.c, list([],[])); + +S1=S([1 1],1,1); +assert_checkequal(S1.a, list(33,33)); +assert_checkequal(S1.b, list("toto","toto")); +assert_checkequal(S1.c, list([],[])); + +S1=S([1 2 1],1,1); +assert_checkequal(S1.a, list(33,[],33)); +assert_checkequal(S1.b, list("toto",12,"toto")); +assert_checkequal(S1.c, list([],[],[])); + +S1=S(1,:,1); +assert_checkequal(S1.a, list(33,[])); +assert_checkequal(S1.b, list("toto",[])); +assert_checkequal(S1.c, list([],[])); + +S1=S(:,:); +assert_checkequal(S1.a, list(33,[],[],33,[],[],[],-5)); +assert_checkequal(S1.b, list("toto",12,[],"toto",[],[],[],[])); +assert_checkequal(S1.c, list([],[],[],[],[],[],[],8)); + +S=struct(); +S.a(2).b=1; +assert_checkequal(S.a.b, list([],1)); + +clear S; +S.a(2).b=1; +assert_checkequal(S.a.b, list([],1)); + +S=struct(); +S(2).a.b=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, 1); + +clear S; +S(2).a.b=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, 1); + +clear S; +S(2).a(3).b=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, list([],[], 1)); + +// +S = struct("a", "1"); +S(1,1,2).a = "2"; +S(1).b = 2; +assert_checkequal(S.a, list("1", "2")); +assert_checkequal(S.b, list(2, [])); +S(2).a=5; +assert_checkequal(S.a, list("1", 5)); + +S(1,3,2).a="foo"; +assert_checkequal(S.a, list("1",[],[],5,[],"foo")); +assert_checkequal(S.b, list(2,[],[],[],[],[])); + +S(1,3,2,2).b=[33 44]; +assert_checkequal(S.a, list("1",[],[],5,[],"foo" ,[],[],[],[],[],[])); +assert_checkequal(S.b, list(2,[],[],[],[],[],[],[],[],[],[],[33,44])); + +clear S;S(1,2).a=3;S(3).a=44 ; +assert_checkequal(S.a, list([],3,44)); + +clear S;S.a=3;S(3).a=44; +assert_checkequal(S.a, list(3,[],44)); + +clear S;S(4).a=3; +assert_checkequal(S.a, list([],[],[],3)); + +clear S; +S(1).a(1,1:4)=1; +S(1).b(1:3)=5; +assert_checkequal(S.a, [1,1,1,1]); +assert_checkequal(S.b, [5;5;5]); + +S=struct(); +S.b(1,1)=3; +assert_checkequal(S.b, 3); + +clear S; +S(1,1).a(1,1:4)=1; +S(1,1).b(1,1:3)=5; +assert_checkequal(S.a, [1,1,1,1]); +assert_checkequal(S.b, [5,5,5]); + +clear S; +S(1,1).a(1:4)=1; +S(1,1).b(1:3)=5; +assert_checkequal(S.a, [1;1;1;1]); +assert_checkequal(S.b, [5;5;5]); + +clear S; +S(1,2).a(1:4)=1; +S(2,1).b(1:3)=5; +assert_checkequal(S.a, list([],[],[1,1,1,1]',[])); +assert_checkequal(S.b, list([],[5,5,5]',[],[])); + +clear S; +S(1,2).a(2).b(1,2)=1; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, list([],[0,1])); + +clear S; +S(1,2).a(1,2).b(1,2,3)=4; +assert_checkequal(S(1).a, []); +assert_checkequal(S(2).a.b, list([], hypermat([1 2 3], [0;0;0;0;0;4]))); + +mtlb_mode(%t) +clear S;S(1,2).a=3;S(3).a=44 ; +assert_checkequal(S.a, list([],3,44)); +assert_checkequal(size(S), [1, 3]); + +clear S;S.a=3;S(3).a=44; +assert_checkequal(S.a, list(3,[],44)); +assert_checkequal(size(S), [1, 3]); + +clear S;S(4).a=3; +assert_checkequal(S.a, list([],[],[],3)); +assert_checkequal(size(S), [1, 4]); +mtlb_mode(%f) diff --git a/modules/data_structures/tests/unit_tests/lstcat.dia.ref b/modules/data_structures/tests/unit_tests/lstcat.dia.ref new file mode 100755 index 000000000..5c8b9fd85 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/lstcat.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +if or(lstcat(list(1,2),list(4))<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list(1,2,4),list())<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list(1),list(2,4))<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list(),list(1,2,4))<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list(1,2),4)<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(1,list(2,4))<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list(1),list(2),list(4))<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list(1,2),list(),4)<>list(1,2,4)) then bugmes();quit;end +if or(lstcat(list([1 2],['my string';'matrix']),list('foo',%s))<>list([1 2],.. + ['my string';'matrix'],'foo',%s)) then bugmes();quit;end diff --git a/modules/data_structures/tests/unit_tests/lstcat.tst b/modules/data_structures/tests/unit_tests/lstcat.tst new file mode 100755 index 000000000..ecdcca53c --- /dev/null +++ b/modules/data_structures/tests/unit_tests/lstcat.tst @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +if or(lstcat(list(1,2),list(4))<>list(1,2,4)) then pause,end +if or(lstcat(list(1,2,4),list())<>list(1,2,4)) then pause,end +if or(lstcat(list(1),list(2,4))<>list(1,2,4)) then pause,end +if or(lstcat(list(),list(1,2,4))<>list(1,2,4)) then pause,end + +if or(lstcat(list(1,2),4)<>list(1,2,4)) then pause,end +if or(lstcat(1,list(2,4))<>list(1,2,4)) then pause,end + +if or(lstcat(list(1),list(2),list(4))<>list(1,2,4)) then pause,end + +if or(lstcat(list(1,2),list(),4)<>list(1,2,4)) then pause,end + +if or(lstcat(list([1 2],['my string';'matrix']),list('foo',%s))<>list([1 2],.. + ['my string';'matrix'],'foo',%s)) then pause,end diff --git a/modules/data_structures/tests/unit_tests/lstops.dia.ref b/modules/data_structures/tests/unit_tests/lstops.dia.ref new file mode 100755 index 000000000..3fef4e9dd --- /dev/null +++ b/modules/data_structures/tests/unit_tests/lstops.dia.ref @@ -0,0 +1,112 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +mode(5); +funcprot(0); +//----------------------- +//-- extractions tests -- +//----------------------- +l=list(1,2,-4); +if l(1)<>1 then bugmes();quit;end +if l(3)<>-4 then bugmes();quit;end +[x1,x2]=l([1 3]); +if x1<>l(1)|x2<>l(3) then bugmes();quit;end +[x2,x1]=l([3 1]); +if x1<>l(1)|x2<>l(3) then bugmes();quit;end +[x1,x2]=l([1;3]); +if x1<>l(1)|x2<>l(3) then bugmes();quit;end +[x2,x1]=l([3;1]); +if x1<>l(1)|x2<>l(3) then bugmes();quit;end +[x1,x2,x3]=l(:); +if x1<>l(1)|x2<>l(2)|x3<>l(3) then bugmes();quit;end +//with full tlists +l=tlist(['t','a','b','c'],1,-2,5); +if l(2)<>1 then bugmes();quit;end +if l(4)<>5 then bugmes();quit;end +[x1,x2]=l([2 4]); +if x1<>l(2)|x2<>l(4) then bugmes();quit;end +[x2,x1]=l([4 2]); +if x1<>l(2)|x2<>l(4) then bugmes();quit;end +if l('a')<>1 then bugmes();quit;end +if l('c')<>5 then bugmes();quit;end +[x1,x2]=l(['a' 'c']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +[x2,x1]=l(['c' 'a']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +[x1,x2]=l(['a';'c']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +[x2,x1]=l(['c';'a']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +//with partial tlists (no elements formal names) +l=tlist('t',1,-2,5); +deff('[f1,f2,f3,f4,f5,f6,f7]=%t_e(i,j,f)',[ + 'nams=[''a'',''b'',''c''];' + 'for k=1:prod(size(i))'; + ' kf=find(i(k)==nams);'; + ' if kf==[] then error(21),end;' + ' execstr(''f''+string(k)+''=j(kf+1)'');' + ' end;']) +if l(2)<>1 then bugmes();quit;end +if l(4)<>5 then bugmes();quit;end +[x1,x2]=l([2 4]); +if x1<>l(2)|x2<>l(4) then bugmes();quit;end +[x2,x1]=l([4 2]); +if x1<>l(2)|x2<>l(4) then bugmes();quit;end +if l('a')<>1 then bugmes();quit;end +if l('c')<>5 then bugmes();quit;end +[x1,x2]=l(['a' 'c']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +[x2,x1]=l(['c' 'a']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +[x1,x2]=l(['a';'c']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +[x2,x1]=l(['c';'a']); +if x1<>l('a')|x2<>l('c') then bugmes();quit;end +// extraction inside a input argument list +a=list(1,2,3,4); +if or(list(a(1:2))<>list(1,2)) then bugmes();quit;end +if type(list(a(1:2)))<>15 then bugmes();quit;end +deff('[a,b]=foo(x,y)','a=x;b=y') +[u,v]=foo(a(1:2));if u<>a(1)|v<>a(2) then bugmes();quit;end +deff('[a]=foo(x,y)','a=x+y') +if abs(foo(a(1:2)))<>3 then bugmes();quit;end +//--------------------- +//-- insertion tests -- +//--------------------- +l=list(2,'a',-1); +l(1)=[1 2]; +if l<>list([1 2],'a',-1) then bugmes();quit;end +l(1)=33; +if l<>list(33,'a',-1) then bugmes();quit;end +l(1)=33; +if l<>list(33,'a',-1) then bugmes();quit;end +l(0)=1.25; +if l<>list(1.25,33,'a',-1) then bugmes();quit;end +l(5)=[1 2 3]; +if l<>list(1.25,33,'a',-1,[1 2 3]) then bugmes();quit;end +l(3)=null(); +if l<>list(1.25,33,-1,[1 2 3]) then bugmes();quit;end +l(3)=null(); +if l<>list(1.25,33,[1 2 3]) then bugmes();quit;end +l(4)=null(); +if l<>list(1.25,33,[1 2 3]) then bugmes();quit;end +l(0)=null(); +if l<>list(1.25,33,[1 2 3]) then bugmes();quit;end +l=tlist('t',2,'a',-1); +l(2)=[1 2 3]; +if %l_n_l(l,tlist('t',[1 2 3],'a',-1)) then bugmes();quit;end +l(2)=33; +if %l_n_l(l,tlist('t',33,'a',-1)) then bugmes();quit;end +l(2)=33; +if %l_n_l(l,tlist('t',33,'a',-1)) then bugmes();quit;end +l(4)=[1 2]; +if %l_n_l(l,tlist('t',33,'a',[1,2])) then bugmes();quit;end +l(2)=null(); +if %l_n_l(l,tlist('t','a',[1,2])) then bugmes();quit;end +l(1)=null(); +if %l_n_l(l,list('a',[1,2])) then bugmes();quit;end +funcprot(1); diff --git a/modules/data_structures/tests/unit_tests/lstops.tst b/modules/data_structures/tests/unit_tests/lstops.tst new file mode 100755 index 000000000..d0b7e8b9d --- /dev/null +++ b/modules/data_structures/tests/unit_tests/lstops.tst @@ -0,0 +1,119 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +mode(5); +funcprot(0); + +//----------------------- +//-- extractions tests -- +//----------------------- + +l=list(1,2,-4); +if l(1)<>1 then pause,end +if l(3)<>-4 then pause,end +[x1,x2]=l([1 3]); +if x1<>l(1)|x2<>l(3) then pause,end +[x2,x1]=l([3 1]); +if x1<>l(1)|x2<>l(3) then pause,end +[x1,x2]=l([1;3]); +if x1<>l(1)|x2<>l(3) then pause,end +[x2,x1]=l([3;1]); +if x1<>l(1)|x2<>l(3) then pause,end +[x1,x2,x3]=l(:); +if x1<>l(1)|x2<>l(2)|x3<>l(3) then pause,end + +//with full tlists +l=tlist(['t','a','b','c'],1,-2,5); +if l(2)<>1 then pause,end +if l(4)<>5 then pause,end +[x1,x2]=l([2 4]); +if x1<>l(2)|x2<>l(4) then pause,end +[x2,x1]=l([4 2]); +if x1<>l(2)|x2<>l(4) then pause,end +if l('a')<>1 then pause,end +if l('c')<>5 then pause,end +[x1,x2]=l(['a' 'c']); +if x1<>l('a')|x2<>l('c') then pause,end +[x2,x1]=l(['c' 'a']); +if x1<>l('a')|x2<>l('c') then pause,end +[x1,x2]=l(['a';'c']); +if x1<>l('a')|x2<>l('c') then pause,end +[x2,x1]=l(['c';'a']); +if x1<>l('a')|x2<>l('c') then pause,end + +//with partial tlists (no elements formal names) +l=tlist('t',1,-2,5); +deff('[f1,f2,f3,f4,f5,f6,f7]=%t_e(i,j,f)',[ + 'nams=[''a'',''b'',''c''];' + 'for k=1:prod(size(i))'; + ' kf=find(i(k)==nams);'; + ' if kf==[] then error(21),end;' + ' execstr(''f''+string(k)+''=j(kf+1)'');' + ' end;']) +if l(2)<>1 then pause,end +if l(4)<>5 then pause,end +[x1,x2]=l([2 4]); +if x1<>l(2)|x2<>l(4) then pause,end +[x2,x1]=l([4 2]); +if x1<>l(2)|x2<>l(4) then pause,end +if l('a')<>1 then pause,end +if l('c')<>5 then pause,end +[x1,x2]=l(['a' 'c']); +if x1<>l('a')|x2<>l('c') then pause,end +[x2,x1]=l(['c' 'a']); +if x1<>l('a')|x2<>l('c') then pause,end +[x1,x2]=l(['a';'c']); +if x1<>l('a')|x2<>l('c') then pause,end +[x2,x1]=l(['c';'a']); +if x1<>l('a')|x2<>l('c') then pause,end + +// extraction inside a input argument list +a=list(1,2,3,4); +if or(list(a(1:2))<>list(1,2)) then pause,end +if type(list(a(1:2)))<>15 then pause,end +deff('[a,b]=foo(x,y)','a=x;b=y') +[u,v]=foo(a(1:2));if u<>a(1)|v<>a(2) then pause,end +deff('[a]=foo(x,y)','a=x+y') +if abs(foo(a(1:2)))<>3 then pause,end + +//--------------------- +//-- insertion tests -- +//--------------------- +l=list(2,'a',-1); +l(1)=[1 2]; +if l<>list([1 2],'a',-1) then pause,end +l(1)=33; +if l<>list(33,'a',-1) then pause,end +l(1)=33; +if l<>list(33,'a',-1) then pause,end +l(0)=1.25; +if l<>list(1.25,33,'a',-1) then pause,end +l(5)=[1 2 3]; +if l<>list(1.25,33,'a',-1,[1 2 3]) then pause,end +l(3)=null(); +if l<>list(1.25,33,-1,[1 2 3]) then pause,end +l(3)=null(); +if l<>list(1.25,33,[1 2 3]) then pause,end +l(4)=null(); +if l<>list(1.25,33,[1 2 3]) then pause,end +l(0)=null(); +if l<>list(1.25,33,[1 2 3]) then pause,end +l=tlist('t',2,'a',-1); +l(2)=[1 2 3]; +if %l_n_l(l,tlist('t',[1 2 3],'a',-1)) then pause,end +l(2)=33; +if %l_n_l(l,tlist('t',33,'a',-1)) then pause,end +l(2)=33; +if %l_n_l(l,tlist('t',33,'a',-1)) then pause,end +l(4)=[1 2]; +if %l_n_l(l,tlist('t',33,'a',[1,2])) then pause,end +l(2)=null(); +if %l_n_l(l,tlist('t','a',[1,2])) then pause,end +l(1)=null(); +if %l_n_l(l,list('a',[1,2])) then pause,end + +funcprot(1); diff --git a/modules/data_structures/tests/unit_tests/struct.dia.ref b/modules/data_structures/tests/unit_tests/struct.dia.ref new file mode 100755 index 000000000..8ec8bca46 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/struct.dia.ref @@ -0,0 +1,78 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- ENGLISH IMPOSED --> +// <-- CLI SHELL MODE --> +// unit tests for structs +// ============================================================================= +date_st=struct('jour',25,'mois','DEC','annee',2006); +if date_st.jour <> 25 then bugmes();quit;end +if date_st.mois <> 'DEC' then bugmes();quit;end +if date_st.annee <> 2006 then bugmes();quit;end +date_st.jour=19; +if date_st.jour <> 19 then bugmes();quit;end +date_st.mois='AOU'; +if date_st.mois <> 'AOU' then bugmes();quit;end +date_st.annee=1973; +if date_st.annee <> 1973 then bugmes();quit;end +date_st.semaine=32; +if date_st.semaine <> 32 then bugmes();quit;end +// Example from bug #7244 +clear; +foo(1) = 1; +foo(2) = 2; +foo(3) = 3; +foo = foo([1 3]); +foo(3) = 2; +if [1; 3; 2] <> foo then bugmes();quit;end +clear; +foo(1) = 1; +foo(2) = 2; +foo(3) = 3; +foo = foo([%T %F %T]); +foo(3) = 2; +if or([1; 3; 2] <> foo) then bugmes();quit;end +clear; +foo(1).bar = 1; +foo(2).bar = 2; +foo(3).bar = 3; +foo = foo([1 3]); +foo(3).bar = 2; +if foo(1).bar <> 1 then bugmes();quit;end +if foo(2).bar <> 3 then bugmes();quit;end +if foo(3).bar <> 2 then bugmes();quit;end +out.a=1; +out.b=2; +if size(out,'*') <> 1 then bugmes();quit;end +out(2,3).b=2; +if or(size(out) <> [2 3]) then bugmes();quit;end +s=struct("txt","Hello","num",%pi,"pol",%z^2+1); +if s.pol <> %z^2+1 then bugmes();quit;end +if s.txt <> "Hello" then bugmes();quit;end +s.txt=null();s.num=null();s.pol=null(); +if isfield( s , "txt" ) then bugmes();quit;end +if isfield( s , "num" ) then bugmes();quit;end +if isfield( s , "pol" ) then bugmes();quit;end +if or(isfield( s , ["pol", "num", "txt"] )) then bugmes();quit;end +if or(size(s) <> [1 1]) then bugmes();quit;end +z.y = 42; +y.o = z; +y.d.e = z; +y.f.r.h = z; +y.i.j.k.l = z; +z.m = y; +z.m.o.y = z; +if z.m.o.y.m.i.j.k.l.y <> 42 then bugmes();quit;end +if ~isfield(z.m.o.y.m.i.j.k.l,"y") then bugmes();quit;end +z.z = 21; +z.b = z; +z.b.c = z; +if z.z <> 21 then bugmes();quit;end +if z.b.c.z <> 21 then bugmes();quit;end +if ~isfield(z,"b") then bugmes();quit;end +if ~isfield(z.b,"c") then bugmes();quit;end +z(1).x.x = 1; +if execstr('z(42).x','errcatch')<>21 then bugmes();quit;end diff --git a/modules/data_structures/tests/unit_tests/struct.tst b/modules/data_structures/tests/unit_tests/struct.tst new file mode 100755 index 000000000..116a77171 --- /dev/null +++ b/modules/data_structures/tests/unit_tests/struct.tst @@ -0,0 +1,96 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- ENGLISH IMPOSED --> +// <-- CLI SHELL MODE --> + +// unit tests for structs +// ============================================================================= + +date_st=struct('jour',25,'mois','DEC','annee',2006); + +if date_st.jour <> 25 then pause, end +if date_st.mois <> 'DEC' then pause, end +if date_st.annee <> 2006 then pause, end + +date_st.jour=19; +if date_st.jour <> 19 then pause, end + +date_st.mois='AOU'; +if date_st.mois <> 'AOU' then pause, end + +date_st.annee=1973; +if date_st.annee <> 1973 then pause, end + +date_st.semaine=32; +if date_st.semaine <> 32 then pause, end + +// Example from bug #7244 +clear; +foo(1) = 1; +foo(2) = 2; +foo(3) = 3; +foo = foo([1 3]); +foo(3) = 2; +if [1; 3; 2] <> foo then pause, end + +clear; +foo(1) = 1; +foo(2) = 2; +foo(3) = 3; +foo = foo([%T %F %T]); +foo(3) = 2; +if or([1; 3; 2] <> foo) then pause, end + +clear; +foo(1).bar = 1; +foo(2).bar = 2; +foo(3).bar = 3; +foo = foo([1 3]); +foo(3).bar = 2; +if foo(1).bar <> 1 then pause, end +if foo(2).bar <> 3 then pause, end +if foo(3).bar <> 2 then pause, end + +out.a=1; +out.b=2; +if size(out,'*') <> 1 then pause, end + +out(2,3).b=2; +if or(size(out) <> [2 3]) then pause, end + +s=struct("txt","Hello","num",%pi,"pol",%z^2+1); +if s.pol <> %z^2+1 then pause, end +if s.txt <> "Hello" then pause, end + +s.txt=null();s.num=null();s.pol=null(); +if isfield( s , "txt" ) then pause, end +if isfield( s , "num" ) then pause, end +if isfield( s , "pol" ) then pause, end +if or(isfield( s , ["pol", "num", "txt"] )) then pause, end +if or(size(s) <> [1 1]) then pause, end + +z.y = 42; +y.o = z; +y.d.e = z; +y.f.r.h = z; +y.i.j.k.l = z; +z.m = y; +z.m.o.y = z; +if z.m.o.y.m.i.j.k.l.y <> 42 then pause, end +if ~isfield(z.m.o.y.m.i.j.k.l,"y") then pause, end + +z.z = 21; +z.b = z; +z.b.c = z; +if z.z <> 21 then pause, end +if z.b.c.z <> 21 then pause, end +if ~isfield(z,"b") then pause, end +if ~isfield(z.b,"c") then pause, end + +z(1).x.x = 1; +if execstr('z(42).x','errcatch')<>21 then pause,end |