diff options
Diffstat (limited to 'modules/completion/tests')
76 files changed, 3301 insertions, 0 deletions
diff --git a/modules/completion/tests/nonreg_tests/bug_10982.dia.ref b/modules/completion/tests/nonreg_tests/bug_10982.dia.ref new file mode 100755 index 000000000..fb5cd2f85 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_10982.dia.ref @@ -0,0 +1,45 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- JAVA NOT MANDATORY --> +// +// <-- Non-regression test for bug 10982 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10982 +// +// <-- Short Description --> +// Completion failed when space are used before the command. +// +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +REF = 'cd cudascilab/sci_gateway/'; +currentline = 'cd cudascilab/sc'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, REF); +REF = "~/Downl"; +currentline = 'ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); +currentline = 'out=ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); +currentline = 'out =ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); +currentline = 'out = ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); +REF = 'c:\Program files'; +currentline = ' cd c:\Program files'; +r = getfilepartlevel(currentline); +REF = 'c:\'; +currentline = 'for s=ls(""c:\'; +r = getfilepartlevel(currentline); diff --git a/modules/completion/tests/nonreg_tests/bug_10982.tst b/modules/completion/tests/nonreg_tests/bug_10982.tst new file mode 100755 index 000000000..aad867d71 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_10982.tst @@ -0,0 +1,53 @@ +// ============================================================================= +// 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. +// ============================================================================= +// +// <-- JAVA NOT MANDATORY --> +// +// <-- Non-regression test for bug 10982 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=10982 +// +// <-- Short Description --> +// Completion failed when space are used before the command. +// + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +REF = 'cd cudascilab/sci_gateway/'; +currentline = 'cd cudascilab/sc'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, REF); + +REF = "~/Downl"; +currentline = 'ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); + +currentline = 'out=ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); + +currentline = 'out =ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); + +currentline = 'out = ls(""~/Downl'; +r = getfilepartlevel(currentline); +assert_checkequal(r, REF); + +REF = 'c:\Program files'; +currentline = ' cd c:\Program files'; +r = getfilepartlevel(currentline); + +REF = 'c:\'; +currentline = 'for s=ls(""c:\'; +r = getfilepartlevel(currentline); diff --git a/modules/completion/tests/nonreg_tests/bug_12393.dia.ref b/modules/completion/tests/nonreg_tests/bug_12393.dia.ref new file mode 100755 index 000000000..dfdf71375 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_12393.dia.ref @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- JAVA NOT MANDATORY --> +// +// <-- Non-regression test for bug 10393 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12393 +// +// <-- Short Description --> +// Replacment by common part during completion does not work +ilib_verbose(0); +ierr = exec(SCI + "/modules/completion/tests/utilities/build_primitives.sce", .. + "errcatch", -1); +assert_checkequal(ierr, 0); +ierr = exec(TMPDIR + "/completion/loader.sce", "errcatch", -1); +assert_checkequal(ierr, 0); +// Suggested words for 'setdefau' are 'setdefaultlanguage', 'setDefaultColor' +// We must replace 'setdefau' by common part of this words: 'set' +currentline = 'setdefau'; +r = completeline('setdefau', 'set', getfilepartlevel(currentline), .. + getpartlevel(currentline), %t); +assert_checkequal(r, 'set'); diff --git a/modules/completion/tests/nonreg_tests/bug_12393.tst b/modules/completion/tests/nonreg_tests/bug_12393.tst new file mode 100755 index 000000000..410743ff4 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_12393.tst @@ -0,0 +1,30 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- JAVA NOT MANDATORY --> +// +// <-- Non-regression test for bug 10393 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=12393 +// +// <-- Short Description --> +// During completion replacment by common part of suggested words does not work + +ilib_verbose(0); +ierr = exec(SCI + "/modules/completion/tests/utilities/build_primitives.sce", .. + "errcatch", -1); +assert_checkequal(ierr, 0); +ierr = exec(TMPDIR + "/completion/loader.sce", "errcatch", -1); +assert_checkequal(ierr, 0); + +// Suggested words for 'setdefau' are 'setdefaultlanguage', 'setDefaultColor' +// We must replace 'setdefau' by common part of this words: 'set' +currentline = 'setdefau'; +r = completeline('setdefau', 'set', getfilepartlevel(currentline), .. + getpartlevel(currentline), %t); +assert_checkequal(r, 'set'); diff --git a/modules/completion/tests/nonreg_tests/bug_2848.dia.ref b/modules/completion/tests/nonreg_tests/bug_2848.dia.ref new file mode 100755 index 000000000..b096732dc --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_2848.dia.ref @@ -0,0 +1,44 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 2848 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2848 +// +// <-- Short Description --> +// When using the TAB key for completion in the console, after using once a Scilab +// macro, its name appears twice in the completion list: as a macro and as a variable. +[a, b, c, d] = completion("with"); +assert_checkequal(c, []); +with_tk(); +[a, b, c, d]=completion("with"); +assert_checkequal(c, []); +clear with_tk +[a, b, c, d]=completion("with"); +assert_checkequal(c, []); +with_tk(); +function x = with_foo(y, z) + x = y + z; +endfunction +[a, b, c, d] = completion("with"); +ref_a = ["with_module"]; +ref_b = []; +ref_c = []; +ref_d = ["with_foo"; .. +"with_javasci"; .. +"with_macros_source"; .. +"with_modelica_compiler"; .. +"with_tk"]; +assert_checkequal(a, ref_a); +assert_checkequal(b, ref_b); +assert_checkequal(c, ref_c); +assert_checkequal(d, ref_d); +clear with_tk +clear with_foo +[a,b,c,d] = completion("with"); +assert_checkequal(c, []); diff --git a/modules/completion/tests/nonreg_tests/bug_2848.tst b/modules/completion/tests/nonreg_tests/bug_2848.tst new file mode 100755 index 000000000..7a159f77f --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_2848.tst @@ -0,0 +1,56 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 2848 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=2848 +// +// <-- Short Description --> +// When using the TAB key for completion in the console, after using once a Scilab +// macro, its name appears twice in the completion list: as a macro and as a variable. + + +[a, b, c, d] = completion("with"); +assert_checkequal(c, []); + +with_tk(); +[a, b, c, d]=completion("with"); +assert_checkequal(c, []); + +clear with_tk +[a, b, c, d]=completion("with"); +assert_checkequal(c, []); + +with_tk(); + +function x = with_foo(y, z) + x = y + z; +endfunction + +[a, b, c, d] = completion("with"); +ref_a = ["with_module"]; +ref_b = []; +ref_c = []; +ref_d = ["with_foo"; .. +"with_javasci"; .. +"with_macros_source"; .. +"with_modelica_compiler"; .. +"with_tk"]; + +assert_checkequal(a, ref_a); +assert_checkequal(b, ref_b); +assert_checkequal(c, ref_c); +assert_checkequal(d, ref_d); + +clear with_tk +clear with_foo + +[a,b,c,d] = completion("with"); +assert_checkequal(c, []); diff --git a/modules/completion/tests/nonreg_tests/bug_3051.dia.ref b/modules/completion/tests/nonreg_tests/bug_3051.dia.ref new file mode 100755 index 000000000..463b9597f --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3051.dia.ref @@ -0,0 +1,35 @@ +// ============================================================================= +// 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 3051 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3051 +// +// <-- Short Description --> +// +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +// gethi<Tab> +currentline = 'gethi'; +ref = ['gethistory';'gethistoryfile']; +r = completion(currentline); +if ~and(r == ref) then bugmes();quit;end +if getcommonpart(r) <> 'gethistory' then bugmes();quit;end +cd SCI/contrib/; +//cd toolbo[TAB] +currentline = 'cd toolbo'; +r = getfilepartlevel(currentline); +if r <> 'toolbo' then bugmes();quit;end; +r2 = completion(r,'files'); +if r2 <> 'toolbox_skeleton' + filesep() then bugmes();quit;end +pos = find(r2 == 'toolbox_skeleton'+filesep()); +r = completeline(currentline,r2(pos),getpartlevel(currentline),getfilepartlevel(currentline),%t); +if r <> 'cd toolbox_skeleton' + filesep() then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_3051.tst b/modules/completion/tests/nonreg_tests/bug_3051.tst new file mode 100755 index 000000000..94bcc13e3 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3051.tst @@ -0,0 +1,45 @@ +// ============================================================================= +// 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 3051 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3051 +// +// <-- Short Description --> +// + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +// gethi<Tab> +currentline = 'gethi'; + +ref = ['gethistory';'gethistoryfile']; +r = completion(currentline); +if ~and(r == ref) then pause,end + +if getcommonpart(r) <> 'gethistory' then pause,end + +cd SCI/contrib/; +//cd toolbo[TAB] +currentline = 'cd toolbo'; +r = getfilepartlevel(currentline); +if r <> 'toolbo' then pause,end; + +r2 = completion(r,'files'); +if r2 <> 'toolbox_skeleton' + filesep() then pause,end + +pos = find(r2 == 'toolbox_skeleton'+filesep()); + +r = completeline(currentline,r2(pos),getpartlevel(currentline),getfilepartlevel(currentline),%t); +if r <> 'cd toolbox_skeleton' + filesep() then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_3297.dia.ref b/modules/completion/tests/nonreg_tests/bug_3297.dia.ref new file mode 100755 index 000000000..718826397 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3297.dia.ref @@ -0,0 +1,27 @@ +// ============================================================================= +// 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 3306 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3306 +// +// <-- Short Description --> +// Wildcards should not be interpreted as such in completion, but as literal text. +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +// get*<TAB> +currentline = 'get*'; +r = getpartlevel(currentline); +if r <> '' then bugmes();quit;end +r = getfilepartlevel(currentline); +if r <> '' then bugmes();quit;end +r = completeline(currentline,'',getpartlevel(currentline),getfilepartlevel(currentline),%f); +if r <> currentline then bugmes();quit;end; diff --git a/modules/completion/tests/nonreg_tests/bug_3297.tst b/modules/completion/tests/nonreg_tests/bug_3297.tst new file mode 100755 index 000000000..0e9307edd --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3297.tst @@ -0,0 +1,35 @@ +// ============================================================================= +// 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 3306 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3306 +// +// <-- Short Description --> +// Wildcards should not be interpreted as such in completion, but as literal text. + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +// get*<TAB> +currentline = 'get*'; + +r = getpartlevel(currentline); +if r <> '' then pause,end + +r = getfilepartlevel(currentline); +if r <> '' then pause,end + +r = completeline(currentline,'',getpartlevel(currentline),getfilepartlevel(currentline),%f); +if r <> currentline then pause,end; + diff --git a/modules/completion/tests/nonreg_tests/bug_3306.dia.ref b/modules/completion/tests/nonreg_tests/bug_3306.dia.ref new file mode 100755 index 000000000..2f97e32c6 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3306.dia.ref @@ -0,0 +1,38 @@ +// ============================================================================= +// 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 3306 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3306 +// +// <-- Short Description --> +// Automatic completion swallows the first completed letter when using double quotes (") around a string, while it gives good +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +fd = mopen(TMPDIR+'/foofile.ext','wt'); +mclose(fd); +cd TMPDIR; +//scipad('foof[TAB] +currentline = "scipad(''foof"; +r = getfilepartlevel(currentline); +if r <> 'foof' then bugmes();quit;end; +r = completion(getfilepartlevel(currentline)); +if r <> 'foofile.ext' then bugmes();quit;end +r = completeline(currentline,'foofile.ext',getpartlevel(currentline),getfilepartlevel(currentline),%t); +if r <> 'scipad(''foofile.ext' then bugmes();quit;end; +//scipad("foof[TAB] +currentline = "scipad(""foof"; +r = getfilepartlevel(currentline); +if r <> 'foof' then bugmes();quit;end +r = completion(getfilepartlevel(currentline)); +if r <> 'foofile.ext' then bugmes();quit;end +r = completeline(currentline,'foofile.ext',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'scipad(""foofile.ext' then bugmes();quit;end; diff --git a/modules/completion/tests/nonreg_tests/bug_3306.tst b/modules/completion/tests/nonreg_tests/bug_3306.tst new file mode 100755 index 000000000..91957cdb5 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3306.tst @@ -0,0 +1,53 @@ +// ============================================================================= +// 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 3306 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3306 +// +// <-- Short Description --> +// Automatic completion swallows the first completed letter when using double quotes (") around a string, while it gives good + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +fd = mopen(TMPDIR+'/foofile.ext','wt'); +mclose(fd); + +cd TMPDIR; + +//scipad('foof[TAB] +currentline = "scipad(''foof"; + +r = getfilepartlevel(currentline); +if r <> 'foof' then pause,end; + +r = completion(getfilepartlevel(currentline)); +if r <> 'foofile.ext' then pause,end + +r = completeline(currentline,'foofile.ext',getpartlevel(currentline),getfilepartlevel(currentline),%t); +if r <> 'scipad(''foofile.ext' then pause,end; + +//scipad("foof[TAB] +currentline = "scipad(""foof"; + +r = getfilepartlevel(currentline); +if r <> 'foof' then pause,end + +r = completion(getfilepartlevel(currentline)); +if r <> 'foofile.ext' then pause,end + +r = completeline(currentline,'foofile.ext',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'scipad(""foofile.ext' then pause,end; + +
\ No newline at end of file diff --git a/modules/completion/tests/nonreg_tests/bug_3398.dia.ref b/modules/completion/tests/nonreg_tests/bug_3398.dia.ref new file mode 100755 index 000000000..8a2911e8e --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3398.dia.ref @@ -0,0 +1,27 @@ +// ============================================================================= +// 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 3398 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3398 +// +// <-- Short Description --> +// A bug in the completion: +// it removes the line. It should add it at the end instead instead. +// exec le<TAB> +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'exec le'; +r = getpartlevel(currentline); +if r <> 'le' then bugmes();quit;end +if size(completion(r),'*') == [] then bugmes();quit;end +r = completeline(currentline,'',getpartlevel(currentline),getfilepartlevel(currentline),%f); +if r <> currentline then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_3398.tst b/modules/completion/tests/nonreg_tests/bug_3398.tst new file mode 100755 index 000000000..9d6fa9ecf --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3398.tst @@ -0,0 +1,35 @@ +// ============================================================================= +// 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 3398 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3398 +// +// <-- Short Description --> +// A bug in the completion: +// it removes the line. It should add it at the end instead instead. +// exec le<TAB> + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +currentline = 'exec le'; +r = getpartlevel(currentline); +if r <> 'le' then pause,end + +if size(completion(r),'*') == [] then pause,end + +r = completeline(currentline,'',getpartlevel(currentline),getfilepartlevel(currentline),%f); +if r <> currentline then pause,end + +
\ No newline at end of file diff --git a/modules/completion/tests/nonreg_tests/bug_3399.dia.ref b/modules/completion/tests/nonreg_tests/bug_3399.dia.ref new file mode 100755 index 000000000..746e2cce5 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3399.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// 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 3399 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3399 +// +// <-- Short Description --> +// Completion is eating a character. +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +//cd /h<TAB> +currentline = 'cd /h'; +newline = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd /home' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_3399.tst b/modules/completion/tests/nonreg_tests/bug_3399.tst new file mode 100755 index 000000000..9ac4e3ef7 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3399.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// 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 3399 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3399 +// +// <-- Short Description --> +// Completion is eating a character. + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +//cd /h<TAB> + +currentline = 'cd /h'; +newline = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd /home' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_3681.dia.ref b/modules/completion/tests/nonreg_tests/bug_3681.dia.ref new file mode 100755 index 000000000..083016c94 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3681.dia.ref @@ -0,0 +1,15 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 3681 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3681 +// +// <-- Short Description --> +// Disable automatic completion if there are only spaces in a line +if completion(" ") <> [] then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_3681.tst b/modules/completion/tests/nonreg_tests/bug_3681.tst new file mode 100755 index 000000000..215b5607c --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3681.tst @@ -0,0 +1,18 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 3681 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3681 +// +// <-- Short Description --> +// Disable automatic completion if there are only spaces in a line + +if completion(" ") <> [] then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_3757.dia.ref b/modules/completion/tests/nonreg_tests/bug_3757.dia.ref new file mode 100755 index 000000000..210d352f6 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3757.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// 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 3757 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3757 +// +// <-- Short Description --> +// Under Scilex, the completion of paths is incorrect +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +// cd d:\Pro[TAB] +currentline = 'cd d:\Pro'; +newline = completeline(currentline,'Projects',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd d:\Projects' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_3757.tst b/modules/completion/tests/nonreg_tests/bug_3757.tst new file mode 100755 index 000000000..310a0d8c7 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_3757.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// 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 3757 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=3757 +// +// <-- Short Description --> +// Under Scilex, the completion of paths is incorrect + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + + +// cd d:\Pro[TAB] +currentline = 'cd d:\Pro'; +newline = completeline(currentline,'Projects',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd d:\Projects' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4039.dia.ref b/modules/completion/tests/nonreg_tests/bug_4039.dia.ref new file mode 100755 index 000000000..0263c989a --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4039.dia.ref @@ -0,0 +1,32 @@ +// ============================================================================= +// 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 4039 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4039 +// +// <-- Short Description --> +// Problem of completion with version 5.1: +// (With NW mode). +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +// wavread("/ho[TAB] +currentline = 'wavread(""/ho'; +r = getfilepartlevel(currentline); +if r <> '/ho' then bugmes();quit;end +newline = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'wavread(""/home' then bugmes();quit;end +// wavread("/home/sy[TAB] +currentline = 'wavread(""/home/sy'; +r = getfilepartlevel(currentline); +if r <> '/home/sy' then bugmes();quit;end +newline = completeline(currentline,'sylvestre',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'wavread(""/home/sylvestre' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4039.tst b/modules/completion/tests/nonreg_tests/bug_4039.tst new file mode 100755 index 000000000..1381ca7a0 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4039.tst @@ -0,0 +1,39 @@ +// ============================================================================= +// 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 4039 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4039 +// +// <-- Short Description --> +// Problem of completion with version 5.1: +// (With NW mode). + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +// wavread("/ho[TAB] +currentline = 'wavread(""/ho'; +r = getfilepartlevel(currentline); +if r <> '/ho' then pause,end + +newline = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'wavread(""/home' then pause,end + +// wavread("/home/sy[TAB] +currentline = 'wavread(""/home/sy'; +r = getfilepartlevel(currentline); +if r <> '/home/sy' then pause,end + +newline = completeline(currentline,'sylvestre',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'wavread(""/home/sylvestre' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4067.dia.ref b/modules/completion/tests/nonreg_tests/bug_4067.dia.ref new file mode 100755 index 000000000..c3cd4b211 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4067.dia.ref @@ -0,0 +1,40 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4067 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4067 +// +// <-- Short Description --> +// Completion STD mode. +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +chdir(TMPDIR); +mkdir('bug_4067'); +chdir('bug_4067'); +fd = mopen('bugA.sce','wt'); +mclose(fd); +fd = mopen('bugB.sce','wt'); +mclose(fd); +//exec bug<tab> +currentline = 'exec bug'; +r = getfilepartlevel(currentline); +if r <> 'bug' then bugmes();quit;end +r = completion(getfilepartlevel(currentline),'files'); +if and(gsort(r) <> gsort(['bugA.sce';'bugB.sce'])) then bugmes();quit;end +newline = completeline(currentline,'bugA.sce',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline<>'exec bugA.sce' then bugmes();quit;end +// -->cd /h<TAB> +currentline = 'cd /h'; +r = getfilepartlevel(currentline); +if r <> '/h' then bugmes();quit;end +newline = completeline(currentline,'/home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline<>'cd /home' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4067.tst b/modules/completion/tests/nonreg_tests/bug_4067.tst new file mode 100755 index 000000000..cf3e3348d --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4067.tst @@ -0,0 +1,47 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4067 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4067 +// +// <-- Short Description --> +// Completion STD mode. + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +chdir(TMPDIR); +mkdir('bug_4067'); +chdir('bug_4067'); +fd = mopen('bugA.sce','wt'); +mclose(fd); +fd = mopen('bugB.sce','wt'); +mclose(fd); + +//exec bug<tab> +currentline = 'exec bug'; +r = getfilepartlevel(currentline); +if r <> 'bug' then pause,end +r = completion(getfilepartlevel(currentline),'files'); +if and(gsort(r) <> gsort(['bugA.sce';'bugB.sce'])) then pause,end + +newline = completeline(currentline,'bugA.sce',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline<>'exec bugA.sce' then pause,end + +// -->cd /h<TAB> +currentline = 'cd /h'; +r = getfilepartlevel(currentline); +if r <> '/h' then pause,end +newline = completeline(currentline,'/home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline<>'cd /home' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4095.dia.ref b/modules/completion/tests/nonreg_tests/bug_4095.dia.ref new file mode 100755 index 000000000..e78b70e7e --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4095.dia.ref @@ -0,0 +1,51 @@ +// ============================================================================= +// 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 4095 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4095 +// +// <-- Short Description --> +// Completion delete some characters of the string we are typing (With NW mode). +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +// cd SCI/mod<TAB> +currentline = 'cd SCI/mod'; +r = getfilepartlevel(currentline); +if r <> 'SCI/mod' then bugmes();quit;end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'modules' + filesep() then bugmes();quit;end +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules' + filesep() then bugmes();quit;end +// cd SCI/modules/file<TAB> +currentline = 'cd SCI/modules/file'; +r = getfilepartlevel(currentline); +if r <> 'SCI/modules/file' then bugmes();quit;end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'fileio' + filesep() then bugmes();quit;end +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules/fileio' + filesep() then bugmes();quit;end +// cd SCI/modules/fileio/te<TAB> +currentline = 'cd SCI/modules/fileio/te'; +r = getfilepartlevel(currentline); +if r <> 'SCI/modules/fileio/te' then bugmes();quit;end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'tests' + filesep() then bugmes();quit;end +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules/fileio/tests' + filesep() then bugmes();quit;end +// cd SCI/modules/fileio/tests/u<TAB> +currentline = 'cd SCI/modules/fileio/tests/u'; +r = getfilepartlevel(currentline); +if r <> 'SCI/modules/fileio/tests/u' then bugmes();quit;end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'unit_tests' + filesep() then bugmes();quit;end +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules/fileio/tests/unit_tests' + filesep() then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4095.tst b/modules/completion/tests/nonreg_tests/bug_4095.tst new file mode 100755 index 000000000..850bd39c0 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4095.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 4095 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4095 +// +// <-- Short Description --> +// Completion delete some characters of the string we are typing (With NW mode). + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + + +// cd SCI/mod<TAB> +currentline = 'cd SCI/mod'; +r = getfilepartlevel(currentline); +if r <> 'SCI/mod' then pause,end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'modules' + filesep() then pause,end + +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules' + filesep() then pause,end + +// cd SCI/modules/file<TAB> +currentline = 'cd SCI/modules/file'; +r = getfilepartlevel(currentline); +if r <> 'SCI/modules/file' then pause,end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'fileio' + filesep() then pause,end + +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules/fileio' + filesep() then pause,end + +// cd SCI/modules/fileio/te<TAB> +currentline = 'cd SCI/modules/fileio/te'; +r = getfilepartlevel(currentline); +if r <> 'SCI/modules/fileio/te' then pause,end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'tests' + filesep() then pause,end + +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules/fileio/tests' + filesep() then pause,end + +// cd SCI/modules/fileio/tests/u<TAB> +currentline = 'cd SCI/modules/fileio/tests/u'; +r = getfilepartlevel(currentline); +if r <> 'SCI/modules/fileio/tests/u' then pause,end +r = completion(getfilepartlevel(currentline),'files'); +if r <> 'unit_tests' + filesep() then pause,end + +newline = completeline(currentline,r,getfilepartlevel(currentline),getpartlevel(currentline),%t); +if newline <> 'cd SCI/modules/fileio/tests/unit_tests' + filesep() then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4263.dia.ref b/modules/completion/tests/nonreg_tests/bug_4263.dia.ref new file mode 100755 index 000000000..33dfc1ae0 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4263.dia.ref @@ -0,0 +1,22 @@ +// ============================================================================= +// 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 4263 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4263 +// +// <-- Short Description --> +// completion cleans input line +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'cd d:\Sci'; +r = completeline(currentline,'d:\Scilab5',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd d:\Scilab5' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4263.tst b/modules/completion/tests/nonreg_tests/bug_4263.tst new file mode 100755 index 000000000..9c2e82934 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4263.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// 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 4263 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4263 +// +// <-- Short Description --> +// completion cleans input line +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + + +currentline = 'cd d:\Sci'; +r = completeline(currentline,'d:\Scilab5',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd d:\Scilab5' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4315.dia.ref b/modules/completion/tests/nonreg_tests/bug_4315.dia.ref new file mode 100755 index 000000000..bc7f99be1 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4315.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// 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 4315 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4315 +// +// <-- Short Description --> +// --> completion("",["commands","macros"]) +// it will only returns commands +// <-- CLI SHELL MODE --> +w = ""; +c = ["commands","macros"]; +ierr = execstr("a=completion(w,c);","errcatch"); +if ierr <> 999 then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4315.tst b/modules/completion/tests/nonreg_tests/bug_4315.tst new file mode 100755 index 000000000..6fe6d76dc --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4315.tst @@ -0,0 +1,24 @@ +// ============================================================================= +// 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 4315 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4315 +// +// <-- Short Description --> +// --> completion("",["commands","macros"]) +// it will only returns commands + + +// <-- CLI SHELL MODE --> + +w = ""; +c = ["commands","macros"]; + +ierr = execstr("a=completion(w,c);","errcatch"); +if ierr <> 999 then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4332.dia.ref b/modules/completion/tests/nonreg_tests/bug_4332.dia.ref new file mode 100755 index 000000000..66f5f8df4 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4332.dia.ref @@ -0,0 +1,28 @@ +// ============================================================================= +// 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 4332 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4332 +// +// <-- Short Description --> +// completion copies selected item instead of completing according to this one. +// <-- ENGLISH IMPOSED --> +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +// You choose thermaSnap.img +currentline = 'scipad thermaSnap.'; +r = completeline(currentline,'thermaSnap.img',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'scipad thermaSnap.img' then bugmes();quit;end +// You choose thermaSnap.sce +currentline = 'scipad thermaSnap.'; +r = completeline(currentline,'thermaSnap.sce',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'scipad thermaSnap.sce' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4332.tst b/modules/completion/tests/nonreg_tests/bug_4332.tst new file mode 100755 index 000000000..02d18679a --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4332.tst @@ -0,0 +1,34 @@ +// ============================================================================= +// 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 4332 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4332 +// +// <-- Short Description --> +// completion copies selected item instead of completing according to this one. + + +// <-- ENGLISH IMPOSED --> +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +// You choose thermaSnap.img +currentline = 'scipad thermaSnap.'; +r = completeline(currentline,'thermaSnap.img',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'scipad thermaSnap.img' then pause,end + +// You choose thermaSnap.sce +currentline = 'scipad thermaSnap.'; +r = completeline(currentline,'thermaSnap.sce',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'scipad thermaSnap.sce' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4365.dia.ref b/modules/completion/tests/nonreg_tests/bug_4365.dia.ref new file mode 100755 index 000000000..7f63fe3b8 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4365.dia.ref @@ -0,0 +1,47 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4365 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4365 +// +// <-- Short Description --> +// completion fails and returns a bad value if we try to use it on a path that doesn't exist +// cd SCI/modules/arnoldi/nonreg_tes[TAB] +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'cd SCI/modules/arnoldi/nonreg_tes'; +r = completeline(currentline,'nonreg_test_run',getfilepartlevel(currentline),getpartlevel(currentline),%f); +if r <> currentline then bugmes();quit;end +currentline = 'cd modules/arnoldi/src/c'; +r = completeline(currentline,'c/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd modules/arnoldi/src/c/' then bugmes();quit;end +currentline = 'cd reposit'; +r = completeline(currentline,'repositories/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/' then bugmes();quit;end +currentline = 'cd repositories/'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then bugmes();quit;end +currentline = 'cd repositories/to'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then bugmes();quit;end +currentline = 'cd repositories/tooboxes_google'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then bugmes();quit;end +currentline = 'cd repositories/tooboxes_google/sci'; +r = completeline(currentline,'scicoinor/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/scicoinor/' then bugmes();quit;end +currentline = 'cd repositories/tooboxes_google/scicoinor/sci'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/scicoinor/sci_gateway/' then bugmes();quit;end +currentline = 'cd repositories/tooboxes_google/scicoinor/'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/scicoinor/sci_gateway/' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4365.tst b/modules/completion/tests/nonreg_tests/bug_4365.tst new file mode 100755 index 000000000..fb949961c --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4365.tst @@ -0,0 +1,60 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4365 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4365 +// +// <-- Short Description --> +// completion fails and returns a bad value if we try to use it on a path that doesn't exist +// cd SCI/modules/arnoldi/nonreg_tes[TAB] + + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +currentline = 'cd SCI/modules/arnoldi/nonreg_tes'; +r = completeline(currentline,'nonreg_test_run',getfilepartlevel(currentline),getpartlevel(currentline),%f); +if r <> currentline then pause,end + +currentline = 'cd modules/arnoldi/src/c'; +r = completeline(currentline,'c/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd modules/arnoldi/src/c/' then pause,end + +currentline = 'cd reposit'; +r = completeline(currentline,'repositories/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/' then pause,end + +currentline = 'cd repositories/'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then pause,end + +currentline = 'cd repositories/to'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then pause,end + +currentline = 'cd repositories/tooboxes_google'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then pause,end + +currentline = 'cd repositories/tooboxes_google/sci'; +r = completeline(currentline,'scicoinor/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/scicoinor/' then pause,end + +currentline = 'cd repositories/tooboxes_google/scicoinor/sci'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/scicoinor/sci_gateway/' then pause,end + +currentline = 'cd repositories/tooboxes_google/scicoinor/'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/scicoinor/sci_gateway/' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4421.dia.ref b/modules/completion/tests/nonreg_tests/bug_4421.dia.ref new file mode 100755 index 000000000..b316b05ea --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4421.dia.ref @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4421 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4421 +// +// <-- Short Description --> +// bug with the completion +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +cd TMPDIR; +mkdir('scicoinor'); +mkdir('dir1'); +cd (TMPDIR+'/dir1'); +mkdir('dir2'); +cd (TMPDIR+'/dir1/dir2'); +currentline = 'cd ../../scicoi'; +r = completeline(currentline,'scicoinor',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd ../../scicoinor' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4421.tst b/modules/completion/tests/nonreg_tests/bug_4421.tst new file mode 100755 index 000000000..67f6a7363 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4421.tst @@ -0,0 +1,33 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4421 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4421 +// +// <-- Short Description --> +// bug with the completion + + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +cd TMPDIR; +mkdir('scicoinor'); +mkdir('dir1'); +cd (TMPDIR+'/dir1'); +mkdir('dir2'); +cd (TMPDIR+'/dir1/dir2'); +currentline = 'cd ../../scicoi'; +r = completeline(currentline,'scicoinor',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd ../../scicoinor' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4438.dia.ref b/modules/completion/tests/nonreg_tests/bug_4438.dia.ref new file mode 100755 index 000000000..0fa67b5f4 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4438.dia.ref @@ -0,0 +1,23 @@ +// ============================================================================= +// 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 4838 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4838 +// +// <-- Short Description --> +// bug in the completion (insertion) +// load(SCIH[TAB]/macros) +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'load(SCIH'; +r = completeline(currentline,'SCIHOME',getfilepartlevel(currentline),getpartlevel(currentline),%t,'/modules)'); +if r <> 'load(SCIHOME/modules)' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4438.tst b/modules/completion/tests/nonreg_tests/bug_4438.tst new file mode 100755 index 000000000..9f730c2cb --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4438.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// 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 4838 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4838 +// +// <-- Short Description --> +// bug in the completion (insertion) +// load(SCIH[TAB]/macros) + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + + +currentline = 'load(SCIH'; +r = completeline(currentline,'SCIHOME',getfilepartlevel(currentline),getpartlevel(currentline),%t,'/modules)'); +if r <> 'load(SCIHOME/modules)' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4626.dia.ref b/modules/completion/tests/nonreg_tests/bug_4626.dia.ref new file mode 100755 index 000000000..332a20e9e --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4626.dia.ref @@ -0,0 +1,17 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4626 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4626 +// +// <-- Short Description --> +// +// when using the CLI version (NO GRAPHICS), the autocompletion feature make Scilab crash +// <-- CLI SHELL MODE --> +r = completion('a','graphic_properties'); +if ~isdef('r') then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4626.tst b/modules/completion/tests/nonreg_tests/bug_4626.tst new file mode 100755 index 000000000..c906e02cd --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4626.tst @@ -0,0 +1,20 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4626 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4626 +// +// <-- Short Description --> +// +// when using the CLI version (NO GRAPHICS), the autocompletion feature make Scilab crash + + +// <-- CLI SHELL MODE --> +r = completion('a','graphic_properties'); +if ~isdef('r') then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4737.dia.ref b/modules/completion/tests/nonreg_tests/bug_4737.dia.ref new file mode 100755 index 000000000..0c337cbe5 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4737.dia.ref @@ -0,0 +1,31 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- Non-regression test for bug 4737 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4737 +// +// <-- Short Description --> +// bug with the completion +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +cd TMPDIR; +mkdir('modules'); +cd (TMPDIR+'/modules'); +mkdir('string'); +cd (TMPDIR+'/modules/string'); +mkdir('macros'); +cd (TMPDIR+'/modules/string/macros'); +mputl('TEST',TMPDIR+'/modules/string/macros/finddeps.sci'); +cd TMPDIR; +currentline = 'ls modules/string/macros/finddeps.'; +r = completeline(currentline,'finddeps.sci',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'ls modules/string/macros/finddeps.sci' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4737.tst b/modules/completion/tests/nonreg_tests/bug_4737.tst new file mode 100755 index 000000000..d4640bed0 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4737.tst @@ -0,0 +1,36 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 4737 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4737 +// +// <-- Short Description --> +// bug with the completion + + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +cd TMPDIR; +mkdir('modules'); +cd (TMPDIR+'/modules'); +mkdir('string'); +cd (TMPDIR+'/modules/string'); +mkdir('macros'); +cd (TMPDIR+'/modules/string/macros'); +mputl('TEST',TMPDIR+'/modules/string/macros/finddeps.sci'); +cd TMPDIR; +currentline = 'ls modules/string/macros/finddeps.'; +r = completeline(currentline,'finddeps.sci',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'ls modules/string/macros/finddeps.sci' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_4838.dia.ref b/modules/completion/tests/nonreg_tests/bug_4838.dia.ref new file mode 100755 index 000000000..f85dff1be --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4838.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// 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 4838 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4838 +// +// <-- Short Description --> +// completion returns wrong value with '..' +// cd SCI/modules +// cd ../et[tab] +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'cd ../et'; +r = completeline(currentline,'etc/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd ../etc/' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_4838.tst b/modules/completion/tests/nonreg_tests/bug_4838.tst new file mode 100755 index 000000000..b26822fba --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_4838.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// 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 4838 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=4838 +// +// <-- Short Description --> +// completion returns wrong value with '..' +// cd SCI/modules +// cd ../et[tab] + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + + +currentline = 'cd ../et'; +r = completeline(currentline,'etc/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd ../etc/' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_5105.dia.ref b/modules/completion/tests/nonreg_tests/bug_5105.dia.ref new file mode 100755 index 000000000..0f700a2a9 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_5105.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// 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 5105 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5105 +// +// <-- Short Description --> +// completion: cd "..\L<tab> does not work +// +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'cd ""../et'; +if getfilepartlevel(currentline) <> '../et' then bugmes();quit;end +r = completeline(currentline,'etc/', getfilepartlevel(currentline), getpartlevel(currentline), %t); +if r <> 'cd ""../etc/' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_5105.tst b/modules/completion/tests/nonreg_tests/bug_5105.tst new file mode 100755 index 000000000..97dd4cbd1 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_5105.tst @@ -0,0 +1,29 @@ +// ============================================================================= +// 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 5105 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=5105 +// +// <-- Short Description --> +// completion: cd "..\L<tab> does not work +// + + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +currentline = 'cd ""../et'; +if getfilepartlevel(currentline) <> '../et' then pause,end +r = completeline(currentline,'etc/', getfilepartlevel(currentline), getpartlevel(currentline), %t); +if r <> 'cd ""../etc/' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_6320.dia.ref b/modules/completion/tests/nonreg_tests/bug_6320.dia.ref new file mode 100755 index 000000000..7f92d0ace --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_6320.dia.ref @@ -0,0 +1,19 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +/// <-- Non-regression test for bug 6320 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6320 +// +// <-- Short Description --> +// completion should be case insensitive +// <-- CLI SHELL MODE --> +createNode = 1; +r = completion('createn'); +assert_checkequal(r, 'createNode'); +r = completion('CREATEN'); +assert_checkequal(r, 'createNode'); diff --git a/modules/completion/tests/nonreg_tests/bug_6320.tst b/modules/completion/tests/nonreg_tests/bug_6320.tst new file mode 100755 index 000000000..4388ec677 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_6320.tst @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2012 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- Non-regression test for bug 6320 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6320 +// +// <-- Short Description --> +// completion should be case insensitive + +// <-- CLI SHELL MODE --> + +createNode = 1; + +r = completion('createn'); +assert_checkequal(r, 'createNode'); + +r = completion('CREATEN'); +assert_checkequal(r, 'createNode'); diff --git a/modules/completion/tests/nonreg_tests/bug_6739.dia.ref b/modules/completion/tests/nonreg_tests/bug_6739.dia.ref new file mode 100755 index 000000000..a40c6e7af --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_6739.dia.ref @@ -0,0 +1,30 @@ +// ============================================================================= +// 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. +// ============================================================================= +// <-- Non-regression test for bug 6739 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6739 +// +// <-- Short Description --> +// if a Scilab coded library function is redefined in a new library, completion +// on its name maked Scilab crashed +// +// <-- CLI SHELL MODE --> +mkdir(TMPDIR,'test'); +m=['function y = acosd(x)' +' r=180/%pi ' +' y = r*acos(x);' +'endfunction']; +mputl(m,TMPDIR+'/test/acosd.sci'); +genlib('testlib',TMPDIR+'/test/'); +acosd(3); //ok +[a,b,c,d,e]=completion('ac'); +if a <> 'acos' then bugmes();quit;end +if b <> [] then bugmes();quit;end +if c <> [] then bugmes();quit;end +if d == [] then bugmes();quit;end +if e <> [] then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_6739.tst b/modules/completion/tests/nonreg_tests/bug_6739.tst new file mode 100755 index 000000000..6870c1fe5 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_6739.tst @@ -0,0 +1,36 @@ +// ============================================================================= +// 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. +// ============================================================================= + +// <-- Non-regression test for bug 6739 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6739 +// +// <-- Short Description --> +// if a Scilab coded library function is redefined in a new library, completion +// on its name maked Scilab crashed +// + + +// <-- CLI SHELL MODE --> + +mkdir(TMPDIR,'test'); +m=['function y = acosd(x)' +' r=180/%pi ' +' y = r*acos(x);' +'endfunction']; +mputl(m,TMPDIR+'/test/acosd.sci'); +genlib('testlib',TMPDIR+'/test/'); + +acosd(3); //ok + +[a,b,c,d,e]=completion('ac'); +if a <> 'acos' then pause,end +if b <> [] then pause,end +if c <> [] then pause,end +if d == [] then pause,end +if e <> [] then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_6751.dia.ref b/modules/completion/tests/nonreg_tests/bug_6751.dia.ref new file mode 100755 index 000000000..0eb3618e1 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_6751.dia.ref @@ -0,0 +1,37 @@ +// ============================================================================= +// 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 6751 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6751 +// +// <-- Short Description --> +// A completion bug: +// mkdir -p cudascilab/sci_gateway cudascilab/src +// scilab -nwni +// exec cudascilab/[TAB]s[TAB]c[TAB] +// shows cudascilab/ssci_gateway/ +// instead of +// cudascilab/sci_gateway/ +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +currentline = 'cd cudascilab/sc'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd cudascilab/sci_gateway/' then bugmes();quit;end +currentline = 'cd cudascilab/sc'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd cudascilab/sci_gateway/' then bugmes();quit;end +currentline = 'cd repositories/'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then bugmes();quit;end +currentline = 'cd ~/scilab/'; +r = completeline(currentline,'scilab/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd ~/scilab/scilab/' then bugmes();quit;end diff --git a/modules/completion/tests/nonreg_tests/bug_6751.tst b/modules/completion/tests/nonreg_tests/bug_6751.tst new file mode 100755 index 000000000..72a5cf614 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_6751.tst @@ -0,0 +1,46 @@ +// ============================================================================= +// 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 6751 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=6751 +// +// <-- Short Description --> +// A completion bug: +// mkdir -p cudascilab/sci_gateway cudascilab/src +// scilab -nwni +// exec cudascilab/[TAB]s[TAB]c[TAB] +// shows cudascilab/ssci_gateway/ +// instead of +// cudascilab/sci_gateway/ + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + + +currentline = 'cd cudascilab/sc'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd cudascilab/sci_gateway/' then pause,end + + +currentline = 'cd cudascilab/sc'; +r = completeline(currentline,'sci_gateway/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd cudascilab/sci_gateway/' then pause,end + +currentline = 'cd repositories/'; +r = completeline(currentline,'tooboxes_google/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd repositories/tooboxes_google/' then pause,end + +currentline = 'cd ~/scilab/'; +r = completeline(currentline,'scilab/',getfilepartlevel(currentline),getpartlevel(currentline),%t); +if r <> 'cd ~/scilab/scilab/' then pause,end diff --git a/modules/completion/tests/nonreg_tests/bug_7123.dia.ref b/modules/completion/tests/nonreg_tests/bug_7123.dia.ref new file mode 100755 index 000000000..48b25bb0a --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_7123.dia.ref @@ -0,0 +1,44 @@ +// ============================================================================= +// 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 7123 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7123 +// +// <-- Short Description --> +// No completion was possible if the name of a variable is preceded by ~ or @ or < or > +// +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr <> 0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr <> 0 then bugmes();quit;end +blahblah = %t; +ref = 'blahbl'; +r = getpartlevel('if ~blahbl'); +if r <> ref then bugmes();quit;end; +r = getpartlevel('if @blahbl'); +if r <> ref then bugmes();quit;end; +r = getpartlevel('if %t==blahbl'); +if r <> ref then bugmes();quit;end; +r = getpartlevel('if %t == blahbl'); +if r <> ref then bugmes();quit;end; +blahblah = 3; +r = getpartlevel('if 2>blahbl'); +if r <> ref then bugmes();quit;end; +r = getpartlevel('if 2 > blahbl'); +if r <> ref then bugmes();quit;end; +r = getpartlevel('if 2<blahbl'); +if r <> ref then bugmes();quit;end; +r = getpartlevel('if 2 < blahbl'); +if r <> ref then bugmes();quit;end; +// tabulation used in editor not in console +r = getpartlevel(ascii(9) + 'blahbl'); +if r <> ref then bugmes();quit;end; diff --git a/modules/completion/tests/nonreg_tests/bug_7123.tst b/modules/completion/tests/nonreg_tests/bug_7123.tst new file mode 100755 index 000000000..cdd230fb0 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_7123.tst @@ -0,0 +1,56 @@ +// ============================================================================= +// 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 7123 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=7123 +// +// <-- Short Description --> +// No completion was possible if the name of a variable is preceded by ~ or @ or < or > +// + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr <> 0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr <> 0 then pause, end + +blahblah = %t; +ref = 'blahbl'; + +r = getpartlevel('if ~blahbl'); +if r <> ref then pause, end; + +r = getpartlevel('if @blahbl'); +if r <> ref then pause, end; + +r = getpartlevel('if %t==blahbl'); +if r <> ref then pause, end; + +r = getpartlevel('if %t == blahbl'); +if r <> ref then pause, end; + +blahblah = 3; + +r = getpartlevel('if 2>blahbl'); +if r <> ref then pause, end; + +r = getpartlevel('if 2 > blahbl'); +if r <> ref then pause,end; + +r = getpartlevel('if 2<blahbl'); +if r <> ref then pause,end; + +r = getpartlevel('if 2 < blahbl'); +if r <> ref then pause,end; + +// tabulation used in editor not in console +r = getpartlevel(ascii(9) + 'blahbl'); +if r <> ref then pause,end; diff --git a/modules/completion/tests/nonreg_tests/bug_9300.dia.ref b/modules/completion/tests/nonreg_tests/bug_9300.dia.ref new file mode 100755 index 000000000..72a21582c --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_9300.dia.ref @@ -0,0 +1,34 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9300 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/9300 +// +// <-- Short Description --> +// Crash when try to complete a mlist without fields +// +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr <> 0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr <> 0 then bugmes();quit;end +a = mlist(['V']); +if getfields('a.') <> '' then bugmes();quit;end; +a = tlist(['V']); +if getfields('a.') <> '' then bugmes();quit;end; +a = struct(); +if getfields('a.') <> '' then bugmes();quit;end; +a = mlist(['V' 'f']); +if getfields('a.') <> 'f' then bugmes();quit;end; +a = tlist(['V' 'f']); +if getfields('a.') <> 'f' then bugmes();quit;end; +a = struct('f', 'v'); +if getfields('a.') <> 'f' then bugmes();quit;end; diff --git a/modules/completion/tests/nonreg_tests/bug_9300.tst b/modules/completion/tests/nonreg_tests/bug_9300.tst new file mode 100755 index 000000000..9de6ffa12 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_9300.tst @@ -0,0 +1,41 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9300 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/9300 +// +// <-- Short Description --> +// Crash when try to complete a mlist without fields +// + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr <> 0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr <> 0 then pause, end + +a = mlist(['V']); +if getfields('a.') <> '' then pause, end; + +a = tlist(['V']); +if getfields('a.') <> '' then pause, end; + +a = struct(); +if getfields('a.') <> '' then pause, end; + +a = mlist(['V' 'f']); +if getfields('a.') <> 'f' then pause, end; + +a = tlist(['V' 'f']); +if getfields('a.') <> 'f' then pause, end; + +a = struct('f', 'v'); +if getfields('a.') <> 'f' then pause, end; diff --git a/modules/completion/tests/nonreg_tests/bug_9755.dia.ref b/modules/completion/tests/nonreg_tests/bug_9755.dia.ref new file mode 100755 index 000000000..72f5cf2c9 --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_9755.dia.ref @@ -0,0 +1,30 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9755 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/9755 +// +// <-- Short Description --> +// Completion on paths was not case insensitive on Windows +// +if getos() == 'Windows' then + ilib_verbose(0); + ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); + if ierr <> 0 then bugmes();quit;end + ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); + if ierr <> 0 then bugmes();quit;end + currentline = 'cd c:/u'; + r = completeline(currentline,'Users',getfilepartlevel(currentline),getpartlevel(currentline),%t); + if r <> 'cd c:/Users' then bugmes();quit;end + currentline = 'cd c:/programs Files/f'; + r = completeline(currentline,'Fichiers',getfilepartlevel(currentline),getpartlevel(currentline),%t); + if r <> 'cd c:/programs Files/Fichiers' then bugmes();quit;end +end diff --git a/modules/completion/tests/nonreg_tests/bug_9755.tst b/modules/completion/tests/nonreg_tests/bug_9755.tst new file mode 100755 index 000000000..bc57639ac --- /dev/null +++ b/modules/completion/tests/nonreg_tests/bug_9755.tst @@ -0,0 +1,33 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2011 - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 9755 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/9755 +// +// <-- Short Description --> +// Completion on paths was not case insensitive on Windows +// + +if getos() == 'Windows' then + ilib_verbose(0); + ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); + if ierr <> 0 then pause, end + ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); + if ierr <> 0 then pause, end + + currentline = 'cd c:/u'; + r = completeline(currentline,'Users',getfilepartlevel(currentline),getpartlevel(currentline),%t); + if r <> 'cd c:/Users' then pause,end + + currentline = 'cd c:/programs Files/f'; + r = completeline(currentline,'Fichiers',getfilepartlevel(currentline),getpartlevel(currentline),%t); + if r <> 'cd c:/programs Files/Fichiers' then pause,end +end diff --git a/modules/completion/tests/unit_tests/completeline.dia.ref b/modules/completion/tests/unit_tests/completeline.dia.ref new file mode 100755 index 000000000..b16eb1716 --- /dev/null +++ b/modules/completion/tests/unit_tests/completeline.dia.ref @@ -0,0 +1,80 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +ilib_verbose(0); +exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +currentline = 'cd /t'; +r = completeline(currentline,'/tmp',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /tmp'); +currentline = 'cd /T'; +r = completeline(currentline,'/tmp',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /tmp'); +r = completeline('cd /home/sy','sylvestre',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /home/sylvestre'); +r = completeline('cd /home/sci','Scilab',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /home/Scilab'); +r = completeline('cd d:\GIT-scilab-','d:\GIT-scilab-branch',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd d:\GIT-scilab-branch'); +currentline = 'cd C:\ProgramD'; +r = completeline(currentline,'ProgramData',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\ProgramData'); +currentline = 'cd C:\programd'; +r = completeline(currentline,'ProgramData',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\ProgramData'); +currentline = 'cd C:\Program F'; +r = completeline(currentline,'Program Files',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Program Files'); +currentline = 'cd C:\program f'; +r = completeline(currentline,'Program Files',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Program Files'); +currentline = 'cd C:\Windows\Sys'; +r = completeline(currentline,'System32',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Windows\System32'); +currentline = 'cd C:\Windows\sys'; +r = completeline(currentline,'System32',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Windows\System32'); +currentline = 'ho'; +r = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'home'); +currentline = 'HO'; +r = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'home'); +currentline = 'tmp'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'TMPDIR'); +currentline = 'Tmp'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'TMPDIR'); +currentline = 'disp(TMP'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'disp(TMPDIR'); +currentline = '1 + ab'; +r = completeline(currentline,'abs',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, '1 + abs'); +currentline = '1 + AB'; +r = completeline(currentline,'abs',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, '1 + abs'); +currentline = 'tmpStr = ""TMP = "" + TMP'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'tmpStr = ""TMP = "" + TMPDIR'); +currentline = 'mytab = ab'; +r = completeline(currentline,'abs',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'mytab = abs'); +currentline = 't.fie'; +r = completeline(currentline,'field1',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 't.field1'); +currentline = 't.field1 = t.fie'; +r = completeline(currentline,'field2',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 't.field1 = t.field2'); +currentline = 'totoa'; +r = completeline(currentline,'toto',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'toto'); +currentline = 'totototoa'; +r = completeline(currentline,'toto',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'toto'); diff --git a/modules/completion/tests/unit_tests/completeline.tst b/modules/completion/tests/unit_tests/completeline.tst new file mode 100755 index 000000000..634c6aea7 --- /dev/null +++ b/modules/completion/tests/unit_tests/completeline.tst @@ -0,0 +1,106 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +exec(TMPDIR + "/completion/loader.sce","errcatch",-1); + +currentline = 'cd /t'; +r = completeline(currentline,'/tmp',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /tmp'); + +currentline = 'cd /T'; +r = completeline(currentline,'/tmp',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /tmp'); + +r = completeline('cd /home/sy','sylvestre',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /home/sylvestre'); + +r = completeline('cd /home/sci','Scilab',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'cd /home/Scilab'); + +r = completeline('cd d:\GIT-scilab-','d:\GIT-scilab-branch',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd d:\GIT-scilab-branch'); + +currentline = 'cd C:\ProgramD'; +r = completeline(currentline,'ProgramData',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\ProgramData'); + +currentline = 'cd C:\programd'; +r = completeline(currentline,'ProgramData',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\ProgramData'); + +currentline = 'cd C:\Program F'; +r = completeline(currentline,'Program Files',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Program Files'); + +currentline = 'cd C:\program f'; +r = completeline(currentline,'Program Files',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Program Files'); + +currentline = 'cd C:\Windows\Sys'; +r = completeline(currentline,'System32',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Windows\System32'); + +currentline = 'cd C:\Windows\sys'; +r = completeline(currentline,'System32',getpartlevel(currentline),getfilepartlevel(currentline),%t); +assert_checkequal(r, 'cd C:\Windows\System32'); + +currentline = 'ho'; +r = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'home'); + +currentline = 'HO'; +r = completeline(currentline,'home',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'home'); + +currentline = 'tmp'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'TMPDIR'); + +currentline = 'Tmp'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'TMPDIR'); + +currentline = 'disp(TMP'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'disp(TMPDIR'); + +currentline = '1 + ab'; +r = completeline(currentline,'abs',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, '1 + abs'); + +currentline = '1 + AB'; +r = completeline(currentline,'abs',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, '1 + abs'); + +currentline = 'tmpStr = ""TMP = "" + TMP'; +r = completeline(currentline,'TMPDIR',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'tmpStr = ""TMP = "" + TMPDIR'); + +currentline = 'mytab = ab'; +r = completeline(currentline,'abs',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'mytab = abs'); + +currentline = 't.fie'; +r = completeline(currentline,'field1',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 't.field1'); + +currentline = 't.field1 = t.fie'; +r = completeline(currentline,'field2',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 't.field1 = t.field2'); + +currentline = 'totoa'; +r = completeline(currentline,'toto',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'toto'); + +currentline = 'totototoa'; +r = completeline(currentline,'toto',getfilepartlevel(currentline),getpartlevel(currentline),%t); +assert_checkequal(r, 'toto'); diff --git a/modules/completion/tests/unit_tests/completion.dia.ref b/modules/completion/tests/unit_tests/completion.dia.ref new file mode 100755 index 000000000..9143214e6 --- /dev/null +++ b/modules/completion/tests/unit_tests/completion.dia.ref @@ -0,0 +1,146 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +//=============================== +// unit tests completion +//=============================== +function [] = check_completion(actual, expected) + for i = 1 : size(actual, 'r') + [start,end,match] = regexp(actual(i,1), '/(?i)^(' + expected + ')/'); + assert_checktrue(match <> ''); + end +endfunction +// File paths +if (getos() == "Windows") then + r = completion('C:\Documents and'); + assert_checkequal(r, 'Documents and Settings\'); + r = completion('c:\documents And'); + assert_checkequal(r, 'Documents and Settings\'); +else + r = completion('/tm'); + assert_checkequal(r, 'tmp/'); + r = completion('/TM'); + // We are still case sensitive + assert_checkequal(r, []); +end +r = completion(SCI+'/to'); +r2 = completion(SCI+'/TO'); +if (getos() == "Windows") then + assert_checkequal(r, ['tools\']); + assert_checkequal(r2, ['tools\']); +else + assert_checkequal(r, ['tools/']); + assert_checkequal(r2, []); +end +// Predefined variables +r = completion('ho', 'variables'); +check_completion(r, 'home'); +r = completion('HO', 'variables'); +check_completion(r, 'home'); +r = completion('%na'); +check_completion(r, '%nan'); +r = completion('%Na'); +check_completion(r, '%nan'); +r = completion('tmp'); +check_completion(r, 'TMPDIR'); +r = completion('Tmp'); +check_completion(r, 'TMPDIR'); +r = completion('%', 'variables'); +rexpected = ['%F'; '%T'; '%e'; '%eps'; '%f'; '%fftw'; '%gui'; '%i';'%inf'; '%io'; + '%modalWarning'; '%nan'; '%pi'; '%s'; '%t'; '%tk'; '%toolboxes'; '%toolboxes_dir'; '%z']; +assert_checkequal(r, rexpected); +// User variables +variable1_completion1 = 1; +variable1_completion2 = 2; +r = completion('variable1_comp'); +assert_checkequal(r, ['variable1_completion1'; 'variable1_completion2']); +r = completion('VARIABLE1_COMP'); +assert_checkequal(r, ['variable1_completion1'; 'variable1_completion2']); +variable2_completion = 1; +VARIABLE2_COMPLETION = 2; +r = completion('variable2_comp'); +assert_checkequal(r, ['VARIABLE2_COMPLETION'; 'variable2_completion']); +r = completion('VARIABLE2_COMP'); +assert_checkequal(r, ['VARIABLE2_COMPLETION'; 'variable2_completion']); +// Predefined functions, macros and commands +r = completion('floo'); +check_completion(r, 'floor'); +r = completion('FLOO'); +check_completion(r, 'floor'); +r = completion('abort'); +check_completion(r, 'abort'); +r = completion('Abort'); +check_completion(r, 'abort'); +// User functions, macros, commands +function [] = function_completion(x); +endfunction; +r = completion('function_comp'); +assert_checkequal(r, 'function_completion'); +r = completion('FUNCTION_COMP'); +assert_checkequal(r, 'function_completion'); +function [] = FUNCTION_COMPLETION(x); +endfunction; +r = completion('function_comp'); +assert_checkequal(r, ['FUNCTION_COMPLETION'; 'function_completion']); +r = completion('FUNCTION_COMP'); +assert_checkequal(r, ['FUNCTION_COMPLETION'; 'function_completion']); +// Filter argument +r = completion('ho'); +assert_checkequal(r, ['home'; 'horizontalalignment'; 'horner'; 'host'; 'hotcolormap'; 'householder']); +r = completion('ho', 'functions'); +assert_checkequal(r, 'host'); +r = completion('ho', 'commands'); +assert_checkequal(r, []); +r = completion('ho', 'macros'); +assert_checkequal(r, ['horner'; 'hotcolormap'; 'householder']); +r = completion('ho', 'variables'); +assert_checkequal(r, 'home'); +r = completion('ho', 'graphic_properties'); +assert_checkequal(r, 'horizontalalignment'); +r = completion('ho', 'files'); +assert_checkequal(r, []); +r = completion('abo'); +assert_checkequal(r, ['abort'; 'about']); +r = completion('abo', 'functions'); +assert_checkequal(r, 'about'); +r = completion('abo', 'commands'); +assert_checkequal(r, 'abort'); +r = completion('abo', 'variables'); +assert_checkequal(r, []); +r = completion('abo', 'macros'); +assert_checkequal(r, []); +r = completion('abo', 'graphic_properties'); +assert_checkequal(r, []); +r = completion('abo', 'files'); +assert_checkequal(r, []); +// Output arguments +[functions,commands,variables,macros,graphic_properties,files] = completion('ho'); +assert_checkequal(functions, ['host']); +assert_checkequal(commands, []); +assert_checkequal(variables, ['home']); +assert_checkequal(macros, ['horner'; 'hotcolormap'; 'householder']); +assert_checkequal(graphic_properties, ['horizontalalignment']); +assert_checkequal(files, []); +[functions,commands,variables,macros,graphic_properties,files] = completion('abo'); +assert_checkequal(functions, ['about']); +assert_checkequal(commands, ['abort']); +assert_checkequal(variables, []); +assert_checkequal(macros, []); +assert_checkequal(graphic_properties, []); +assert_checkequal(files, []); +if (getos() == "Windows") then; + [functions,commands,variables,macros,graphic_properties,files] = completion('C:\Documents and'); + assert_checkequal(files, ['Documents and Settings\']); +else + [functions,commands,variables,macros,graphic_properties,files] = completion('/tm'); + assert_checkequal(files, ['tmp/']); +end +assert_checkerror("completion(2)",[], 999); +assert_checkerror("completion([''aze'',''bze''])",[], 999); +assert_checkerror("completion(''a'',''foo'')",[], 999); +assert_checkerror("completion(''a'',2)",[], 999); +assert_checkerror("[aazeaz,azeza,e,aze,azea,zazeaze,azeaze,azeze,aze,azeaz]=completion(""aaze"")",[],78); diff --git a/modules/completion/tests/unit_tests/completion.tst b/modules/completion/tests/unit_tests/completion.tst new file mode 100755 index 000000000..e5041a811 --- /dev/null +++ b/modules/completion/tests/unit_tests/completion.tst @@ -0,0 +1,199 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2007-2008 - INRIA +// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +//=============================== +// unit tests completion +//=============================== + +function [] = check_completion(actual, expected) + for i = 1 : size(actual, 'r') + [start,end,match] = regexp(actual(i,1), '/(?i)^(' + expected + ')/'); + assert_checktrue(match <> ''); + end +endfunction + +// File paths + +if (getos() == "Windows") then + r = completion('C:\Documents and'); + assert_checkequal(r, 'Documents and Settings\'); + + r = completion('c:\documents And'); + assert_checkequal(r, 'Documents and Settings\'); +else + r = completion('/tm'); + assert_checkequal(r, 'tmp/'); + + r = completion('/TM'); + // We are still case sensitive + assert_checkequal(r, []); +end + +r = completion(SCI+'/to'); +r2 = completion(SCI+'/TO'); +if (getos() == "Windows") then + assert_checkequal(r, ['tools\']); + assert_checkequal(r2, ['tools\']); +else + assert_checkequal(r, ['tools/']); + assert_checkequal(r2, []); +end + + +// Predefined variables + +r = completion('ho', 'variables'); +check_completion(r, 'home'); + +r = completion('HO', 'variables'); +check_completion(r, 'home'); + +r = completion('%na'); +check_completion(r, '%nan'); + +r = completion('%Na'); +check_completion(r, '%nan'); + +r = completion('tmp'); +check_completion(r, 'TMPDIR'); + +r = completion('Tmp'); +check_completion(r, 'TMPDIR'); + +r = completion('%', 'variables'); +rexpected = ['%F'; '%T'; '%e'; '%eps'; '%f'; '%fftw'; '%gui'; '%i';'%inf'; '%io'; + '%modalWarning'; '%nan'; '%pi'; '%s'; '%t'; '%tk'; '%toolboxes'; '%toolboxes_dir'; '%z']; +assert_checkequal(r, rexpected); + + +// User variables + +variable1_completion1 = 1; +variable1_completion2 = 2; +r = completion('variable1_comp'); +assert_checkequal(r, ['variable1_completion1'; 'variable1_completion2']); +r = completion('VARIABLE1_COMP'); +assert_checkequal(r, ['variable1_completion1'; 'variable1_completion2']); + +variable2_completion = 1; +VARIABLE2_COMPLETION = 2; +r = completion('variable2_comp'); +assert_checkequal(r, ['VARIABLE2_COMPLETION'; 'variable2_completion']); +r = completion('VARIABLE2_COMP'); +assert_checkequal(r, ['VARIABLE2_COMPLETION'; 'variable2_completion']); + + +// Predefined functions, macros and commands + +r = completion('floo'); +check_completion(r, 'floor'); + +r = completion('FLOO'); +check_completion(r, 'floor'); + +r = completion('abort'); +check_completion(r, 'abort'); + +r = completion('Abort'); +check_completion(r, 'abort'); + + +// User functions, macros, commands + +function [] = function_completion(x); +endfunction; +r = completion('function_comp'); +assert_checkequal(r, 'function_completion'); +r = completion('FUNCTION_COMP'); +assert_checkequal(r, 'function_completion'); + +function [] = FUNCTION_COMPLETION(x); +endfunction; +r = completion('function_comp'); +assert_checkequal(r, ['FUNCTION_COMPLETION'; 'function_completion']); +r = completion('FUNCTION_COMP'); +assert_checkequal(r, ['FUNCTION_COMPLETION'; 'function_completion']); + + +// Filter argument + +r = completion('ho'); +assert_checkequal(r, ['home'; 'horizontalalignment'; 'horner'; 'host'; 'hotcolormap'; 'householder']); + +r = completion('ho', 'functions'); +assert_checkequal(r, 'host'); + +r = completion('ho', 'commands'); +assert_checkequal(r, []); + +r = completion('ho', 'macros'); +assert_checkequal(r, ['horner'; 'hotcolormap'; 'householder']); + +r = completion('ho', 'variables'); +assert_checkequal(r, 'home'); + +r = completion('ho', 'graphic_properties'); +assert_checkequal(r, 'horizontalalignment'); + +r = completion('ho', 'files'); +assert_checkequal(r, []); + +r = completion('abo'); +assert_checkequal(r, ['abort'; 'about']); + +r = completion('abo', 'functions'); +assert_checkequal(r, 'about'); + +r = completion('abo', 'commands'); +assert_checkequal(r, 'abort'); + +r = completion('abo', 'variables'); +assert_checkequal(r, []); + +r = completion('abo', 'macros'); +assert_checkequal(r, []); + +r = completion('abo', 'graphic_properties'); +assert_checkequal(r, []); + +r = completion('abo', 'files'); +assert_checkequal(r, []); + + +// Output arguments + +[functions,commands,variables,macros,graphic_properties,files] = completion('ho'); +assert_checkequal(functions, ['host']); +assert_checkequal(commands, []); +assert_checkequal(variables, ['home']); +assert_checkequal(macros, ['horner'; 'hotcolormap'; 'householder']); +assert_checkequal(graphic_properties, ['horizontalalignment']); +assert_checkequal(files, []); + +[functions,commands,variables,macros,graphic_properties,files] = completion('abo'); +assert_checkequal(functions, ['about']); +assert_checkequal(commands, ['abort']); +assert_checkequal(variables, []); +assert_checkequal(macros, []); +assert_checkequal(graphic_properties, []); +assert_checkequal(files, []); + +if (getos() == "Windows") then; + [functions,commands,variables,macros,graphic_properties,files] = completion('C:\Documents and'); + assert_checkequal(files, ['Documents and Settings\']); +else + [functions,commands,variables,macros,graphic_properties,files] = completion('/tm'); + assert_checkequal(files, ['tmp/']); +end + +assert_checkerror("completion(2)",[], 999); + +assert_checkerror("completion([''aze'',''bze''])",[], 999); +assert_checkerror("completion(''a'',''foo'')",[], 999); +assert_checkerror("completion(''a'',2)",[], 999); +assert_checkerror("[aazeaz,azeza,e,aze,azea,zazeaze,azeaze,azeze,aze,azeaz]=completion(""aaze"")",[],78); diff --git a/modules/completion/tests/unit_tests/getcommonpart.dia.ref b/modules/completion/tests/unit_tests/getcommonpart.dia.ref new file mode 100755 index 000000000..17c526dea --- /dev/null +++ b/modules/completion/tests/unit_tests/getcommonpart.dia.ref @@ -0,0 +1,30 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +r = getcommonpart(['home','homer']); +if r <> 'home' then bugmes();quit;end; +r = getcommonpart(['gethistory','gethistoryfile','gethis']); +if r <> 'gethis' then bugmes();quit;end; +r = getcommonpart(['gethistory','gethistoryfile','geths']); +if r <> 'geth' then bugmes();quit;end; +ws = ['umf_ludel', 'umf_lufact', 'umf_luget', 'umf_luinfo', 'umf_lusolve', 'umfpack', 'umfpacklib']; +r = getcommonpart(ws); +if r <> 'umf' then bugmes();quit;end; +ws = ['umf_ludel', 'umf_lufact', 'umf_luget', 'umf_luinfo', 'umf_lusolve']; +r = getcommonpart(ws); +if r <> 'umf_lu' then bugmes();quit;end; +ws = ['c:\Program files\GIT-scilab-branch-5.1','c:\Program files\GIT-scilab-master']; +r = getcommonpart(ws); +if r <> 'c:\Program files\GIT-scilab-' then bugmes();quit;end; +ws = ['/home/sylvestre/GIT-scilab-branch-5.1','/home/sylvestre/GIT-scilab-master']; +r = getcommonpart(ws); +if r <> '/home/sylvestre/GIT-scilab-' then bugmes();quit;end; diff --git a/modules/completion/tests/unit_tests/getcommonpart.tst b/modules/completion/tests/unit_tests/getcommonpart.tst new file mode 100755 index 000000000..12b32e84a --- /dev/null +++ b/modules/completion/tests/unit_tests/getcommonpart.tst @@ -0,0 +1,39 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +r = getcommonpart(['home','homer']); +if r <> 'home' then pause,end; + +r = getcommonpart(['gethistory','gethistoryfile','gethis']); +if r <> 'gethis' then pause,end; + +r = getcommonpart(['gethistory','gethistoryfile','geths']); +if r <> 'geth' then pause,end; + +ws = ['umf_ludel', 'umf_lufact', 'umf_luget', 'umf_luinfo', 'umf_lusolve', 'umfpack', 'umfpacklib']; +r = getcommonpart(ws); +if r <> 'umf' then pause,end; + +ws = ['umf_ludel', 'umf_lufact', 'umf_luget', 'umf_luinfo', 'umf_lusolve']; +r = getcommonpart(ws); +if r <> 'umf_lu' then pause,end; + +ws = ['c:\Program files\GIT-scilab-branch-5.1','c:\Program files\GIT-scilab-master']; +r = getcommonpart(ws); +if r <> 'c:\Program files\GIT-scilab-' then pause,end; + +ws = ['/home/sylvestre/GIT-scilab-branch-5.1','/home/sylvestre/GIT-scilab-master']; +r = getcommonpart(ws); +if r <> '/home/sylvestre/GIT-scilab-' then pause,end; diff --git a/modules/completion/tests/unit_tests/getfields.dia.ref b/modules/completion/tests/unit_tests/getfields.dia.ref new file mode 100755 index 000000000..9cdade933 --- /dev/null +++ b/modules/completion/tests/unit_tests/getfields.dia.ref @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +a=mlist(['TYPE' 'abcd' 'efgh' 'abce' 'ab']); +r = getfields('a.'); +if ~and(r==['ab'; 'abcd'; 'abce'; 'efgh']) then bugmes();quit;end; +r = getfields('a.a'); +if ~and(r==['ab'; 'abcd'; 'abce']) then bugmes();quit;end; +r = getfields('foo;a.abc'); +if ~and(r==['abcd'; 'abce']) then bugmes();quit;end; +r = getfields('b.'); +if ~isempty(r) then bugmes();quit;end diff --git a/modules/completion/tests/unit_tests/getfields.tst b/modules/completion/tests/unit_tests/getfields.tst new file mode 100755 index 000000000..45e815e77 --- /dev/null +++ b/modules/completion/tests/unit_tests/getfields.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2010 - Calixte DENIZET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +a=mlist(['TYPE' 'abcd' 'efgh' 'abce' 'ab']); +r = getfields('a.'); +if ~and(r==['ab'; 'abcd'; 'abce'; 'efgh']) then pause,end; + +r = getfields('a.a'); +if ~and(r==['ab'; 'abcd'; 'abce']) then pause,end; + +r = getfields('foo;a.abc'); +if ~and(r==['abcd'; 'abce']) then pause,end; + +r = getfields('b.'); +if ~isempty(r) then pause,end
\ No newline at end of file diff --git a/modules/completion/tests/unit_tests/getfilepartlevel.dia.ref b/modules/completion/tests/unit_tests/getfilepartlevel.dia.ref new file mode 100755 index 000000000..b94d35424 --- /dev/null +++ b/modules/completion/tests/unit_tests/getfilepartlevel.dia.ref @@ -0,0 +1,32 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +r = getfilepartlevel('cd c:\Program Files\scilab-5.1'); +if r <>'c:\Program Files\scilab-5.1' then bugmes();quit;end; +r = getfilepartlevel('cd(""c:\Program Files\scilab-5.1'); +if r <>'c:\Program Files\scilab-5.1' then bugmes();quit;end; +r = getfilepartlevel('cd(''c:\Program Files\scilab-5.1'); +if r <>'c:\Program Files\scilab-5.1' then bugmes();quit;end; +r = getfilepartlevel('cd /home/scilabs/scilab-5.1'); +if r <>'/home/scilabs/scilab-5.1' then bugmes();quit;end; +r = getfilepartlevel('cd(""/home/scilabs/scilab-5.1'); +if r <>'/home/scilabs/scilab-5.1' then bugmes();quit;end; +r = getfilepartlevel('cd(''/home/scilabs/scilab-5.1'); +if r <>'/home/scilabs/scilab-5.1' then bugmes();quit;end; +r = getfilepartlevel('cd ../'); +if r <>'../' then bugmes();quit;end; +r = getfilepartlevel('cd ~/'); +if r <>'~/' then bugmes();quit;end; +r = getfilepartlevel('cd ~'); +if r <>'~' then bugmes();quit;end; +r = getfilepartlevel('cd '); +if r <>'' then bugmes();quit;end; diff --git a/modules/completion/tests/unit_tests/getfilepartlevel.tst b/modules/completion/tests/unit_tests/getfilepartlevel.tst new file mode 100755 index 000000000..8715a7411 --- /dev/null +++ b/modules/completion/tests/unit_tests/getfilepartlevel.tst @@ -0,0 +1,44 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +r = getfilepartlevel('cd c:\Program Files\scilab-5.1'); +if r <>'c:\Program Files\scilab-5.1' then pause,end; + +r = getfilepartlevel('cd(""c:\Program Files\scilab-5.1'); +if r <>'c:\Program Files\scilab-5.1' then pause,end; + +r = getfilepartlevel('cd(''c:\Program Files\scilab-5.1'); +if r <>'c:\Program Files\scilab-5.1' then pause,end; + +r = getfilepartlevel('cd /home/scilabs/scilab-5.1'); +if r <>'/home/scilabs/scilab-5.1' then pause,end; + +r = getfilepartlevel('cd(""/home/scilabs/scilab-5.1'); +if r <>'/home/scilabs/scilab-5.1' then pause,end; + +r = getfilepartlevel('cd(''/home/scilabs/scilab-5.1'); +if r <>'/home/scilabs/scilab-5.1' then pause,end; + +r = getfilepartlevel('cd ../'); +if r <>'../' then pause,end; + +r = getfilepartlevel('cd ~/'); +if r <>'~/' then pause,end; + +r = getfilepartlevel('cd ~'); +if r <>'~' then pause,end; + +r = getfilepartlevel('cd '); +if r <>'' then pause,end; diff --git a/modules/completion/tests/unit_tests/getpartlevel.dia.ref b/modules/completion/tests/unit_tests/getpartlevel.dia.ref new file mode 100755 index 000000000..9251c1067 --- /dev/null +++ b/modules/completion/tests/unit_tests/getpartlevel.dia.ref @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then bugmes();quit;end +r = getpartlevel('cd c:\Program Files\scilab-5.1'); +if r <>'1' then bugmes();quit;end; +r = getpartlevel('cd(""c:\Program Files\scilab-5.1'); +if r <>'1' then bugmes();quit;end; +r = getpartlevel('printf(""hello"")'); +if r <>'' then bugmes();quit;end; +r = getpartlevel('g.children'); +if r <> 'children' then bugmes();quit;end +r = getpartlevel('1+myvariable'); +if r <> 'myvariable' then bugmes();quit;end diff --git a/modules/completion/tests/unit_tests/getpartlevel.tst b/modules/completion/tests/unit_tests/getpartlevel.tst new file mode 100755 index 000000000..d00ecacb3 --- /dev/null +++ b/modules/completion/tests/unit_tests/getpartlevel.tst @@ -0,0 +1,28 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> + +ilib_verbose(0); +ierr = exec(SCI+"/modules/completion/tests/utilities/build_primitives.sce","errcatch",-1); +if ierr<>0 then pause, end +ierr = exec(TMPDIR + "/completion/loader.sce","errcatch",-1); +if ierr<>0 then pause, end + +r = getpartlevel('cd c:\Program Files\scilab-5.1'); +if r <>'1' then pause,end; + +r = getpartlevel('cd(""c:\Program Files\scilab-5.1'); +if r <>'1' then pause,end; + +r = getpartlevel('printf(""hello"")'); +if r <>'' then pause,end; + +r = getpartlevel('g.children'); +if r <> 'children' then pause,end + +r = getpartlevel('1+myvariable'); +if r <> 'myvariable' then pause,end
\ No newline at end of file diff --git a/modules/completion/tests/utilities/build_primitives.sce b/modules/completion/tests/utilities/build_primitives.sce new file mode 100755 index 000000000..06e698083 --- /dev/null +++ b/modules/completion/tests/utilities/build_primitives.sce @@ -0,0 +1,66 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2009 - DIGITEO - Allan CORNET +// Copyright (C) 2009-2010 - DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org> +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + +previous_dir = pwd(); +cd(get_absolute_file_path("build_primitives.sce")); +file_path = pwd(); +mkdir(TMPDIR + "/completion"); +cd(TMPDIR + "/completion"); + +ilib_name = "completion_c"; +files = [ "sci_completeline.c" , .. +"sci_getpartlevel.c" , .. +"sci_getfilepartlevel.c", .. +"sci_getcommonpart.c" , .. +"sci_getfields.c" ]; + +for i = 1 : size(files, "*") + copyfile(file_path + "/" + files(i), TMPDIR + "/completion"); +end + +if getos() == "Windows" then + libs = SCI + "/bin/scicompletion"; + cflags = "-I " + SCI +"/modules/completion/includes"; + +elseif isdir(SCI+"/modules/completion/includes") + // Unix source version + libs = SCI + "/modules/completion/.libs/libscicompletion"; + cflags = "-I " + SCI +"/modules/completion/includes -I " + SCI + "/modules/localization/includes"; + +else + // Unix binary version + SCI_LIB = strsubst(SCI,"/share\/scilab$/","lib/scilab" ,"r"); + SCI_INCLUDE = strsubst(SCI,"/share\/scilab$/","include/scilab" ,"r"); + libs = SCI_LIB + "/libscicompletion"; + cflags = "-I " + SCI_INCLUDE +end + +// name known in scilab , C function called +table = ["completeline" ,"sci_completeline" ; +"getpartlevel" ,"sci_getpartlevel" ; +"getfilepartlevel","sci_getfilepartlevel"; +"getcommonpart" ,"sci_getcommonpart" ; +"getfields" ,"sci_getfields" ]; + + +libname = ilib_build(ilib_name,table,files,libs,[],"",cflags); + +cd(previous_dir); + +clear ilib_build; +clear libname; +clear table; +clear libs; +clear files; +clear ilib_name; +clear previous_dir; +clear gateway_c_dir; +clear SCI_LIB; +clear SCI_INCLUDE; diff --git a/modules/completion/tests/utilities/sci_completeline.c b/modules/completion/tests/utilities/sci_completeline.c new file mode 100755 index 000000000..ea87d0511 --- /dev/null +++ b/modules/completion/tests/utilities/sci_completeline.c @@ -0,0 +1,191 @@ +/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) DIGITEO - 2009 - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +* +*/ +/*--------------------------------------------------------------------------*/ +#define __USE_DEPRECATED_STACK_FUNCTIONS__ +#include "stack-c.h" +#include "completeLine.h" +#include "localization.h" +#include "Scierror.h" +#include "BOOL.h" +#include "freeArrayOfString.h" +#include "MALLOC.h" +/*--------------------------------------------------------------------------*/ +int sci_completeline(char *fname, unsigned long fname_len) +{ + char *postCaretLine = NULL; + char **InputString_Parameter6 = NULL; + + CheckRhs(5, 6); + CheckLhs(1, 1); + + if (Rhs == 6) + { + if (GetType(6) == sci_strings) + { + int m6 = 0; + int n6 = 0; + + GetRhsVar(6, MATRIX_OF_STRING_DATATYPE, &m6, &n6, &InputString_Parameter6); + if ( (m6 == 1) && (n6 == 1) ) + { + postCaretLine = InputString_Parameter6[0]; + } + else + { + freeArrayOfString(InputString_Parameter6, m6 * n6); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 6); + return 0; + } + } + else + { + Scierror(999, _("%s: Wrong type for input arguments.\n"), fname); + return 0; + } + } + else + { + InputString_Parameter6 = (char**)MALLOC(sizeof(char*) * 1); + InputString_Parameter6[0] = (char*)MALLOC(sizeof(char) * ((int)strlen("") + 1)); + strcpy(InputString_Parameter6[0], ""); + postCaretLine = InputString_Parameter6[0]; + } + + if ( (GetType(1) == sci_strings) && + (GetType(2) == sci_strings) && + (GetType(3) == sci_strings) && + (GetType(4) == sci_strings) && + (GetType(5) == sci_boolean) ) + { + char *currentline = NULL; + char *stringToAdd = NULL; + char *filePattern = NULL; + char *defaultPattern = NULL; + BOOL stringToAddIsPath = FALSE; + int l5 = 0; + int m = 0, n = 0; + + char **InputString_Parameter1 = NULL; + char **InputString_Parameter2 = NULL; + char **InputString_Parameter3 = NULL; + char **InputString_Parameter4 = NULL; + + char *result = NULL; + + GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString_Parameter1); + if ( (m == 1) && (n == 1) ) + { + currentline = InputString_Parameter1[0]; + } + else + { + freeArrayOfString(InputString_Parameter1, m * n); + freeArrayOfString(InputString_Parameter6, 1); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1); + return 0; + } + + GetRhsVar(2, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString_Parameter2); + if ( (m == 1) && (n == 1) ) + { + stringToAdd = InputString_Parameter2[0]; + } + else + { + freeArrayOfString(InputString_Parameter1, 1); + freeArrayOfString(InputString_Parameter2, m * n); + freeArrayOfString(InputString_Parameter6, 1); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 2); + return 0; + } + + GetRhsVar(3, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString_Parameter3); + if ( (m == 1) && (n == 1) ) + { + filePattern = InputString_Parameter3[0]; + } + else + { + freeArrayOfString(InputString_Parameter1, 1); + freeArrayOfString(InputString_Parameter2, 1); + freeArrayOfString(InputString_Parameter3, m * n); + freeArrayOfString(InputString_Parameter6, 1); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 3); + return 0; + } + + GetRhsVar(4, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString_Parameter4); + if ( (m == 1) && (n == 1) ) + { + defaultPattern = InputString_Parameter4[0]; + } + else + { + freeArrayOfString(InputString_Parameter1, 1); + freeArrayOfString(InputString_Parameter2, 1); + freeArrayOfString(InputString_Parameter3, 1); + freeArrayOfString(InputString_Parameter4, m * n); + freeArrayOfString(InputString_Parameter6, 1); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 4); + return 0; + } + + GetRhsVar(5, MATRIX_OF_BOOLEAN_DATATYPE, &m, &n, &l5); + if ( (m == 1) && (n == 1) ) + { + stringToAddIsPath = (BOOL) * istk(l5); + } + else + { + freeArrayOfString(InputString_Parameter1, 1); + freeArrayOfString(InputString_Parameter2, 1); + freeArrayOfString(InputString_Parameter3, 1); + freeArrayOfString(InputString_Parameter4, 1); + freeArrayOfString(InputString_Parameter6, 1); + Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), fname, 4); + return 0; + } + + result = completeLine(currentline, stringToAdd, filePattern, defaultPattern, stringToAddIsPath, postCaretLine); + + if (result == NULL) + { + int l = 0; + m = 0, n = 0; + CreateVar(Rhs + 1, STRING_DATATYPE, &m, &n, &l); + } + else + { + n = 1; + CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, (m = (int)strlen(result), &m), &n, &result); + if (result) + { + FREE(result); + result = NULL; + } + } + LhsVar(1) = Rhs + 1; + + freeArrayOfString(InputString_Parameter1, 1); + freeArrayOfString(InputString_Parameter2, 1); + freeArrayOfString(InputString_Parameter3, 1); + freeArrayOfString(InputString_Parameter4, 1); + freeArrayOfString(InputString_Parameter6, 1); + + } + else + { + Scierror(999, _("%s: Wrong type for input arguments.\n"), fname); + } + return 0; +} +/*--------------------------------------------------------------------------*/ diff --git a/modules/completion/tests/utilities/sci_getcommonpart.c b/modules/completion/tests/utilities/sci_getcommonpart.c new file mode 100755 index 000000000..66022be78 --- /dev/null +++ b/modules/completion/tests/utilities/sci_getcommonpart.c @@ -0,0 +1,70 @@ +/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) DIGITEO - 2009 - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +* +*/ +/*--------------------------------------------------------------------------*/ +#define __USE_DEPRECATED_STACK_FUNCTIONS__ +#include "stack-c.h" +#include "localization.h" +#include "Scierror.h" +#include "BOOL.h" +#include "freeArrayOfString.h" +#include "MALLOC.h" +#include "getCommonPart.h" +/*--------------------------------------------------------------------------*/ +int sci_getcommonpart(char *fname, unsigned long fname_len) +{ + CheckRhs(1, 1); + CheckLhs(1, 1); + + if (GetType(1) == sci_strings) + { + int m = 0, n = 0; + char **InputString = NULL; + char *Output = NULL; + + GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString); + if ( ( (m == 1) && (n != 1) ) || ( (m != 1) && (n == 1) ) ) + { + Output = getCommonPart(InputString, m * n); + freeArrayOfString(InputString, m * n); + + if (Output == NULL) + { + int l = 0; + m = 0, n = 0; + CreateVar(Rhs + 1, STRING_DATATYPE, &m, &n, &l); + } + else + { + n = 1; + CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, (m = (int)strlen(Output), &m), &n, &Output); + if (Output) + { + FREE(Output); + Output = NULL; + } + } + + LhsVar(1) = Rhs + 1; + } + else + { + freeArrayOfString(InputString, m * n); + Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 1); + } + } + else + { + Scierror(999, _("%s: Wrong type for input arguments.\n"), fname); + } + return 0; +} +/*--------------------------------------------------------------------------*/ diff --git a/modules/completion/tests/utilities/sci_getfields.c b/modules/completion/tests/utilities/sci_getfields.c new file mode 100755 index 000000000..6d48bdbf3 --- /dev/null +++ b/modules/completion/tests/utilities/sci_getfields.c @@ -0,0 +1,93 @@ +/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) DIGITEO - 2009 - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +* +*/ +/*--------------------------------------------------------------------------*/ +#include "api_scilab.h" +#include "localization.h" +#include "Scierror.h" +#include "freeArrayOfString.h" +#include "MALLOC.h" +#include "completion.h" +#include "getPartLine.h" +/*--------------------------------------------------------------------------*/ +int sci_getfields(char *fname, unsigned long fname_len) +{ + SciErr sciErr; + int *piAddr = NULL; + int rows = 0; + int cols = 0; + int length = 0; + char *line = NULL; + char **fields = NULL; + int sizefields = 0; + + CheckRhs(1, 1); + CheckLhs(1, 1); + + sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + sciErr = getMatrixOfString(pvApiCtx, piAddr, &rows, &cols, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + if (rows != 1 || cols != 1) + { + Scierror(999, _("%s: Wrong size for input argument: A string expected.\n"), fname); + } + + sciErr = getMatrixOfString(pvApiCtx, piAddr, &rows, &cols, &length, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + line = (char*)MALLOC(sizeof(char) * (length + 1)); + sciErr = getMatrixOfString(pvApiCtx, piAddr, &rows, &cols, &length, &line); + if (sciErr.iErr) + { + FREE(line); + printError(&sciErr, 0); + return 0; + } + + fields = completionOnFields(line, getPartLevel(line), &sizefields); + FREE(line); + + if (fields != NULL) + { + sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, sizefields, 1, fields); + } + else + { + char *emptystr = ""; + sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, 1, 1, &emptystr); + } + + freeArrayOfString(fields, sizefields); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + + LhsVar(1) = Rhs + 1; + + return 0; +} diff --git a/modules/completion/tests/utilities/sci_getfilepartlevel.c b/modules/completion/tests/utilities/sci_getfilepartlevel.c new file mode 100755 index 000000000..8f3b8a304 --- /dev/null +++ b/modules/completion/tests/utilities/sci_getfilepartlevel.c @@ -0,0 +1,69 @@ +/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) DIGITEO - 2009 - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +* +*/ +/*--------------------------------------------------------------------------*/ +#define __USE_DEPRECATED_STACK_FUNCTIONS__ +#include "stack-c.h" +#include "localization.h" +#include "Scierror.h" +#include "BOOL.h" +#include "freeArrayOfString.h" +#include "MALLOC.h" +#include "getPartLine.h" +/*--------------------------------------------------------------------------*/ +int sci_getfilepartlevel(char *fname, unsigned long fname_len) +{ + CheckRhs(1, 1); + CheckLhs(1, 1); + + if (GetType(1) == sci_strings) + { + int m = 0, n = 0; + char **InputString = NULL; + + GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString); + if ( (m == 1) && (n == 1) ) + { + char *result = NULL; + result = getFilePartLevel(InputString[0]); + if (result == NULL) + { + int l = 0; + m = 0, n = 0; + CreateVar(Rhs + 1, STRING_DATATYPE, &m, &n, &l); + } + else + { + n = 1; + CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, (m = (int)strlen(result), &m), &n, &result); + if (result) + { + FREE(result); + result = NULL; + } + } + + LhsVar(1) = Rhs + 1; + } + else + { + freeArrayOfString(InputString, m * n); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1); + } + } + else + { + Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1); + } + + return 0; +} +/*--------------------------------------------------------------------------*/ diff --git a/modules/completion/tests/utilities/sci_getpartlevel.c b/modules/completion/tests/utilities/sci_getpartlevel.c new file mode 100755 index 000000000..10e55108d --- /dev/null +++ b/modules/completion/tests/utilities/sci_getpartlevel.c @@ -0,0 +1,69 @@ +/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) DIGITEO - 2009 - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +* +*/ +/*--------------------------------------------------------------------------*/ +#define __USE_DEPRECATED_STACK_FUNCTIONS__ +#include "stack-c.h" +#include "localization.h" +#include "Scierror.h" +#include "BOOL.h" +#include "freeArrayOfString.h" +#include "MALLOC.h" +#include "getPartLine.h" +/*--------------------------------------------------------------------------*/ +int sci_getpartlevel(char *fname, unsigned long fname_len) +{ + CheckRhs(1, 1); + CheckLhs(1, 1); + + if (GetType(1) == sci_strings) + { + int m = 0, n = 0; + char **InputString = NULL; + + GetRhsVar(1, MATRIX_OF_STRING_DATATYPE, &m, &n, &InputString); + if ( (m == 1) && (n == 1) ) + { + char *result = NULL; + result = getPartLevel(InputString[0]); + + if (result == NULL) + { + int l = 0; + m = 0, n = 0; + CreateVar(Rhs + 1, STRING_DATATYPE, &m, &n, &l); + } + else + { + n = 1; + CreateVarFromPtr(Rhs + 1, STRING_DATATYPE, (m = (int)strlen(result), &m), &n, &result); + if (result) + { + FREE(result); + result = NULL; + } + } + LhsVar(1) = Rhs + 1; + } + else + { + freeArrayOfString(InputString, m * n); + Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, 1); + } + } + else + { + Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, 1); + } + + return 0; +} +/*--------------------------------------------------------------------------*/ |