lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2018-07-13 0:52 GMT+02:00  <tobias@justdreams.de>:
>
> Hi there,
>
> working on unittests made me aware that having an assert function with
> formatting would be very helpful.
>
>> a=4
>> assert( a==1, '`a` should be `%d`, but was `%s`', 1, a )
>
>
> Of course I could write a wrapper function which takes varargs compiles the
> string and run assert on that.

assert( a==1, ('`a` should be `%d`, but was `%s`'):format(1,a) )