bugGNU Octave - Bugs: bug #44793, assert([]) is valid

 
 

bug #44793: assert([]) is valid

Submitter:  John Donoghue <lostbard>
Submitted:  Thu 09 Apr 2015 04:06:59 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  JohnD Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 09 Apr 2015 05:54:57 PM UTC, comment #2: 

The check in assert is for


all (cond(:))


If cond is an empty matrix, that returns true.

I checked in the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/cbba639b956b

John W. Eaton <jwe>
Group administrator
Thu 09 Apr 2015 04:25:43 PM UTC, comment #1: 

I just checked and we have had assert([]) be a no-op since at least version 3.2.4 of Octave.  Maybe we should change that?  In scripting languages like Perl the empty value, such as "", is interpreted as false and so assert (false) should produce an error.

In other cases in Octave we do assume that [] is false.  For example,


if ([])
   disp ("True");
else
   disp ("False");
endif


prints out False.

Rik <rik5>
Group administrator
Thu 09 Apr 2015 04:06:59 PM UTC, original submission:  

Is assert([]) valid?
Matlab doesn't allow it with an error about expecting an scalar logical.

I noticed this when looking at some of the uimenu tests where the result of ishghandle() is used.

It maybe that the real issue here is the test:


hf = figure
uif = findall (hf, "label", "&file1"); % returns empty as no match
assert(ishghandle(uif)) % doesn't complain as ishghandle will correctly return empty array


John Donoghue <lostbard>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by lostbard (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-09 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code