[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] Add assert statement to make unit testing easier for Poke code
From: |
Jose E. Marchesi |
Subject: |
Re: [RFC] Add assert statement to make unit testing easier for Poke code |
Date: |
Thu, 19 Nov 2020 08:53:45 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> On Wed, Nov 18, 2020 at 09:37:36AM +0100, Jose E. Marchesi wrote:
>>
>> I think this can be achieved without having to introduce a special form
>> `assert'. Something like this:
>>
>> fun assert (int condition, string msg,
>> int line, string file) = void:
>> {
>> if (!condition)
>> raise Exception {
>> code = EC_generic,
>> msg = "Assertion failed at " + itos (line) + file + (msg'length ?
>> ": " + msg : ""),
>> exit_status = 1
>> };
>> }
>>
>> That you invoke like:
>>
>> assert ("foo"[n] == 102UB, "", __LINE__, __FILE);
>>
>
>
> Yes. But I don't like to put those `__LINE__` and `__FILE__` variables
> everywhere.
> And I think adding such a small syntactic sugar to achieve conciseness
> is an affordable thing to do.
> BTW do you know that `assert` is a keyword of Poke? (libpoke/pkl-tab.y:315)
Heh ok, thats quite an argument :D