From 6bede4a5476297c4028368d269e35155bc4903e9 Mon Sep 17 00:00:00 2001 From: Antoine ELIAS Date: Mon, 27 Jul 2015 18:17:18 +0200 Subject: [PATCH] insertion of [] in struct may used to delete entire row or col. fix some overloading tests test_run overloading bug_7042 test_run overloading bug_2267 Change-Id: I2cbdc9fc6ab8cc1d693c665172436f750e455553 --- scilab/modules/ast/src/cpp/ast/visitor_common.cpp | 4 ++-- .../tests/nonreg_tests/bug_2267.dia.ref | 7 +++---- .../overloading/tests/nonreg_tests/bug_2267.tst | 8 +++----- .../tests/nonreg_tests/bug_7042.dia.ref | 10 +++++----- .../overloading/tests/nonreg_tests/bug_7042.tst | 10 +++++----- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/scilab/modules/ast/src/cpp/ast/visitor_common.cpp b/scilab/modules/ast/src/cpp/ast/visitor_common.cpp index 829cc33..127c21b 100644 --- a/scilab/modules/ast/src/cpp/ast/visitor_common.cpp +++ b/scilab/modules/ast/src/cpp/ast/visitor_common.cpp @@ -1700,7 +1700,7 @@ InternalType* insertionCall(const ast::Exp& e, typed_list* _pArgs, InternalType* // l(x) = [] when l is not defined => create l = [] pOut = Double::Empty(); } - else if (_pInsert->isDouble() && _pInsert->getAs()->isEmpty() && _pVar->isStruct() == false && _pVar->isList() == false) + else if (_pInsert->isDouble() && _pInsert->getAs()->isEmpty() && _pVar->isList() == false) { //insert [] so deletion except for Struct and List which can insert [] InternalType::ScilabType varType = _pVar->getType(); @@ -1783,7 +1783,7 @@ InternalType* insertionCall(const ast::Exp& e, typed_list* _pArgs, InternalType* } case InternalType::ScilabStruct : { - pOut = _pVar->getAs()->insert(_pArgs, _pInsert); + pOut = _pVar->getAs()->remove(_pArgs); break; } case InternalType::ScilabHandle : diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref b/scilab/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref index 8899f47..16727a8 100644 --- a/scilab/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref +++ b/scilab/modules/overloading/tests/nonreg_tests/bug_2267.dia.ref @@ -15,14 +15,13 @@ // <-- Short Description --> // Wrong error message when ticks locations and labels have not the same sizes clf(); plot2d(); a=gca(); -errmsg1=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "x_ticks.locations", "x_ticks.labels"); +errmsg1=msprintf(_("Ticks location and label vectors must have the same size.\n")); execstr("a.x_ticks.locations=0:2:6","errcatch"); //assert_checkerror does not catch the error here assert_checkequal(lasterror(), errmsg1); execstr("a.x_ticks.labels=string([0:2:6])", "errcatch"); assert_checkequal(lasterror(), errmsg1); -errmsg2=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "y_ticks.locations", "y_ticks.labels"); execstr("a.y_ticks.locations=-2:1:2", "errcatch"); -assert_checkequal(lasterror(), errmsg2); +assert_checkequal(lasterror(), errmsg1); execstr("a.y_ticks.labels=string([-2:1:2])", "errcatch"); -assert_checkequal(lasterror(), errmsg2); +assert_checkequal(lasterror(), errmsg1); close diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_2267.tst b/scilab/modules/overloading/tests/nonreg_tests/bug_2267.tst index d3f8cc6..29e0699 100644 --- a/scilab/modules/overloading/tests/nonreg_tests/bug_2267.tst +++ b/scilab/modules/overloading/tests/nonreg_tests/bug_2267.tst @@ -16,15 +16,13 @@ // Wrong error message when ticks locations and labels have not the same sizes clf(); plot2d(); a=gca(); -errmsg1=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "x_ticks.locations", "x_ticks.labels"); +errmsg1=msprintf(_("Ticks location and label vectors must have the same size.\n")); execstr("a.x_ticks.locations=0:2:6","errcatch"); //assert_checkerror does not catch the error here assert_checkequal(lasterror(), errmsg1); execstr("a.x_ticks.labels=string([0:2:6])", "errcatch"); assert_checkequal(lasterror(), errmsg1); - -errmsg2=msprintf(_("%s: Incompatible sizes for properties ''%s'' and ''%s'': Same sizes expected.\n"), "generic_i_h", "y_ticks.locations", "y_ticks.labels"); execstr("a.y_ticks.locations=-2:1:2", "errcatch"); -assert_checkequal(lasterror(), errmsg2); +assert_checkequal(lasterror(), errmsg1); execstr("a.y_ticks.labels=string([-2:1:2])", "errcatch"); -assert_checkequal(lasterror(), errmsg2); +assert_checkequal(lasterror(), errmsg1); close diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref b/scilab/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref index 1c21b14..43dc437 100644 --- a/scilab/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref +++ b/scilab/modules/overloading/tests/nonreg_tests/bug_7042.dia.ref @@ -10,15 +10,15 @@ // <-- CLI SHELL MODE --> // // <-- Bugzilla URL --> -// http://bugzilla.scilab.org/show_bug.cgi?id= 7042 +// http://bugzilla.scilab.org/show_bug.cgi?id=7042 // // <-- Short Description --> // insertion of an empty matrix into a struct (to remove a row or column) // is buggy when multiple index is used -d11=struct('day',25,'month' ,'DEC','year',2006); -d12=struct('day',2,'month' ,'DEC','year',2006); -d21=struct('day',8,'month' ,'Feb','year',2010); -d22=struct('day',12,'month' ,'Feb','year',2010); +d11=struct("day",25,"month" ,"DEC","year",2006); +d12=struct("day",2,"month" ,"DEC","year",2006); +d21=struct("day",8,"month" ,"Feb","year",2010); +d22=struct("day",12,"month" ,"Feb","year",2010); d=[d11 d12;d21 d22]; dd=d; dd(1,:)=[]; diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_7042.tst b/scilab/modules/overloading/tests/nonreg_tests/bug_7042.tst index b854268..8807562 100644 --- a/scilab/modules/overloading/tests/nonreg_tests/bug_7042.tst +++ b/scilab/modules/overloading/tests/nonreg_tests/bug_7042.tst @@ -10,15 +10,15 @@ // <-- CLI SHELL MODE --> // // <-- Bugzilla URL --> -// http://bugzilla.scilab.org/show_bug.cgi?id= 7042 +// http://bugzilla.scilab.org/show_bug.cgi?id=7042 // // <-- Short Description --> // insertion of an empty matrix into a struct (to remove a row or column) // is buggy when multiple index is used -d11=struct('day',25,'month' ,'DEC','year',2006); -d12=struct('day',2,'month' ,'DEC','year',2006); -d21=struct('day',8,'month' ,'Feb','year',2010); -d22=struct('day',12,'month' ,'Feb','year',2010); +d11=struct("day",25,"month" ,"DEC","year",2006); +d12=struct("day",2,"month" ,"DEC","year",2006); +d21=struct("day",8,"month" ,"Feb","year",2010); +d22=struct("day",12,"month" ,"Feb","year",2010); d=[d11 d12;d21 d22]; -- 1.7.9.5