[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Matlab compatibility of assert
From: |
Rik |
Subject: |
Re: Matlab compatibility of assert |
Date: |
Tue, 24 Sep 2013 10:28:30 -0700 |
On 09/24/2013 08:50 AM, John W. Eaton wrote:
> On 09/24/2013 11:18 AM, Julien Bect wrote:
>
>> It seems to me that Octave's assert behaves almost exactly as Matlab's
>> assert when there are more than one argument and the second argument is
>> a string (interpreted as an error message).
>
> I think there is still some abiguity in the behavior. For example,
> suppose I'm testing with
>
> assert (observed, "the value I expect")
>
> and OBSERVED happens to be a logical value that is true. Then instead
> of failing because of mismatch, the assert succeeds. And if OBSERVED
> is false, I get "the value I expect" as an error message instead of
> the usual error message about mismatched values. Although it probably
> doesn't happen often, I don't think this kind of inconsistency is good
> behavior.
>
> I see now that Matlab requires the condition to be a logical scalar
> value, so we don't have trouble with other cases, just logical scalar.
> So perhaps we are compatible, but at the expense of inconsistency for
> the way we use assert in the Octave test suite.
>
> Maybe we should implement the Matlab behavior in assert and use
> test_assert or tassert, or something else for the Octave assert
> functionality that we use in the test suite? Then we could easily
> make assert a built-in function and it would be somewhat faster too,
> solving the initial performance concern.
>
> We could leave the !%assert syntax alone, but have it call the new
> test_assert function.
>
> The built-in assert function could test for the Matlab style case and
> perform that action, otherwise warn about deprecated usage and call
> the new test_assert function.
>
How bothersome! We have a perfectly good feature and then the syntax gets
changed underneath us.
I guess it's fine to change the function. I would rather see oassert for
Octave assert rather than tassert. This follows the pattern for ostrsplit
and strsplit where the same pre-existing function situation happened and we
had to change Octave to accommodate Matlab.
--Rik
- Re: assert () taking long time, Rik, 2013/09/19
- Re: assert () taking long time, Daniel Kraft, 2013/09/20
- Re: assert () taking long time, Rik, 2013/09/23
- Re: assert () taking long time, Daniel Kraft, 2013/09/24
- Matlab compatibility of assert (was: Re: assert () taking long time), John W. Eaton, 2013/09/24
- Re: Matlab compatibility of assert, Julien Bect, 2013/09/24
- Re: Matlab compatibility of assert, John W. Eaton, 2013/09/24
- Re: Matlab compatibility of assert, Julien Bect, 2013/09/24
- Re: Matlab compatibility of assert,
Rik <=
- Re: Matlab compatibility of assert, John W. Eaton, 2013/09/24
- Re: Matlab compatibility of assert, Rik, 2013/09/24