Code coverage for block.li

///////////////////////////////////////////////////////////////////////////////
//                             Lisaac Library                                //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header

  + name    := BLOCK;


  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";

  - comment := "Block instruction library { ... } .";

Section Inherit

  - parent_object:OBJECT := OBJECT;

Section Public

  //
  // Conditional :
  //

  - Self:{BOOLEAN} '||' Left 10 other:{BOOLEAN} :BOOLEAN <-
  (
    value || other
  );

  - Self:{BOOLEAN} '  ' Left 20 other:{BOOLEAN} :BOOLEAN <-
  (
    value    other
  );

  - Self:{}.if test:BOOLEAN <-
  (
    test.if_true {
      value;
    };
  );

  //
  // Loop :
  //

  - Self:{}.endless_loop <-
  (
    (`1`:BOOLEAN{TRUE,FALSE}).if {
      value;
      endless_loop;
    };
  );

  - Self:{BOOLEAN}.while_do body:{} <-
  ( //? {body!=NULL};

    value.if {
      body.value;
      while_do body;
    };
  );

  - Self:{}.do_while test:{BOOLEAN} <-
  ( //? {test!=NULL};

    value;
    test.value.if {
      do_while test;
    };
  );

  - Self:{BOOLEAN}.until_do body:{} <-
  ( // ? {body!=NULL};

    (! value).if {
      body.value;
      until_do body;
    };
  );

  - Self:{}.do_until test:{BOOLEAN} <-
  ( //? {test!=NULL};

    value;
    (! test.value).if {
      do_until test;
    };
  );

  - Self:{BOOLEAN}.while_do body:{} ensure test:{BOOLEAN} <-
  // Mix loop version beetween `while_do' and `do_while'
  (
    value.if {
      body.value;
      test.value.if {
	while_do body ensure test;
      };
    };
  );

  /*
  - until_do body:BLOCK or_until test:BLOCK <-
  (
    (! value).if {
      body.value;
      (! test.value).if {
	until_do body or_until test;
      };
    };
  );
  */

  //
  // Debug: Require / Ensure / Check
  //

  - Self:{BOOLEAN} '?' msg:STRING_CONSTANT <-
  // User assertion with message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >=10)    {! value}).if {
      crash_on ptr with_message msg;
    };
  );

  - '?' Self:{BOOLEAN} <-
  // User assertion without message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >=10)    {! value}).if {
      crash_on ptr with_message "User assertion violated.";
    };
  );

  - Self:{BOOLEAN} '-?' msg:STRING_CONSTANT <-
  // Require assertion with message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >= 5)    {! value}).if {
      crash_on ptr with_message msg;
    };
  );

  - '-?' Self:{BOOLEAN} <-
  // Require assertion without message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >= 5)    {! value}).if {
      crash_on ptr with_message "Require assertion violated.";
    };
  );

  - Self:{BOOLEAN} '+?' msg:STRING_CONSTANT <-
  // Ensure assertion with message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >= 15)    {! value}).if {
      crash_on ptr with_message msg;
    };
  );

  - '+?' Self:{BOOLEAN} <-
  // Require assertion without message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >= 15)    {! value}).if {
      crash_on ptr with_message "Ensure assertion violated.";
    };
  );

  - Self:{BOOLEAN} '?#' val:INTEGER <-
  // Other assertion without message.
  ( + ptr:POINTER;

    ptr := top_runtime_stack;
    ((debug_level >= val)    {! value}).if {
      crash_on ptr with_message "Assertion violated.";
    };
  );

  //
  // Code debug.
  //

  - '!' Self:{BOOLEAN} <-
  (
    (debug_level >=10).if {
      value;
    };
  );