RELEASE LiveCode 6.6 DP1

Peter Haworth pete at lcsql.com
Sun Feb 16 18:11:23 CET 2014


All valid points. I'm just not seeing any big advantages over using if/then
constructs, but I can see that being a personal preference.

Pete
lcSQL Software
On Feb 16, 2014 4:49 AM, "Trevor DeVore" <lists at mangomultimedia.com> wrote:

> On Sunday, February 16, 2014, Peter Haworth <pete at lcsql.com> wrote:
>
> > The assert command seems to have appeared out of nowhere.  Is it on any
> > plan that anyone has seen?
>
>
> I believe it was added in order to aid with adding test coverage to
> LiveCode. At least I seem to recall reading something about that in some
> commit notes on GitHub.
>
>
> > Anyway, with assert:
> > -----------------------------
> > --Test Harness using assert
> > -----------------------------
> > command test1
> >   <do test commands>
> >    assert .....
> > end test1
> >
> > command test2
> >   <do test commands>
> >    assert .....
> > end test2
> >
> > on assertMessage
> >   switch phandler
> >      case "test1"
> >          <log stuff>
> >          break
> >       case "test2"
> >          <log stuff>
> >          break
> >    end switch
> > end assertMessage
> > ------------------------------
>
>
> I wouldn't have a switch statement like that in assert message. Why not
> just stop execution on every error? The developer sees the error, knows
> exactly which line to check (your code could even open the script editor
> and position the cursor at the exact spot), makes the fix, and then runs
> the tests again.
>
> I don't see how you could do that with assert since the main way to
> > identify which test failed is by the handlername parameter so it would be
> > one test per test handler unless you wanted to rely on the line parameter
> > which doesn't feel very safe.  I guess you could stop the tests by
> setting
> > a script local or global variable but seems unnecessarily complicated.
> >
>
> Can't you just stop the tests with 'exit to top'?
>
> I think a useful implementation of assertMessage is to log the error, open
> the script editor, and then stop execution with 'exit to top'. If a
> developer runs their test suite prior to every release they have a quick
> way of finding any errors that break their preconditions defined by the
> asserts and fixing them.
>
> Another use would be to just log a bunch of messages that the developer
> could go back and check. Perhaps assert could be improved upon with the
> ability to tell it to stop execution if the assertion fails:
>
> Assert 'condition' with exit to top
>
> The engine would send the assertMessage and then halt execution
> automatically.
>
> Ultimately I think assert gives us a richer way of expressing what it is we
> are doing in the code - testing that something behaves as it is intended.
> Personally I find assert more descriptive when reading through code (assert
> is commonly used in other languages).
>
> --
> Trevor DeVore
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


More information about the use-livecode mailing list