RELEASE LiveCode 6.6 DP1

Peter Haworth pete at lcsql.com
Sun Feb 16 01:14:06 EST 2014


The assert command seems to have appeared out of nowhere.  Is it on any
plan that anyone has seen?

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
------------------------------

With old fashioned if/then
------------------------------
Test harness using if/then
----------------------------------
command testGroup1
   <do test1 commands>
   if <test1 failed condition> then
      <log stuff>
      exit testGroup1 --because test2 depend on the successful execution of
test1
   end if
   <do test2 commands>
   if <test2 failed condition> then
      <log stuff>
   end if
end testGroup1
------------------------------------

Personally, I'd prefer the old fashioned if/then, more compact.  You can
execute tests that form a logical group within one test harness handler,
and stop the tests based on dependencies.

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.

I see a column parameter to assertMessage, not sure what that is.

Unless I'm missing something, I don't see how the assert command makes our
lives much easier.  But I guess options are always good.


Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Sat, Feb 15, 2014 at 8:14 PM, Trevor DeVore <lists at mangomultimedia.com>wrote:

> On Sat, Feb 15, 2014 at 5:24 PM, Björnke von Gierke <bvg at mac.com> wrote:
>
> > Can someone elaborate why assert is better then using "is true/false",
> and
> > what additional things it adds?
> >
>
> 'assert' is designed for writing tests for your code. That being the case,
> if 'assert' fails then the assertError message is sent which allows you to
> log the error. If you are releasing an update to some code, you run your
> tests and check your log to see if you broke anything.
>
> If you are writing tests with complete coverage for a code library you may
> end up with hundreds or thousands of 'assert' handlers that test that your
> code behaves as it is supposed to. I think the 'assert' syntax is much more
> compact and easier to write/read then a number of if/then statements that
> then make a call to a logging function.
>
> --
> Trevor DeVore
> Blue Mango Learning Systems
> www.screensteps.com    -    www.clarify-it.com
> _______________________________________________
> 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