--
--	cgtest82.occ -- RESULT parameters and abbreviations
--	Copyright (C) 2001-2002 Fred Barnes <frmb2@ukc.ac.uk>
--
--	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., 675 Mass Ave, Cambridge, MA 02139, USA.
--



PROC cgtest82 (CHAN OF BYTE keyb, scr, err)

  #INCLUDE "cgmain.occ"
  #INCLUDE "cgreal.occ"

  --{{{  identity by RESULT
  PROC res.INT (VAL INT n, RESULT INT x)
    x := n
  :
  PROC res.REAL64 (VAL REAL64 n, RESULT REAL64 x)
    SEQ
      IF
        n < 5.0
          x := n
        TRUE
          x := n
  :
  --}}}  
  --{{{  tests
  PROC test0 ()
    INT x:
    SEQ
      res.INT (42, x)
      check.INT (x, 42, "test0.0")
      res.INT (MOSTNEG INT, x)
      check.INT (x, MOSTNEG INT, "test0.1")
      res.INT (MOSTPOS INT, x)
      check.INT (x, MOSTPOS INT, "test0.2")
  :
  PROC test1 ()
    REAL64 v:
    SEQ
      res.REAL64 (5.0, v)
      check.REAL64 (v, 5.0, "test1.0")
  :
  PROC test2 ()
    INT x:
    [2]INT array:
    SEQ
      RESULT INT y IS x:
      y := 99
      check.INT (x, 99, "test2.0")
      RESULT []INT a IS array:
      SEQ
        a := [i = 1 FOR 2 | (22 * i)]
        SKIP
      check.INT (array[1], 44, "test2.1")
  :
  --}}}  
  SEQ
    init ("CG test 82", "RESULT parameters and abbreviations")
    test0 ()
    test1 ()
    test2 ()
    finish ()
:


