
(********************************************************************)
(*                                                                  *)
(*  chkbool.sd7   Checks boolean operations                         *)
(*  Copyright (C) 1992, 1993, 1994, 2004  Thomas Mertes             *)
(*                                                                  *)
(*  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 2 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, write to the           *)
(*  Free Software Foundation, Inc., 51 Franklin Street,             *)
(*  Fifth Floor, Boston, MA  02110-1301, USA.                       *)
(*                                                                  *)
(********************************************************************)


$ include "seed7_05.s7i";
  include "stdio.s7i";

const boolean: true_const is TRUE;
const boolean: false_const is FALSE;

var boolean: true_var is TRUE;
var boolean: false_var is FALSE;

var integer: counter is 0;


const proc: check_not is func
  begin
    if TRUE then
      if FALSE then
        writeln(" ***** FALSE evaluates to TRUE");
      else
        if not TRUE then
          writeln(" ***** not TRUE evaluates to TRUE");
        else
          if not FALSE then
            if true_var then
              if false_var then
                writeln(" ***** FALSE with variables evaluates to TRUE");
              else
                if not true_var then
                  writeln(" ***** not TRUE with variables evaluates to TRUE");
                else
                  if not false_var then
                    if (1 = 1) then
                      if (1 <> 1) then
                        writeln(" ***** FALSE with expressions evaluates to TRUE");
                      else
                        if not (1 = 1) then
                          writeln(" ***** not TRUE with expressions evaluates to TRUE");
                        else
                          if not (1 <> 1) then
                            writeln("Boolean not works correct.");
                          else
                            writeln(" ***** not FALSE with expressions evaluates to FALSE");
                          end if;
                        end if;
                      end if;
                    else
                      writeln(" ***** TRUE with expressions evaluates to FALSE");
                    end if;
                  else
                    writeln(" ***** not FALSE with variables evaluates to FALSE");
                  end if;
                end if;
              end if;
            else
              writeln(" ***** TRUE with variables evaluates to FALSE");
            end if;
          else
            writeln(" ***** not FALSE evaluates to FALSE");
          end if;
        end if;
      end if;
    else
      writeln(" ***** TRUE evaluates to FALSE");
    end if;
  end func;


const proc: check_and is func
  begin
    if TRUE and TRUE then
      if TRUE and FALSE then
        writeln(" ***** TRUE and FALSE evaluates to TRUE");
      else
        if FALSE and TRUE then
          writeln(" ***** FALSE and TRUE evaluates to TRUE");
        else
          if FALSE and FALSE then
            writeln(" ***** FALSE and FALSE evaluates to TRUE");
          else
            if true_var and true_var then
              if true_var and false_var then
                writeln(" ***** TRUE and FALSE with variables evaluates to TRUE");
              else
                if false_var and true_var then
                  writeln(" ***** FALSE and TRUE with variables evaluates to TRUE");
                else
                  if false_var and false_var then
                    writeln(" ***** FALSE and FALSE with variables evaluates to TRUE");
                  else
                    if (1 = 1) and (1 = 1) then
                      if (1 = 1) and (1 <> 1) then
                        writeln(" ***** TRUE and FALSE with expressions evaluates to TRUE");
                      else
                        if (1 <> 1) and (1 = 1) then
                          writeln(" ***** FALSE and TRUE with expressions evaluates to TRUE");
                        else
                          if (1 <> 1) and (1 <> 1) then
                            writeln(" ***** FALSE and FALSE with expressions evaluates to TRUE");
                          else
                            writeln("Boolean and works correct.");
                          end if;
                        end if;
                      end if;
                    else
                      writeln(" ***** TRUE and TRUE with expressions evaluates to FALSE");
                    end if;
                  end if;
                end if;
              end if;
            else
              writeln(" ***** TRUE and TRUE with variables evaluates to FALSE");
            end if;
          end if;
        end if;
      end if;
    else
      writeln(" ***** TRUE and TRUE evaluates to FALSE");
    end if;
  end func;


const proc: check_or is func
  begin
    if TRUE or TRUE then
      if TRUE or FALSE then
        if FALSE or TRUE then
          if FALSE or FALSE then
            writeln(" ***** FALSE or FALSE evaluates to TRUE");
          else
            if true_var or true_var then
              if true_var or false_var then
                if false_var or true_var then
                  if false_var or false_var then
                    writeln(" ***** FALSE or FALSE with variables evaluates to TRUE");
                  else
                    if (1 = 1) or (1 = 1) then
                      if (1 = 1) or (1 <> 1) then
                        if (1 <> 1) or (1 = 1) then
                          if (1 <> 1) or (1 <> 1) then
                            writeln(" ***** FALSE or FALSE with expressions evaluates to TRUE");
                          else
                            writeln("Boolean or works correct.");
                          end if;
                        else
                          writeln(" ***** FALSE or TRUE with expressions evaluates to FALSE");
                        end if;
                      else
                        writeln(" ***** TRUE or FALSE with expressions evaluates to FALSE");
                      end if;
                    else
                      writeln(" ***** TRUE or TRUE with expressions evaluates to FALSE");
                    end if;
                  end if;
                else
                  writeln(" ***** FALSE or TRUE with variables evaluates to FALSE");
                end if;
              else
                writeln(" ***** TRUE or FALSE with variables evaluates to FALSE");
              end if;
            else
              writeln(" ***** TRUE or TRUE with variables evaluates to FALSE");
            end if;
          end if;
        else
          writeln(" ***** FALSE or TRUE evaluates to FALSE");
        end if;
      else
        writeln(" ***** TRUE or FALSE evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE or TRUE evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_expr is func
  begin
    if (1 = 1) = (1 = 1) then
      if (1 <> 1) = (1 <> 1) then
        if (1 = 1) = (1 <> 1) then
          writeln(" ***** TRUE = FALSE with expressions evaluates to TRUE");
        else
          if (1 <> 1) = (1 = 1) then
            writeln(" ***** FALSE = TRUE with expressions evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE with expressions evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE with expressions evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if true_param = true_param then
      if false_param = false_param then
        if true_param = false_param then
          writeln(" ***** TRUE = FALSE with ref parameters evaluates to TRUE");
        else
          if false_param = true_param then
            writeln(" ***** FALSE = TRUE with ref parameters evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE with ref parameters evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE with ref parameters evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if true_param = true_param then
      if false_param = false_param then
        if true_param = false_param then
          writeln(" ***** TRUE = FALSE with in parameters evaluates to TRUE");
        else
          if false_param = true_param then
            writeln(" ***** FALSE = TRUE with in parameters evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE with in parameters evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE with in parameters evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if local_true_var = local_true_var then
      if local_false_var = local_false_var then
        if local_true_var = local_false_var then
          writeln(" ***** TRUE = FALSE with local variables evaluates to TRUE");
        else
          if local_false_var = local_true_var then
            writeln(" ***** FALSE = TRUE with local variables evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE with local variables evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE with local variables evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_global_var is func
  begin
    if true_var = true_var then
      if false_var = false_var then
        if true_var = false_var then
          writeln(" ***** TRUE = FALSE with global variables evaluates to TRUE");
        else
          if false_var = true_var then
            writeln(" ***** FALSE = TRUE with global variables evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE with global variables evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE with global variables evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_global_const is func
  begin
    if true_const = true_const then
      if false_const = false_const then
        if true_const = false_const then
          writeln(" ***** TRUE = FALSE with global constants evaluates to TRUE");
        else
          if false_const = true_const then
            writeln(" ***** FALSE = TRUE with global constants evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE with global constants evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE with global constants evaluates to FALSE");
    end if;
  end func;


const proc: check_eq_literal is func
  begin
    if TRUE = TRUE then
      if FALSE = FALSE then
        if TRUE = FALSE then
          writeln(" ***** TRUE = FALSE evaluates to TRUE");
        else
          if FALSE = TRUE then
            writeln(" ***** FALSE = TRUE evaluates to TRUE");
          else
            incr(counter);
          end if;
        end if;
      else
        writeln(" ***** FALSE = FALSE evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE = TRUE evaluates to FALSE");
    end if;
  end func;


const proc: check_eq is func
  begin
    counter := 0;
    check_eq_literal();
    check_eq_global_const();
    check_eq_global_var();
    check_eq_local_var();
    check_eq_in_param(TRUE, FALSE);
    check_eq_ref_param(TRUE, FALSE);
    check_eq_expr();
    if counter = 7 then
      writeln("Boolean = works correct.");
    else
      writeln(" ***** Boolean = does not work correct.");
    end if;
  end func;


const proc: check_ne_expr is func
  begin
    if (1 = 1) <> (1 = 1) then
      writeln(" ***** TRUE <> TRUE with expressions evaluates to TRUE");
    else
      if (1 <> 1) <> (1 <> 1) then
        writeln(" ***** FALSE <> FALSE with expressions evaluates to TRUE");
      else
        if (1 = 1) <> (1 <> 1) then
          if (1 <> 1) <> (1 = 1) then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE with expressions evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE with expressions evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if true_param <> true_param then
      writeln(" ***** TRUE <> TRUE with ref parameters evaluates to TRUE");
    else
      if false_param <> false_param then
        writeln(" ***** FALSE <> FALSE with ref parameters evaluates to TRUE");
      else
        if true_param <> false_param then
          if false_param <> true_param then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE with ref parameters evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE with ref parameters evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if true_param <> true_param then
      writeln(" ***** TRUE <> TRUE with in parameters evaluates to TRUE");
    else
      if false_param <> false_param then
        writeln(" ***** FALSE <> FALSE with in parameters evaluates to TRUE");
      else
        if true_param <> false_param then
          if false_param <> true_param then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE with in parameters evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE with in parameters evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if local_true_var <> local_true_var then
      writeln(" ***** TRUE <> TRUE with local variables evaluates to TRUE");
    else
      if local_false_var <> local_false_var then
        writeln(" ***** FALSE <> FALSE with local variables evaluates to TRUE");
      else
        if local_true_var <> local_false_var then
          if local_false_var <> local_true_var then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE with local variables evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE with local variables evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne_global_var is func
  begin
    if true_var <> true_var then
      writeln(" ***** TRUE <> TRUE with global variables evaluates to TRUE");
    else
      if false_var <> false_var then
        writeln(" ***** FALSE <> FALSE with global variables evaluates to TRUE");
      else
        if true_var <> false_var then
          if false_var <> true_var then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE with global variables evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE with global variables evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne_global_const is func
  begin
    if true_const <> true_const then
      writeln(" ***** TRUE <> TRUE with global constants evaluates to TRUE");
    else
      if false_const <> false_const then
        writeln(" ***** FALSE <> FALSE with global constants evaluates to TRUE");
      else
        if true_const <> false_const then
          if false_const <> true_const then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE with global constants evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE with global constants evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne_literal is func
  begin
    if TRUE <> TRUE then
      writeln(" ***** TRUE <> TRUE evaluates to TRUE");
    else
      if FALSE <> FALSE then
        writeln(" ***** FALSE <> FALSE evaluates to TRUE");
      else
        if TRUE <> FALSE then
          if FALSE <> TRUE then
            incr(counter);
          else
            writeln(" ***** FALSE <> TRUE evaluates to FALSE");
          end if;
        else
          writeln(" ***** TRUE <> FALSE evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_ne is func
  begin
    counter := 0;
    check_ne_literal();
    check_ne_global_const();
    check_ne_global_var();
    check_ne_local_var();
    check_ne_in_param(TRUE, FALSE);
    check_ne_ref_param(TRUE, FALSE);
    check_ne_expr();
    if counter = 7 then
      writeln("Boolean <> works correct.");
    else
      writeln(" ***** Boolean <> does not work correct.");
    end if;
  end func;


const proc: check_gt_expr is func
  begin
    if (1 = 1) > (1 = 1) then
      writeln(" ***** TRUE > TRUE with expressions evaluates to TRUE");
    else
      if (1 <> 1) > (1 <> 1) then
        writeln(" ***** FALSE > FALSE with expressions evaluates to TRUE");
      else
        if (1 = 1) > (1 <> 1) then
          if (1 <> 1) > (1 = 1) then
            writeln(" ***** FALSE > TRUE with expressions evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE with expressions evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if true_param > true_param then
      writeln(" ***** TRUE > TRUE with ref parameters evaluates to TRUE");
    else
      if false_param > false_param then
        writeln(" ***** FALSE > FALSE with ref parameters evaluates to TRUE");
      else
        if true_param > false_param then
          if false_param > true_param then
            writeln(" ***** FALSE > TRUE with ref parameters evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE with ref parameters evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if true_param > true_param then
      writeln(" ***** TRUE > TRUE with in parameters evaluates to TRUE");
    else
      if false_param > false_param then
        writeln(" ***** FALSE > FALSE with in parameters evaluates to TRUE");
      else
        if true_param > false_param then
          if false_param > true_param then
            writeln(" ***** FALSE > TRUE with in parameters evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE with in parameters evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if local_true_var > local_true_var then
      writeln(" ***** TRUE > TRUE with local variables evaluates to TRUE");
    else
      if local_false_var > local_false_var then
        writeln(" ***** FALSE > FALSE with local variables evaluates to TRUE");
      else
        if local_true_var > local_false_var then
          if local_false_var > local_true_var then
            writeln(" ***** FALSE > TRUE with local variables evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE with local variables evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt_global_var is func
  begin
    if true_var > true_var then
      writeln(" ***** TRUE > TRUE with global variables evaluates to TRUE");
    else
      if false_var > false_var then
        writeln(" ***** FALSE > FALSE with global variables evaluates to TRUE");
      else
        if true_var > false_var then
          if false_var > true_var then
            writeln(" ***** FALSE > TRUE with global variables evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE with global variables evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt_global_const is func
  begin
    if true_const > true_const then
      writeln(" ***** TRUE > TRUE with global constants evaluates to TRUE");
    else
      if false_const > false_const then
        writeln(" ***** FALSE > FALSE with global constants evaluates to TRUE");
      else
        if true_const > false_const then
          if false_const > true_const then
            writeln(" ***** FALSE > TRUE with global constants evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE with global constants evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt_literal is func
  begin
    if TRUE > TRUE then
      writeln(" ***** TRUE > TRUE evaluates to TRUE");
    else
      if FALSE > FALSE then
        writeln(" ***** FALSE > FALSE evaluates to TRUE");
      else
        if TRUE > FALSE then
          if FALSE > TRUE then
            writeln(" ***** FALSE > TRUE evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE > FALSE evaluates to FALSE");
        end if;
      end if;
    end if;
  end func;


const proc: check_gt is func
  begin
    counter := 0;
    check_gt_literal();
    check_gt_global_const();
    check_gt_global_var();
    check_gt_local_var();
    check_gt_in_param(TRUE, FALSE);
    check_gt_ref_param(TRUE, FALSE);
    check_gt_expr();
    if counter = 7 then
      writeln("Boolean > works correct.");
    else
      writeln(" ***** Boolean > does not work correct.");
    end if;
  end func;


const proc: check_ge_expr is func
  begin
    if (1 = 1) >= (1 = 1) then
      if (1 <> 1) >= (1 <> 1) then
        if (1 = 1) >= (1 <> 1) then
          if (1 <> 1) >= (1 = 1) then
            writeln(" ***** FALSE >= TRUE with expressions evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE with expressions evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE with expressions evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE with expressions evaluates to FALSE");
    end if;
  end func;


const proc: check_ge_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if true_param >= true_param then
      if false_param >= false_param then
        if true_param >= false_param then
          if false_param >= true_param then
            writeln(" ***** FALSE >= TRUE with ref parameters evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE with ref parameters evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE with ref parameters evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE with ref parameters evaluates to FALSE");
    end if;
  end func;


const proc: check_ge_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if true_param >= true_param then
      if false_param >= false_param then
        if true_param >= false_param then
          if false_param >= true_param then
            writeln(" ***** FALSE >= TRUE with in parameters evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE with in parameters evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE with in parameters evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE with in parameters evaluates to FALSE");
    end if;
  end func;


const proc: check_ge_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if local_true_var >= local_true_var then
      if local_false_var >= local_false_var then
        if local_true_var >= local_false_var then
          if local_false_var >= local_true_var then
            writeln(" ***** FALSE >= TRUE with local variables evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE with local variables evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE with local variables evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE with local variables evaluates to FALSE");
    end if;
  end func;


const proc: check_ge_global_var is func
  begin
    if true_var >= true_var then
      if false_var >= false_var then
        if true_var >= false_var then
          if false_var >= true_var then
            writeln(" ***** FALSE >= TRUE with global variables evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE with global variables evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE with global variables evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE with global variables evaluates to FALSE");
    end if;
  end func;


const proc: check_ge_global_const is func
  begin
    if true_const >= true_const then
      if false_const >= false_const then
        if true_const >= false_const then
          if false_const >= true_const then
            writeln(" ***** FALSE >= TRUE with global constants evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE with global constants evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE with global constants evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE with global constants evaluates to FALSE");
    end if;
  end func;


const proc: check_ge_literal is func
  begin
    if TRUE >= TRUE then
      if FALSE >= FALSE then
        if TRUE >= FALSE then
          if FALSE >= TRUE then
            writeln(" ***** FALSE >= TRUE evaluates to TRUE");
          else
            incr(counter);
          end if;
        else
          writeln(" ***** TRUE >= FALSE evaluates to FALSE");
        end if;
      else
        writeln(" ***** FALSE >= FALSE evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE >= TRUE evaluates to FALSE");
    end if;
  end func;


const proc: check_ge is func
  begin
    counter := 0;
    check_ge_literal();
    check_ge_global_const();
    check_ge_global_var();
    check_ge_local_var();
    check_ge_in_param(TRUE, FALSE);
    check_ge_ref_param(TRUE, FALSE);
    check_ge_expr();
    if counter = 7 then
      writeln("Boolean >= works correct.");
    else
      writeln(" ***** Boolean >= does not work correct.");
    end if;
  end func;


const proc: check_lt_expr is func
  begin
    if (1 = 1) < (1 = 1) then
      writeln(" ***** TRUE < TRUE with expressions evaluates to TRUE");
    else
      if (1 <> 1) < (1 <> 1) then
        writeln(" ***** FALSE < FALSE with expressions evaluates to TRUE");
      else
        if (1 = 1) < (1 <> 1) then
          writeln(" ***** TRUE < FALSE with expressions evaluates to TRUE");
        else
          if (1 <> 1) < (1 = 1) then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE with expressions evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if true_param < true_param then
      writeln(" ***** TRUE < TRUE with ref parameters evaluates to TRUE");
    else
      if false_param < false_param then
        writeln(" ***** FALSE < FALSE with ref parameters evaluates to TRUE");
      else
        if true_param < false_param then
          writeln(" ***** TRUE < FALSE with ref parameters evaluates to TRUE");
        else
          if false_param < true_param then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE with ref parameters evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if true_param < true_param then
      writeln(" ***** TRUE < TRUE with in parameters evaluates to TRUE");
    else
      if false_param < false_param then
        writeln(" ***** FALSE < FALSE with in parameters evaluates to TRUE");
      else
        if true_param < false_param then
          writeln(" ***** TRUE < FALSE with in parameters evaluates to TRUE");
        else
          if false_param < true_param then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE with in parameters evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if local_true_var < local_true_var then
      writeln(" ***** TRUE < TRUE with local variables evaluates to TRUE");
    else
      if local_false_var < local_false_var then
        writeln(" ***** FALSE < FALSE with local variables evaluates to TRUE");
      else
        if local_true_var < local_false_var then
          writeln(" ***** TRUE < FALSE with local variables evaluates to TRUE");
        else
          if local_false_var < local_true_var then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE with local variables evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt_global_var is func
  begin
    if true_var < true_var then
      writeln(" ***** TRUE < TRUE with global variables evaluates to TRUE");
    else
      if false_var < false_var then
        writeln(" ***** FALSE < FALSE with global variables evaluates to TRUE");
      else
        if true_var < false_var then
          writeln(" ***** TRUE < FALSE with global variables evaluates to TRUE");
        else
          if false_var < true_var then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE with global variables evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt_global_const is func
  begin
    if true_const < true_const then
      writeln(" ***** TRUE < TRUE with global constants evaluates to TRUE");
    else
      if false_const < false_const then
        writeln(" ***** FALSE < FALSE with global constants evaluates to TRUE");
      else
        if true_const < false_const then
          writeln(" ***** TRUE < FALSE with global constants evaluates to TRUE");
        else
          if false_const < true_const then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE with global constants evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt_literal is func
  begin
    if TRUE < TRUE then
      writeln(" ***** TRUE < TRUE evaluates to TRUE");
    else
      if FALSE < FALSE then
        writeln(" ***** FALSE < FALSE evaluates to TRUE");
      else
        if TRUE < FALSE then
          writeln(" ***** TRUE < FALSE evaluates to TRUE");
        else
          if FALSE < TRUE then
            incr(counter);
          else
            writeln(" ***** FALSE < TRUE evaluates to FALSE");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_lt is func
  begin
    counter := 0;
    check_lt_literal();
    check_lt_global_const();
    check_lt_global_var();
    check_lt_local_var();
    check_lt_in_param(TRUE, FALSE);
    check_lt_ref_param(TRUE, FALSE);
    check_lt_expr();
    if counter = 7 then
      writeln("Boolean < works correct.");
    else
      writeln(" ***** Boolean < does not work correct.");
    end if;
  end func;


const proc: check_le_expr is func
  begin
    if (1 = 1) <= (1 = 1) then
      if (1 <> 1) <= (1 <> 1) then
        if (1 = 1) <= (1 <> 1) then
          writeln(" ***** TRUE <= FALSE with expressions evaluates to TRUE");
        else
          if (1 <> 1) <= (1 = 1) then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE with expressions evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE with expressions evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE with expressions evaluates to FALSE");
    end if;
  end func;


const proc: check_le_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if true_param <= true_param then
      if false_param <= false_param then
        if true_param <= false_param then
          writeln(" ***** TRUE <= FALSE with ref parameters evaluates to TRUE");
        else
          if false_param <= true_param then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE with ref parameters evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE with ref parameters evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE with ref parameters evaluates to FALSE");
    end if;
  end func;


const proc: check_le_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if true_param <= true_param then
      if false_param <= false_param then
        if true_param <= false_param then
          writeln(" ***** TRUE <= FALSE with in parameters evaluates to TRUE");
        else
          if false_param <= true_param then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE with in parameters evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE with in parameters evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE with in parameters evaluates to FALSE");
    end if;
  end func;


const proc: check_le_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if local_true_var <= local_true_var then
      if local_false_var <= local_false_var then
        if local_true_var <= local_false_var then
          writeln(" ***** TRUE <= FALSE with local variables evaluates to TRUE");
        else
          if local_false_var <= local_true_var then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE with local variables evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE with local variables evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE with local variables evaluates to FALSE");
    end if;
  end func;


const proc: check_le_global_var is func
  begin
    if true_var <= true_var then
      if false_var <= false_var then
        if true_var <= false_var then
          writeln(" ***** TRUE <= FALSE with global variables evaluates to TRUE");
        else
          if false_var <= true_var then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE with global variables evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE with global variables evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE with global variables evaluates to FALSE");
    end if;
  end func;


const proc: check_le_global_const is func
  begin
    if true_const <= true_const then
      if false_const <= false_const then
        if true_const <= false_const then
          writeln(" ***** TRUE <= FALSE with global constants evaluates to TRUE");
        else
          if false_const <= true_const then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE with global constants evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE with global constants evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE with global constants evaluates to FALSE");
    end if;
  end func;


const proc: check_le_literal is func
  begin
    if TRUE <= TRUE then
      if FALSE <= FALSE then
        if TRUE <= FALSE then
          writeln(" ***** TRUE <= FALSE evaluates to TRUE");
        else
          if FALSE <= TRUE then
            incr(counter);
          else
            writeln(" ***** FALSE <= TRUE evaluates to FALSE");
          end if;
        end if;
      else
        writeln(" ***** FALSE <= FALSE evaluates to FALSE");
      end if;
    else
      writeln(" ***** TRUE <= TRUE evaluates to FALSE");
    end if;
  end func;


const proc: check_le is func
  begin
    counter := 0;
    check_le_literal();
    check_le_global_const();
    check_le_global_var();
    check_le_local_var();
    check_le_in_param(TRUE, FALSE);
    check_le_ref_param(TRUE, FALSE);
    check_le_expr();
    if counter = 7 then
      writeln("Boolean <= works correct.");
    else
      writeln(" ***** Boolean <= does not work correct.");
    end if;
  end func;


const proc: check_relations is func
  begin
    check_eq();
    check_ne();
    check_gt();
    check_ge();
    check_lt();
    check_le();
  end func;


const proc: check_compare is func
  begin
    if compare(TRUE, TRUE) <> 0 then
      writeln(" ***** compare(TRUE, TRUE) does not return 0");
    else
      if compare(FALSE, FALSE) <> 0 then
        writeln(" ***** compare(FALSE, FALSE) does not return 0");
      else
        if compare(TRUE, FALSE) <> 1 then
          writeln(" ***** compare(TRUE, FALSE) does not return 1");
        else
          if compare(FALSE, TRUE) <> -1 then
            writeln(" ***** compare(FALSE, TRUE) does not return 0");
          else
            writeln("Boolean compare works correct.");
          end if;
        end if;
      end if;
    end if;
  end func;


const proc: check_ord_expr is func
  begin
    if ord(1 = 1) = 1 then
      if ord(1 <> 1) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) with expressions evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) with expressions evaluates not to 1");
    end if;
  end func;


const proc: check_ord_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if ord(true_param) = 1 then
      if ord(false_param) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) with ref parameters evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) with ref parameters evaluates not to 1");
    end if;
  end func;


const proc: check_ord_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if ord(true_param) = 1 then
      if ord(false_param) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) with in parameters evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) with in parameters evaluates not to 1");
    end if;
  end func;


const proc: check_ord_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if ord(local_true_var) = 1 then
      if ord(local_false_var) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) with local variables evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) with local variables evaluates not to 1");
    end if;
  end func;


const proc: check_ord_global_var is func
  begin
    if ord(true_var) = 1 then
      if ord(false_var) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) with global variables evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) with global variables evaluates not to 1");
    end if;
  end func;


const proc: check_ord_global_const is func
  begin
    if ord(true_const) = 1 then
      if ord(false_const) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) with global variables evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) with global variables evaluates not to 1");
    end if;
  end func;


const proc: check_ord_literal is func
  begin
    if ord(TRUE) = 1 then
      if ord(FALSE) = 0 then
        incr(counter);
      else
        writeln(" ***** ord(FALSE) evaluates not to 0");
      end if;
    else
      writeln(" ***** ord(TRUE) evaluates not to 1");
    end if;
  end func;


const proc: check_ord is func
  begin
    counter := 0;
    check_ord_literal();
    check_ord_global_const();
    check_ord_global_var();
    check_ord_local_var();
    check_ord_in_param(TRUE, FALSE);
    check_ord_ref_param(TRUE, FALSE);
    check_ord_expr();
    if counter = 7 then
      writeln("Boolean ord() works correct.");
    else
      writeln(" ***** Boolean ord() does not work correct.");
    end if;
  end func;

(*
const proc: check_rand_literal is func
  begin
    if rand(FALSE, FALSE) = FALSE then
      if rand(TRUE, TRUE) = TRUE then
        incr(counter);
      else
        writeln(" ***** rand(TRUE, TRUE) evaluates not to FALSE");
      end if;
    else
      writeln(" ***** rand(FALSE, FALSE) evaluates not to TRUE");
    end if;
  end func;


const proc: check_rand is func
  begin
    counter := 0;
    check_rand_literal();
    check_rand_global_const();
    check_rand_global_var();
    check_rand_local_var();
    check_rand_in_param(TRUE, FALSE);
    check_rand_ref_param(TRUE, FALSE);
    check_rand_expr();
    if counter = 7 then
      writeln("Boolean rand() works correct.");
    else
      writeln(" ***** Boolean rand() does not work correct.");
    end if;
  end func;
*)

const proc: check_str_expr is func
  begin
    if str(1 = 1) = "TRUE" then
      if str(1 <> 1) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) with expressions evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) with expressions evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str_ref_param (ref boolean: true_param, ref boolean: false_param) is func
  begin
    if str(true_param) = "TRUE" then
      if str(false_param) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) with ref parameters evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) with ref parameters evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str_in_param (in boolean: true_param, in boolean: false_param) is func
  begin
    if str(true_param) = "TRUE" then
      if str(false_param) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) with in parameters evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) with in parameters evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str_local_var is func
  local
    var boolean: local_true_var is TRUE;
    var boolean: local_false_var is FALSE;
  begin
    if str(local_true_var) = "TRUE" then
      if str(local_false_var) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) with local variables evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) with local variables evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str_global_var is func
  begin
    if str(true_var) = "TRUE" then
      if str(false_var) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) with global variables evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) with global variables evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str_global_const is func
  begin
    if str(true_const) = "TRUE" then
      if str(false_const) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) with global variables evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) with global variables evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str_literal is func
  begin
    if str(TRUE) = "TRUE" then
      if str(FALSE) = "FALSE" then
        incr(counter);
      else
        writeln(" ***** str(FALSE) evaluates not to \"FALSE\"");
      end if;
    else
      writeln(" ***** str(TRUE) evaluates not to \"TRUE\"");
    end if;
  end func;


const proc: check_str is func
  begin
    counter := 0;
    check_str_literal();
    check_str_global_const();
    check_str_global_var();
    check_str_local_var();
    check_str_in_param(TRUE, FALSE);
    check_str_ref_param(TRUE, FALSE);
    check_str_expr();
    if counter = 7 then
      writeln("Boolean str() works correct.");
    else
      writeln(" ***** Boolean str() does not work correct.");
    end if;
  end func;


const proc: main is func

  begin
    writeln;
    check_not();
    check_and();
    check_or();
    check_relations;
    check_compare;
    check_ord();
    check_str();
  end func;
