-- version control marker $Id: cgtest05.occ,v 1.4 1995/10/10 12:59:58 djb1 Exp $

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

  #INCLUDE "cgmain.occ"

  SEQ
    init ("CG test 5", "ALT and replicated ALT")

    --{{{  testing ALT                         (A1  - A99)
    PROC alt()
      SEQ
        --{{{  output message
        title("Testing ALT")
        --}}}
        --{{{  A1  - A3
        CHAN OF INT A: --, B, C:
        INT X, Y:
        SEQ
          X := 67
          PAR
            A ! 42
            --{{{
            ALT
              ALT
                ALT
                  ALT
                    ALT
                      ALT
                        (X = 67) & A ? Y
                          SEQ
                            check( X, 67, "A1")
                            check( Y, 42, "A2")
                        (X = 99) & A ? X
                          SKIP
            --}}}
          IF
            X = 42
              check( X, 99, "A3")
            TRUE
              SKIP
        --}}}
        --{{{  A4  - A18
        CHAN OF INT A, B, C, A1, B1, C1, A2, B2, C2, A3, B3, C3, A4, B4, C4:
        INT X:
        SEQ
          --{{{
          PAR
            A ! 0
            ALT
              A ? X
                check( X, 0, "A4")
              B ? X
                check( X, 99, "A5")
              C ? X
                check( X, 99, "A6")
          --}}}
          --{{{
          PAR
            B1 ! 1
            ALT
              A1 ? X
                check( X, 99, "A7")
              B1 ? X
                check( X, 1, "A8")
              C1 ? X
                check( X, 99, "A9")
          --}}}
          --{{{
          PAR
            C2 ! 2
            ALT
              A2 ? X
                check( X, 99, "A10")
              B2 ? X
                check( X, 99, "A11")
              C2 ? X
                check( X, 2, "A12")
          --}}}
          --{{{
          PAR
            A3 ! 0
            ALT
              TRUE & A3 ? X
                check( X, 0, "A13")
              TRUE & B3 ? X
                check( X, 99, "A14")
              TRUE & C3 ? X
                check( X, 99, "A15")
          --}}}
          --{{{
          PAR
            A4 ! 0
            ALT
              TRUE & A4 ? X
                check( X, 0, "A16")
              FALSE & B4 ? X
                check( X, 99, "A17")
              TRUE & C4 ? X
                check( X, 99, "A18")
          --}}}
          --{{{
          PAR
            C3 ! 8
            ALT
              TRUE & A4 ? X
                check( X, 99, "A16")
              FALSE & C3 ? X
                check( X, 99, "A17")
              TRUE & C3 ? X
                check( X, 8, "A18")
          --}}}
        --}}}
        --{{{  A19 - A21
        CHAN OF INT A, B, C:
        INT X:
        SEQ
          PAR
            A ! 0
            B ! 1
            C ! 2
            SEQ i = 0 FOR 3
              ALT
                A ? X
                  check( X, 0, "A19")
                B ? X
                  check( X, 1, "A20")
                C ? X
                  check( X, 2, "A21")
        --}}}
        --{{{  A22 - A24
        CHAN OF INT A, B, C:
        INT X:
        SEQ
          PAR
            A ! 0
            B ! 1
            C ! 2
            SEQ i = 0 FOR 3
              ALT
                A ? X
                  check( X, 0, "A22")
                ALT
                  B ? X
                    check( X, 1, "A23")
                  ALT
                    C ? X
                      check( X, 2, "A24")
        --}}}
        --{{{  A25 - A33
        CHAN OF INT A, B, C:
        INT X, Y, Z:
        SEQ
          PAR
            --{{{  outputs
            SEQ
              A ! -3
              A ! -2
              A ! -1
            SEQ
              C ! 3
              C ! 4
              C ! 5
            SEQ
              B ! 0
              B ! 1
              B ! 2
            --}}}
            SEQ i = 0 FOR 3
              ALT
                A ? X
                  --{{{  tests 25 to 27
                  SEQ
                    A ? Y
                    A ? Z
                    check( X, -3, "A25")
                    check( Y, -2, "A26")
                    check( Z, -1, "A27")
                  --}}}
                B ? X
                  --{{{  tests 28 to 30
                  SEQ
                    B ? Y
                    B ? Z
                    check( X, 0, "A28")
                    check( Y, 1, "A29")
                    check( Z, 2, "A30")
                  --}}}
                C ? X
                  --{{{  tests 31 to 33
                  SEQ
                    C ? Y
                    C ? Z
                    check( X, 3, "A31")
                    check( Y, 4, "A32")
                    check( Z, 5, "A33")
                  --}}}
        --}}}
        --{{{  A34 - A36
        CHAN OF BYTE C :
        PAR
          BYTE Ch :
          BOOL once:
          SEQ
            once := FALSE
            ALT
              C ? Ch
                --{{{
                SEQ
                  IF
                    once
                      check(INT Ch, 99, "A34")
                    TRUE
                      check(INT Ch, INT 'X', "A34")
                  once := TRUE
                --}}}
              C ? Ch
                --{{{
                SEQ
                  IF
                    once
                      check(INT Ch, 99, "A35")
                    TRUE
                      check(INT Ch, INT 'X', "A35")
                  once := TRUE
                --}}}
              C ? Ch
                --{{{
                SEQ
                  IF
                    once
                      check(INT Ch, 99, "A36")
                    TRUE
                      check(INT Ch, INT 'X', "A36")
                  once := TRUE
                --}}}
          C ! 'X'
        --}}}
        --{{{  A37 - A38
        CHAN OF BYTE C :
        PAR
          SEQ
            BYTE Ch :
            ALT
              C ? Ch
                check(INT Ch, -1, "A37")  --should not be called
              TRUE & SKIP
                check(INT TRUE,INT TRUE, "A38")
        --}}}
        --{{{  A39 - A40
        CHAN OF BYTE C :
        PAR
          BYTE Ch :
          ALT
            TRUE & SKIP
              check(INT TRUE, INT TRUE, "A39")
            C ? Ch
              check(INT Ch, -1, "A40")    -- should not get here
        --}}}
        --{{{  A41 - A42  FALSE guards, with range checks - crashes
        [1] CHAN OF INT c :
        BOOL x :
        INT y, z :
        CHAN OF INT d :
        PAR
          d ! 42
          SEQ
            x := FALSE
            z := 100
            ALT
              x & c[z] ? y      -- this should not range check!
                check (0, 1, "A41")
              d ? y
                check (y, 42, "A42")
        --}}}
        --{{{  A50 - A69   same as A4 - A18 but with variables instead of constants
        CHAN OF INT A, B, C, A1, B1, C1, A2, B2, C2, A3, B3, C3, A4, B4, C4:
        INT X:
        BOOL true, false :
        SEQ
          true := TRUE
          false := FALSE
          --{{{
          PAR
            A ! 0
            ALT
              A ? X
                check( X, 0, "A50")
              B ? X
                check( X, 99, "A51")
              C ? X
                check( X, 99, "A52")
          --}}}
          --{{{
          PAR
            B1 ! 1
            ALT
              A1 ? X
                check( X, 99, "A53")
              B1 ? X
                check( X, 1, "A54")
              C1 ? X
                check( X, 99, "A55")
          --}}}
          --{{{
          PAR
            C2 ! 2
            ALT
              A2 ? X
                check( X, 99, "A56")
              B2 ? X
                check( X, 99, "A57")
              C2 ? X
                check( X, 2, "A58")
          --}}}
          --{{{
          PAR
            A3 ! 0
            ALT
              true & A3 ? X
                check( X, 0, "A59")
              true & B3 ? X
                check( X, 99, "A60")
              true & C3 ? X
                check( X, 99, "A61")
          --}}}
          --{{{
          PAR
            A4 ! 0
            ALT
              true & A4 ? X
                check( X, 0, "A62")
              false & A4 ? X
                check( X, 99, "A63")
              true & C4 ? X
                check( X, 99, "A64")
          --}}}
          --{{{
          PAR
            C3 ! 8
            ALT
              true & A4 ? X
                check( X, 99, "A65")
              false & C3 ? X
                check( X, 99, "A66")
              true & C3 ? X
                check( X, 8, "A67")
          --}}}
        --}}}
    :
    alt()
    --}}}
    --{{{  testing replicated ALTs             (AU0 - AU60)
    PROC repl.alt()
      SEQ
        --{{{  output message
        title ("Testing replicated ALT")
        --}}}
        --{{{  AU0 to AU3
        [50]CHAN OF INT X:
        INT A,B, any:
        SEQ
          A := 0
          any := -5
          SEQ
            PAR
              SEQ
                SEQ I = 0 FOR 1000
                  SEQ
                X[A + 33] ! 0
              ALT I = 0 FOR 40
                X[I] ? any
                  SEQ
                    B := I
                    check (I, 33, "AU0")
            check( A, 0, "AU1")
            check( B, 33, "AU2")
            check( any, 0, "AU3")
        --}}}
        --{{{  AU4 to AU5
        [50]CHAN OF BOOL X:
        INT A,B:
        BOOL any:
        SEQ
          any := TRUE
          A := 0
          PAR
            ALT I = 0 FOR 40
              X[I] ? any
                B := I
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              X[A + 33] ! (NOT TRUE)
          check (B, 33, "AU4")
          check (INT any, INT FALSE, "AU5")
        --}}}
        --{{{  AU6 to AU7
        [30]CHAN OF INT X:
        INT A, B:
        SEQ
          A := 4
          B := 0
          PAR
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              IF
                IF I = 0 FOR 30
                  I = 22
                    X[I] ! 4
                TRUE
                  SKIP
            ALT I = 0 FOR 30
              X[I] ? B
                A := I
          check ( A, 22, "AU6")
          check ( B, 4, "AU7")
        --}}}
        --{{{  AU8 to AU10
        [50]CHAN OF BYTE X:
        BYTE A, C:
        SEQ
          C := 'a'
          A := BYTE 4
          PAR
            SEQ
              SEQ I = 0 FOR 30
                SEQ
              X[0] ! 'e'
            ALT
              X[0] ? C
                A := BYTE TRUE
              ALT I = 10 FOR 3
                X[I] ? C
                  check (INT A, 99, "AU8")
          check (INT A, INT TRUE, "AU9")
          check (INT C, INT 'e', "AU10")
        --}}}
        --{{{  AU11 to AU13
        [50]CHAN OF INT X:
        BOOL A:
        INT  B:
        SEQ
          A := FALSE
          PAR
            X[0] ! 1
            ALT I = 10 FOR 30
              ALT
                X[0] ? B
                  SEQ
                    A := TRUE
                    check (B, 1, "AU11")
                X[I] ? B
                  SEQ
                    A := FALSE
                    check(B, 99, "AU12")
          check(INT A, INT TRUE, "AU13")
        --}}}
        --{{{  AU14 to AU16
        BOOL A:
        [50]CHAN OF INT X:
        INT B:
        SEQ
          A := FALSE
          PAR
            X[13] ! 1
            ALT I = 10 FOR 30
              ALT
                X[0] ? B
                  SEQ
                    A := FALSE
                    check (B, -1, "AU14")
                X[I] ? B
                  SEQ
                    A := TRUE
                    check (B, 1, "AU15")
          check (INT A, INT TRUE, "AU16")
        --}}}
        --{{{  AU17 to AU21
        INT B:
        BOOL A:
        [50]CHAN OF INT X:
        SEQ
          A := FALSE
          B := 78
          PAR
            SEQ
              SEQ I = 0 FOR 30
                SEQ
            X[10] ! 0
            ALT
              ALT I = 0 FOR 30
                X[I] ? B
                  SEQ
                    A := TRUE
                    check (B, 0, "AU17")
                    check (I, 10, "AU18")
              X[43] ? B
                SEQ
                  A := FALSE
                  check(INT A, INT TRUE, "AU19")
          check (INT A, INT TRUE, "AU20")
          check (B, 0, "AU21")
        --}}}
        --{{{  AU22 to AU25
        BOOL A:
        [50]CHAN OF INT X:
        INT B:
        SEQ
          A := FALSE
          B := 78
          PAR
            SEQ
              SEQ I = 0 FOR 30
                SEQ
              X[43] ! -8
            ALT
              ALT I = 0 FOR 30
                X[I] ? B
                  SEQ
                    A := FALSE
                    check (INT A, INT TRUE, "AU22")
              X[43] ? B
                SEQ
                  A := TRUE
                  check (B, -8, "AU23")
          check (INT A, INT TRUE, "AU24")
          check ( B, -8, "AU25")
        --}}}
        --{{{  AU26 to AU28
        [50]CHAN OF BYTE X:
        CHAN OF BYTE A:
        BOOL E:
        BYTE B:
        SEQ
          B := BYTE 4
          E := FALSE
          PAR
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              A ! BYTE TRUE
            ALT I = 0 FOR 30
              ALT
                A ? B
                  SEQ
                    check (INT B, INT TRUE, "AU26")
                    E := TRUE
                X[I] ? B
                  SEQ
                    E := FALSE
                    check (INT E, 99, "AU27")
          check (INT E, INT TRUE, "AU28")
        --}}}
        --{{{  AU29 to AU32
        CHAN OF INT A:
        [50]CHAN OF INT X:
        BOOL E:
        INT B, C:
        SEQ
          B := 4
          C := 0
          E := FALSE
          PAR
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              X[5] ! INT (NOT E)
            ALT I = 0 FOR 30
              ALT
                A ? B
                  SEQ
                    check(B, 99, "AU29")
                    B := 99
                X[I] ? B
                  SEQ
                    C := I
                    check (I, 5, "AU30")
          check(B, INT TRUE, "AU31")
          check(C, 5, "AU32")
        --}}}
        --{{{  AU33 to AU36
        CHAN OF BYTE Y:
        [50]CHAN OF BYTE X:
        CHAN OF BOOL Z:
        BYTE temp:
        BOOL A:
        SEQ
          A := FALSE
          PAR
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              Y ! BYTE TRUE
            ALT
              Y ? temp
                SEQ
                  A := BOOL temp
                  check (INT A, INT TRUE, "AU33")
              ALT I = 0 FOR 30
                X[I] ? temp
                  SEQ
                    A := FALSE
                    check (1, 2, "AU34")
              Z ? A
                SEQ
                  A := FALSE
                  check (3, 4, "AU35")
          check (INT A, INT TRUE, "AU36")
        --}}}
        --{{{  AU37 to AU41
        [50]CHAN OF INT X:
        CHAN OF INT Y,Z:
        INT A:
        SEQ
          A := 4
          PAR
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              X[4] ! INT TRUE
            ALT
              Y ? A
                SEQ
                  A := INT FALSE
                  check (A, 4, "AU37")
              ALT I = 0 FOR 30
                X[I] ? A
                  SEQ
                    check (I, 4, "AU38")
                    check (A, INT TRUE, "AU39")
              Z ? A
                SEQ
                  A := INT FALSE
                  check (A, 4, "AU40")
          check (A, INT TRUE, "AU41")
        --}}}
        --{{{  AU42 to AU45
        CHAN OF INT Y,Z:
        INT A :
        [50]CHAN OF INT X:
        SEQ
          A := 4
          PAR
            SEQ
              SEQ I = 0 FOR 100
                SEQ
              Z ! INT TRUE
            ALT
              Y ? A
                SEQ
                  A := INT FALSE
                  check (A, 4, "AU42")
              ALT I = 0 FOR 30
                X[I] ? A
                  SEQ
                    A := INT FALSE
                    check( A, 4, "AU43")
              Z ? A
                SEQ
                  check (A, INT TRUE, "AU44")
          check (A, INT TRUE, "AU45")
        --}}}
        --{{{  AU46 to AU53
        CHAN OF INT A, B, C, D:
        INT X, A1, B1, C1, D1:
        SEQ
          PAR
            SEQ
              SEQ i = 0 FOR 100
                SEQ
              A ! 0
              B ! 1
              C ! 2
              D ! 3
            SEQ j = 0 FOR 4
              ALT
                A ? X
                  SEQ
                    A1 := X
                    check (X, 0, "AU46")
                ALT
                  B ? X
                    SEQ
                      B1 := X
                      check (X, 1, "AU47")
                  C ? X
                    SEQ
                      C1 := X
                      check (X, 2, "AU48")
                D ? X
                  SEQ
                    D1 := X
                    check (X, 3, "AU49")
          check (A1, 0, "AU50")
          check (B1, 1, "AU51")
          check (C1, 2, "AU52")
          check (D1, 3, "AU53")
        --}}}
        --{{{  AU54 to AU55
        [30]CHAN OF INT X:
        INT A, B:
        SEQ
          A := 4
          B := 0
          PAR
            --{{{  transmitter
            SEQ J = 22 FOR 3
              IF
                IF I = 0 FOR 30
                  I = J
                    X[I] ! (J + 4)
                TRUE
                  SKIP
            --}}}
            --{{{  receiver
            SEQ J = 0 FOR 3
              SEQ
                ALT I = 0 FOR 30
                  X[I] ? B
                    A := I
                check (A, (22 + J), "AU54")
                check (B, (26 + J), "AU55")
            --}}}
        --}}}
        --{{{  AU60           CASE input (from compiler bug 137)
        --{{{  protocol definition
        PROTOCOL protocol
          CASE
            tag1 ; INT
            tag2
        :
        --}}}
        [10] CHAN OF protocol c :
        PAR
          --{{{  output some stuff
          PAR i = 0 FOR 10
            SEQ
              c [i] ! tag1 ; i
              c [i] ! tag2
          --}}}
        
          INT x :
          BOOL ok :
          [10]BOOL done :
          SEQ
            ok := TRUE
            --{{{  initialise done array to FALSE
            SEQ i = 0 FOR 10
              done [i] := FALSE
            --}}}
            SEQ loop = 0 FOR 20
              ALT i = 0 FOR 10
                c[i] ? CASE
                  tag1 ; x
                    SEQ
                      ok := ok AND (x = i)
                      done [i] := TRUE
                  tag2
                    ok := ok AND done [i]
            check (INT ok, INT TRUE, "AU60")
        --}}}
        --{{{  AU61
        PROC AU61()
          PROC local(VAL INT x, []CHAN OF INT c)
            INT data :
            SEQ
              PRI ALT
                PRI ALT i = 0 FOR x
                  c[i] ? data
                    check(0, 1, "AU61")
                TRUE & SKIP
                  SEQ
                    check(0, 0, "AU61")
                    c[0] ? data
          :
          [1]CHAN OF INT c :
          PAR
            c[0] ! 99
            local(0, c)
        :
        AU61()
        --}}}
    :
    repl.alt()
    --}}}
    --{{{  PRI ALT                             (PA00 - PA99)
    PROC pri.alt()
      SEQ
        --{{{  output message
        title ("Testing PRI ALT")
        --}}}
        SEQ
          --{{{  PA00
          CHAN OF INT c :
          PAR
            c ! 42
          
            INT x :
            PRI ALT
              TRUE & SKIP
                PRI ALT
                  c ? x
                    check (x, 42, "PA00")
                  c ? x
                    check (0, 1, "PA00")
              c ? x
                check (0, 2, "PA00")
          --}}}
          --{{{  PA01 - PA05
          CHAN OF INT c, d :
          PAR
            SEQ
              --{{{  output 42 .. 51 on channel c
              SEQ i = 0 FOR 10
                c ! i + 42
              --}}}
              --{{{  output 57 .. 66 on channel d
              SEQ i = 0 FOR 10
                d ! i + 57
              --}}}
          
            INT x, y, z :
            SEQ
              --{{{  read in from channel c  (PA01 - PA02)
              z := 0
              SEQ i = 0 FOR 10
                PRI ALT
                  c ? x
                    z := z + 1
                  d ? y
                    check (y, 0, "PA02")
              check (z, 10, "PA01")
              --}}}
              --{{{  read in from channel d  (PA03 - PA05)
              y := 0
              SEQ i = 0 FOR 5
                PRI ALT
                  c ? x              -- no more data left in c
                    check (x, 0, "PA03")
                  d ? x
                    y := y + x
              SEQ i = 0 FOR 5
                PRI ALT
                  d ? x
                    y := y + x
                  c ? x
                    check (x, 0, "PA04")
              check (y, 615, "PA05")     -- 45 + (10 * 57)
              --}}}
          --}}}
    :
    pri.alt()
    --}}}
    --{{{  bulk testing replicated ALTs
    PROC bulk.test()
    
      SEQ
        --{{{  output message
        title ("Bulk testing replicated ALT")
        --}}}
        --{{{  PROC column.out (VAL INT x)
        PROC column.out (VAL INT x)
          SEQ
            --out ( (x / 10) + ('0' (INT)) )
            --out ( (x \ 10) + ('0' (INT)) )
            --out (INT ' ')
        :
        --}}}
    
        VAL no.of.replications IS 20 : -- must be a multiple of 10, I think.
        SEQ j = 0 FOR 3
          SEQ
            --{{{  test replicated ALT via SEQ
            --{{{  output message
            --title ("Testing ALT via SEQ")
            title ("SEQ  ")
            --}}}
            [no.of.replications]CHAN OF INT a :
            INT x :
            PAR
              SEQ i = 0 FOR no.of.replications
                a[i] ! i
              SEQ i = 0 FOR no.of.replications
                ALT i = 0 FOR no.of.replications
                  a[i] ? x
                    column.out (x)
            --}}}
            --{{{  test replicated ALT via PAR
            --{{{  output message
            --title ("Testing ALT via PAR")
            title ("PAR  ")
            --}}}
            [no.of.replications]CHAN OF INT a :
            INT x :
            PAR
              PAR i = 0 FOR no.of.replications
                a[i] ! i
              SEQ i = 0 FOR no.of.replications
                ALT i = 0 FOR no.of.replications
                  a[i] ? x
                    column.out (x)
            --}}}
            --{{{  test replicated ALT via both
            --{{{  output message
            --title ("Testing ALT via both")
            title ("BOTH ")
            --}}}
            [no.of.replications]CHAN OF INT a :
            INT x :
            PAR
              PAR i = 0 FOR no.of.replications / 10
                SEQ j = i * 10 FOR 5
                  PAR
                    VAL index IS j :
                    a [index]  ! index
                    --a [j] ! j
                    VAL index2 IS j + 5 :
                    a [index2] ! index2
                    --a[j + 5] ! j + 5
              SEQ i = 0 FOR no.of.replications
                ALT i = 0 FOR no.of.replications
                  a[i] ? x
                    column.out (x)
            --}}}
    
    :
    bulk.test()
    --}}}
    --{{{  functions in ALT guards
    PROC functions.in.ALT.guards()
      --{{{  functions for testing
      INT FUNCTION f(VAL INT x) IS id.INT(x) :
      BOOL FUNCTION test.fn(VAL BOOL a, b) IS id.BOOL(a) = b :
      BOOL FUNCTION four.params(VAL INT x, y, z, w) IS (id.INT(x) + y) = (z + id(w)) :
      --}}}
      PROC test([]CHAN OF INT ccc, [2]CHAN OF INT cc, CHAN OF INT c)
        INT x, y, z :
        BOOL b1, b2 :
        SEQ
          --{{{  initialise variables
          y := id.INT(77)
          b1 := id.BOOL(TRUE)
          b2 := b1 AND (id.BOOL(TRUE))
          --}}}
          --{{{  use function 'test.fn'
          ALT
            test.fn(TRUE, FALSE) & SKIP
              x := 77
            test.fn(b1, b2) & SKIP
              x := 88
          check(x, 88, "F000")
          
          ALT
            test.fn(b1, b2) & SKIP
              x := 66
            test.fn(FALSE, TRUE) & SKIP
              x := 33
          check(x, 66, "F001")
          --}}}
          --{{{  use function 'f'
          ALT
            f(y) = 77 & SKIP
              check(y, 77, "F002")
          
          ALT
            f(y) > f(100) & c ? x
              SKIP
            f(y) < f(99) & SKIP
              x := 3
          check(x, 3, "F003")
          
          ALT
            f(y) < f(100) & c ? x
              SKIP
            f(y) = 0 & SKIP
              x := 3
          check(x, 5, "F004")
          --}}}
          --{{{  four.params, scalar channel
          ALT
            four.params(x, y, 80, 3) & c ? x
              SKIP
            four.params(80, x, y, 8) & SKIP
              x := 19
          check(x, 19, "F005")
          
          x := id.INT(5)
          ALT
            four.params(80, 2, x, y) & c ? x
              SKIP
            four.params(81, x, y, 8) & SKIP
              x := 19
          check(x, 16, "F006")
          --}}}
          --{{{  four.params, known array channel
          x := id.INT(5)
          ALT i = 0 FOR SIZE cc
            ALT
              four.params(x, y, 80, i) & cc[i] ? x
                SKIP
              four.params(80, x, y, i+7) & SKIP
                x := i
          check(x, 1, "F007")
          
          x := id.INT(5)
          ALT i = 0 FOR SIZE cc
            ALT
              four.params(80, i+1, x, y) & cc[i] ? x
                x := x + i
              four.params(61, x, y, i) & SKIP
                x := i
          check(x, 101, "F008")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE cc
              four.params(x, y, 80, i) & cc[i] ? x
                SKIP
            four.params(73, x, y, 1) & SKIP
              x := 1
          check(x, 1, "F009")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE cc
              four.params(81, i, x, y) & cc[i] ? x
                x := x + i
            four.params(81, x, y, 1) & SKIP
              x := 19
          check(x, 21, "F010")
          --}}}
          --{{{  four.params, open array channel
          x := id.INT(5)
          ALT i = 0 FOR SIZE ccc
            ALT
              four.params(x, y, 80, i) & ccc[i] ? x
                check(0,-1,"F011")--SKIP
              four.params(80, x, y, i+7) & SKIP
                x := i
          check(x, 1, "F011")
          
          x := id.INT(5)
          ALT i = 0 FOR SIZE ccc
            ALT
              four.params(80, i+1, x, y) & ccc[i] ? x
                x := x + i
              four.params(61, x, y, i) & SKIP
                x := i
          check(x, 101, "F012")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE ccc
              four.params(x, y, 80, i) & ccc[i] ? x
                check(0,-1,"F013")--SKIP
            four.params(73, x, y, 1) & SKIP
              x := 1
          check(x, 1, "F013")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE ccc
              four.params(81, i, x, y) & ccc[i] ? x
                x := x + i
            four.params(81, x, y, 1) & SKIP
              x := 19
          check(x, 21, "F014")
          --}}}
          --{{{  mixed number of params
          x := id(1010)
          SEQ i = 0 FOR 4
            SEQ
              ALT
                f(y) = (74+i) & SKIP
                  check(i, 3, "F015")
                test.fn(b1, x = (1010 * i)) & c ? z
                  SEQ
                    check(i, 1, "F016")
                    check(z, 27, "F017")
                four.params(x, y, i, 1087) & cc[i] ? z
                  SEQ
                    check(i, 0, "F018")
                    check(z, 33, "F019")
                ccc[i] ? z
                  SEQ
                    check(i, 2, "F020")
                    check(z, 42, "F021")
          --}}}
          --{{{  four.params, known array channel, fn in channel too
          x := id.INT(5)
          ALT i = 0 FOR SIZE cc
            ALT
              four.params(x, y, 80, i) & cc[id.INT(i)] ? x
                SKIP
              four.params(80, x, y, i+7) & SKIP
                x := i
          check(x, 1, "F022")
          
          x := id.INT(5)
          ALT i = 0 FOR SIZE cc
            ALT
              four.params(80, i+1, x, y) & cc[id.INT(i)] ? x
                x := x + i
              four.params(61, x, y, i) & SKIP
                x := i
          check(x, 101, "F023")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE cc
              four.params(x, y, 80, i) & cc[id.INT(i)] ? x
                SKIP
            four.params(73, x, y, 1) & SKIP
              x := 1
          check(x, 1, "F024")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE cc
              four.params(81, i, x, y) & cc[id.INT(i)] ? x
                x := x + i
            four.params(81, x, y, 1) & SKIP
              x := 19
          check(x, 21, "F025")
          --}}}
          --{{{  four.params, open array channel, fn in channel too
          x := id.INT(5)
          ALT i = 0 FOR SIZE ccc
            ALT
              four.params(x, y, 80, i) & ccc[id.INT(i)] ? x
                check(0,-1,"F026")--SKIP
              four.params(80, x, y, i+7) & SKIP
                x := i
          check(x, 1, "F027")
          
          x := id.INT(5)
          ALT i = 0 FOR SIZE ccc
            ALT
              four.params(80, i+1, x, y) & ccc[id.INT(i)] ? x
                x := x + i
              four.params(61, x, y, i) & SKIP
                x := i
          check(x, 101, "F028")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE ccc
              four.params(x, y, 80, i) & ccc[id.INT(i)] ? x
                check(0,-1,"F013")--SKIP
            four.params(73, x, y, 1) & SKIP
              x := 1
          check(x, 1, "F029")
          
          x := id.INT(5)
          ALT
            ALT i = 0 FOR SIZE ccc
              four.params(81, i, x, y) & ccc[id.INT(i)] ? x
                x := x + i
            four.params(81, x, y, 1) & SKIP
              x := 19
          check(x, 21, "F030")
          --}}}
          --{{{  mixed number of params, fn in channel too
          x := id(1010)
          SEQ i = 0 FOR 4
            SEQ
              ALT
                f(y) = (74+i) & SKIP
                  check(i, 3, "F031")
                test.fn(b1, x = (1010 * i)) & c ? z
                  SEQ
                    check(i, 1, "F032")
                    check(z, 27, "F033")
                four.params(x, y, i, 1087) & cc[id.INT(i)] ? z
                  SEQ
                    check(i, 0, "F034")
                    check(z, 33, "F035")
                ccc[id.INT(i)] ? z
                  SEQ
                    check(i, 2, "F036")
                    check(z, 42, "F037")
          --}}}
          --{{{  four.params, known array channel, fn in channel too, swapped
          x := id.INT(5)
          ALT i = 0 FOR SIZE cc
            ALT
              four.params(80, x, y, i+7) & SKIP
                x := i
              four.params(x, y, 80, i) & cc[id.INT(i)] ? x
                SKIP
          check(x, 1, "F038")
          
          x := id.INT(5)
          ALT i = 0 FOR SIZE cc
            ALT
              four.params(61, x, y, i) & SKIP
                x := i
              four.params(80, i+1, x, y) & cc[id.INT(i)] ? x
                x := x + i
          check(x, 101, "F039")
          
          x := id.INT(5)
          ALT
            four.params(73, x, y, 1) & SKIP
              x := 1
            ALT i = 0 FOR SIZE cc
              four.params(x, y, 80, i) & cc[id.INT(i)] ? x
                SKIP
          check(x, 1, "F040")
          
          x := id.INT(5)
          ALT
            four.params(81, x, y, 1) & SKIP
              x := 19
            ALT i = 0 FOR SIZE cc
              four.params(81, i, x, y) & cc[id.INT(i)] ? x
                x := x + i
          check(x, 21, "F041")
          --}}}
      :
      [10]CHAN OF INT ccc :
      [2]CHAN OF INT cc :
      CHAN OF INT c :
      PAR
        test(ccc, cc, c)
        SEQ
          --{{{  function 'f'
          c ! 5
          --}}}
          --{{{  four.params, scalar channel
          c ! 16
          --}}}
          --{{{  four.params, known array channel
          cc[1] ! 100
          cc[1] !  20
          --}}}
          --{{{  four.params, open array channel
          ccc[1] ! 100
          ccc[1] !  20
          --}}}
          --{{{  mixed number of params
          cc[0] ! 33
          c ! 27
          ccc[2] ! 42
          --}}}
          --{{{  four.params, known array channel, fn in channel too
          cc[1] ! 100
          cc[1] !  20
          --}}}
          --{{{  four.params, open array channel, fn in channel too
          ccc[1] ! 100
          ccc[1] !  20
          --}}}
          --{{{  mixed number of params, fn in channel too
          cc[0] ! 33
          c ! 27
          ccc[2] ! 42
          --}}}
          --{{{  four.params, known array channel, fn in channel too, swapped
          cc[1] ! 100
          cc[1] !  20
          --}}}
    :
    functions.in.ALT.guards()
    --}}}
    --{{{  bug 262
    -- bug 262 from buglist
    PROC bug.262 ()
      PROTOCOL UNKNOWN IS ANY:
      PROC main ([10]CHAN OF UNKNOWN c1, c2)
        INT s :
        SEQ
          s := (SIZE c2) - 1
          ALT
            ALT i = 0 FOR SIZE c1
              INT x :
              c1 [i] ? x
                check (i, x, "B262a")
            VAL size IS s + 1 :
            INT z, y :
            --ALT j = 0 FOR size
            ALT j = 0 FOR SIZE c2
              c2 [j] ? z
                SEQ
                  SEQ k = 0 FOR 500
                    y := k
                  check(j, z, "B262b")
      :
      [10]CHAN OF UNKNOWN c1, c2 :
      PAR
        SEQ
          c2[(SIZE c2) - 1] ! (SIZE c2) - 1
          SEQ i = 0 FOR (SIZE c1) / 2
            c1[i*2] ! i*2
          SEQ j = 0 FOR (SIZE c2) / 2
            c2[((SIZE c2) - 1) -(j*2)] ! ((SIZE c2) - 1) - (j*2)
          SEQ i = 0 FOR SIZE c1
            SEQ
              c1 [i] ! i
              c2 [i] ! i
        SEQ i = 0 FOR ((SIZE c1) * 3) + 1
          main (c1, c2)
    :
    bug.262 ()
    --}}}
    --{{{  bug 262a
    -- bug 262 from buglist
    PROC bug.262a ()
      PROTOCOL any IS ANY :
      PROC main ([10]CHAN OF any c1, c2)
        INT s :
        SEQ
          s := (SIZE c2) - 1
          ALT
            ALT i = 0 FOR SIZE c1
              INT x :
              c1 [i] ? x
                check (i, x, "B262aa")
            VAL size IS s + 1 :
            INT z, y :
            --ALT j = 0 FOR size
            ALT j = 0 FOR SIZE c2
              c2 [j] ? z
                SEQ
                  SEQ k = 0 FOR 500
                    y := k
                  check(j, z, "B262ab")
      :
      [10]CHAN OF any c1, c2 :
      PAR
        SEQ
          c2[(SIZE c2) - 1] ! (SIZE c2) - 1
          SEQ i = 0 FOR (SIZE c1) / 2
            c1[i*2] ! i*2
          SEQ j = 0 FOR (SIZE c2) / 2
            c2[((SIZE c2) - 1) -(j*2)] ! ((SIZE c2) - 1) - (j*2)
          SEQ i = 0 FOR SIZE c1
            SEQ
              c1 [i] ! i
              c2 [i] ! i
        SEQ i = 0 FOR ((SIZE c1) * 3) + 1
          main (c1, c2)
    :
    bug.262a ()
    --}}}
    --{{{  bug 262b
    -- bug 262 from buglist
    PROC bug.262b ()
      PROC main ([10]CHAN OF INT c1, c2)
        INT s :
        SEQ
          s := (SIZE c2) - 1
          ALT
            ALT i = 0 FOR SIZE c1
              INT x :
              c1 [i] ? x
                check (i, x, "B262ba")
            VAL size IS s + 1 :
            INT z, y :
            --ALT j = 0 FOR size
            ALT j = 0 FOR SIZE c2
              c2 [j] ? z
                SEQ
                  SEQ k = 0 FOR 500
                    y := k
                  check(j, z, "B262bb")
      :
      [10]CHAN OF INT c1, c2 :
      PAR
        SEQ
          c2[(SIZE c2) - 1] ! (SIZE c2) - 1
          SEQ i = 0 FOR (SIZE c1) / 2
            c1[i*2] ! i*2
          SEQ j = 0 FOR (SIZE c2) / 2
            c2[((SIZE c2) - 1) -(j*2)] ! ((SIZE c2) - 1) - (j*2)
          SEQ i = 0 FOR SIZE c1
            SEQ
              c1 [i] ! i
              c2 [i] ! i
        SEQ i = 0 FOR ((SIZE c1) * 3) + 1
          main (c1, c2)
    :
    bug.262b ()
    --}}}
    --{{{  bug 275
    -- bug 275 from buglist
    PROC bug.275 ()
      PROTOCOL UNKNOWN IS ANY:
      --{{{  PROC main
      PROC main ([10]CHAN OF UNKNOWN c1, c2)
        INT s :
        INT one :
        SEQ
          s, one := (SIZE c2) - 1, 1
          ALT
            ALT i = 0 FOR SIZE c1
              INT x :
              c1 [i] ? x
                check (i, x, "B275a")
            VAL size IS s + 1 :
            INT z, y :
            ALT j = 0 FOR size
              VAL index IS (j + one) - 1 :
              c2 [index] ? z
                SEQ
                  SEQ k = 0 FOR 500  -- make sure that k has high usage
                    y := k           -- and y too
                  check(index, z, "B275b")
      :
      --}}}
      SEQ
        [10]CHAN OF UNKNOWN c1, c2 :
        PAR
          SEQ
            c2[(SIZE c2) - 1] ! (SIZE c2) - 1
            SEQ i = 0 FOR (SIZE c1) / 2
              c1[i*2] ! i*2
            SEQ j = 0 FOR (SIZE c2) / 2
              c2[((SIZE c2) - 1) -(j*2)] ! ((SIZE c2) - 1) - (j*2)
            SEQ i = 0 FOR SIZE c1
              SEQ
                c1 [i] ! i
                c2 [i] ! i
          SEQ i = 0 FOR ((SIZE c1) * 3) + 1
            main (c1, c2)
        check(0, 0, "Blurgle")
        -- nested replicators, and nested ALTs
        --{{{  PROC fred
        PROC fred (VAL INT count, [][][][]CHAN OF INT c1, [][]CHAN OF INT c2, c3)
          ALT
            ALT i = 0 FOR SIZE c2
              c2i IS c2[i] :
              ALT j = 0 FOR SIZE c2[0]
                INT data :
                c2i [j] ? data
                  SEQ
                    check(data, count, "B275c")
                    check(i,    0,     "B275d")
                    check(j,    1,     "B275e")
            ALT i = 0 FOR SIZE c1
              ALT j = 0 FOR SIZE c1[0]
                ALT k = 0 FOR SIZE c1[0][0]
                  ALT l = 0 FOR SIZE c1[0][0][0]
                    INT data :
                    c1[i][j][k][l] ? data
                      SEQ
                        check(data, count, "B275f")
                        check(i, 1, "B275g")
                        check(j, 1, "B275h")
                        check(k, 1, "B275i")
                        check(l, 1, "B275j")
                        ALT
                          ALT m = 0 FOR SIZE c2
                            c2m IS c2[m] :
                            ALT n = 0 FOR SIZE c2[0]
                              c2m[n] ? data
                                SEQ
                                  check(data, count+1, "B275k")
                                  check(m, 1, "B275l")
                                  check(n, 2, "B275m")
                          ALT o = 0 FOR SIZE c3
                            c3o IS c3[o] :
                            ALT p = 0 FOR SIZE c3[0]
                              c3o[p] ? data
                                SEQ
                                  check(data, count+1, "B275n")
                                  check(o, 1, "B275o")
                                  check(p, 2, "B275p")
            ALT i = 0 FOR SIZE c3
              c3i IS c3[i] :
              ALT j = 0 FOR SIZE c3[0]
                INT data :
                c3i [j] ? data
                  SEQ
                    check(data, count, "B275q")
                    check(i,    0,     "B275r")
                    check(j,    1,     "B275s")
        :
        --}}}
        [2][2][2][2]CHAN OF INT c1 :
        [3][3]CHAN OF INT c2, c3 :
        PAR
          SEQ
            fred (0, c1, c2, c3)
            fred (2, c1, c2, c3)
            fred (3, c1, c2, c3)
            fred (4, c1, c2, c3)
          SEQ
            c1[1][1][1][1] ! 0
            c2[1][2] ! 1
            c2[0][1] ! 2
            c3[0][1] ! 3
            c1[1][1][1][1] ! 4
            c3[1][2] ! 5
    :
    bug.275 ()
    --}}}
    --{{{  bug 275a
    -- bug 275 from buglist
    PROC bug.275a ()
      PROTOCOL any IS ANY :
      --{{{  PROC main
      PROC main ([10]CHAN OF any c1, c2)
        INT s :
        INT one :
        SEQ
          s, one := (SIZE c2) - 1, 1
          ALT
            ALT i = 0 FOR SIZE c1
              INT x :
              c1 [i] ? x
                check (i, x, "B275aa")
            VAL size IS s + 1 :
            INT z, y :
            ALT j = 0 FOR size
              VAL index IS (j + one) - 1 :
              c2 [index] ? z
                SEQ
                  SEQ k = 0 FOR 500  -- make sure that k has high usage
                    y := k           -- and y too
                  check(index, z, "B275ab")
      :
      --}}}
      SEQ
        [10]CHAN OF any c1, c2 :
        PAR
          SEQ
            c2[(SIZE c2) - 1] ! (SIZE c2) - 1
            SEQ i = 0 FOR (SIZE c1) / 2
              c1[i*2] ! i*2
            SEQ j = 0 FOR (SIZE c2) / 2
              c2[((SIZE c2) - 1) -(j*2)] ! ((SIZE c2) - 1) - (j*2)
            SEQ i = 0 FOR SIZE c1
              SEQ
                c1 [i] ! i
                c2 [i] ! i
          SEQ i = 0 FOR ((SIZE c1) * 3) + 1
            main (c1, c2)
        -- nested replicators, and nested ALTs
        --{{{  PROC fred
        PROC fred (VAL INT count, [][][][]CHAN OF INT c1, [][]CHAN OF INT c2, c3)
          ALT
            ALT i = 0 FOR SIZE c2
              c2i IS c2[i] :
              ALT j = 0 FOR SIZE c2[0]
                INT data :
                c2i [j] ? data
                  SEQ
                    check(data, count, "B275ac")
                    check(i,    0,     "B275ad")
                    check(j,    1,     "B275ae")
            ALT i = 0 FOR SIZE c1
              ALT j = 0 FOR SIZE c1[0]
                ALT k = 0 FOR SIZE c1[0][0]
                  ALT l = 0 FOR SIZE c1[0][0][0]
                    INT data :
                    c1[i][j][k][l] ? data
                      SEQ
                        check(data, count, "B275af")
                        check(i, 1, "B275ag")
                        check(j, 1, "B275ah")
                        check(k, 1, "B275ai")
                        check(l, 1, "B275aj")
                        ALT
                          ALT m = 0 FOR SIZE c2
                            c2m IS c2[m] :
                            ALT n = 0 FOR SIZE c2[0]
                              c2m[n] ? data
                                SEQ
                                  check(data, count+1, "B275ak")
                                  check(m, 1, "B275al")
                                  check(n, 2, "B275am")
                          ALT o = 0 FOR SIZE c3
                            c3o IS c3[o] :
                            ALT p = 0 FOR SIZE c3[0]
                              c3o[p] ? data
                                SEQ
                                  check(data, count+1, "B275an")
                                  check(o, 1, "B275ao")
                                  check(p, 2, "B275ap")
            ALT i = 0 FOR SIZE c3
              c3i IS c3[i] :
              ALT j = 0 FOR SIZE c3[0]
                INT data :
                c3i [j] ? data
                  SEQ
                    check(data, count, "B275aq")
                    check(i,    0,     "B275ar")
                    check(j,    1,     "B275as")
        :
        --}}}
        [2][2][2][2]CHAN OF INT c1 :
        [3][3]CHAN OF INT c2, c3 :
        PAR
          SEQ
            fred (0, c1, c2, c3)
            fred (2, c1, c2, c3)
            fred (3, c1, c2, c3)
            fred (4, c1, c2, c3)
          SEQ
            c1[1][1][1][1] ! 0
            c2[1][2] ! 1
            c2[0][1] ! 2
            c3[0][1] ! 3
            c1[1][1][1][1] ! 4
            c3[1][2] ! 5
    :
    bug.275a ()
    --}}}
    --{{{  bug 275b
    -- bug 275 from buglist
    PROC bug.275b ()
      --{{{  PROC main
      PROC main ([10]CHAN OF INT c1, c2)
        INT s :
        INT one :
        SEQ
          s, one := (SIZE c2) - 1, 1
          ALT
            ALT i = 0 FOR SIZE c1
              INT x :
              c1 [i] ? x
                check (i, x, "B275ba")
            VAL size IS s + 1 :
            INT z, y :
            ALT j = 0 FOR size
              VAL index IS (j + one) - 1 :
              c2 [index] ? z
                SEQ
                  SEQ k = 0 FOR 500  -- make sure that k has high usage
                    y := k           -- and y too
                  check(index, z, "B275bb")
      :
      --}}}
      SEQ
        [10]CHAN OF INT c1, c2 :
        PAR
          SEQ
            c2[(SIZE c2) - 1] ! (SIZE c2) - 1
            SEQ i = 0 FOR (SIZE c1) / 2
              c1[i*2] ! i*2
            SEQ j = 0 FOR (SIZE c2) / 2
              c2[((SIZE c2) - 1) -(j*2)] ! ((SIZE c2) - 1) - (j*2)
            SEQ i = 0 FOR SIZE c1
              SEQ
                c1 [i] ! i
                c2 [i] ! i
          SEQ i = 0 FOR ((SIZE c1) * 3) + 1
            main (c1, c2)
        -- nested replicators, and nested ALTs
        --{{{  PROC fred
        PROC fred (VAL INT count, [][][][]CHAN OF INT c1, [][]CHAN OF INT c2, c3)
          ALT
            ALT i = 0 FOR SIZE c2
              c2i IS c2[i] :
              ALT j = 0 FOR SIZE c2[0]
                INT data :
                c2i [j] ? data
                  SEQ
                    check(data, count, "B275bc")
                    check(i,    0,     "B275bd")
                    check(j,    1,     "B275be")
            ALT i = 0 FOR SIZE c1
              ALT j = 0 FOR SIZE c1[0]
                ALT k = 0 FOR SIZE c1[0][0]
                  ALT l = 0 FOR SIZE c1[0][0][0]
                    INT data :
                    c1[i][j][k][l] ? data
                      SEQ
                        check(data, count, "B275bf")
                        check(i, 1, "B275bg")
                        check(j, 1, "B275bh")
                        check(k, 1, "B275bi")
                        check(l, 1, "B275bj")
                        ALT
                          ALT m = 0 FOR SIZE c2
                            c2m IS c2[m] :
                            ALT n = 0 FOR SIZE c2[0]
                              c2m[n] ? data
                                SEQ
                                  check(data, count+1, "B275bk")
                                  check(m, 1, "B275bl")
                                  check(n, 2, "B275bm")
                          ALT o = 0 FOR SIZE c3
                            c3o IS c3[o] :
                            ALT p = 0 FOR SIZE c3[0]
                              c3o[p] ? data
                                SEQ
                                  check(data, count+1, "B275bn")
                                  check(o, 1, "B275bo")
                                  check(p, 2, "B275bp")
            ALT i = 0 FOR SIZE c3
              c3i IS c3[i] :
              ALT j = 0 FOR SIZE c3[0]
                INT data :
                c3i [j] ? data
                  SEQ
                    check(data, count, "B275bq")
                    check(i,    0,     "B275br")
                    check(j,    1,     "B275bs")
        :
        --}}}
        [2][2][2][2]CHAN OF INT c1 :
        [3][3]CHAN OF INT c2, c3 :
        PAR
          SEQ
            fred (0, c1, c2, c3)
            fred (2, c1, c2, c3)
            fred (3, c1, c2, c3)
            fred (4, c1, c2, c3)
          SEQ
            c1[1][1][1][1] ! 0
            c2[1][2] ! 1
            c2[0][1] ! 2
            c3[0][1] ! 3
            c1[1][1][1][1] ! 4
            c3[1][2] ! 5
    :
    bug.275b()
    --}}}
    --{{{  bug 569
    PROC bug.569 ()
      PROTOCOL protocol
        CASE
          tag; INT
      :
      CHAN OF protocol c, d :
      PAR
        SEQ
          c ! tag; 55
          c ! tag; 66
          c ! tag; 77
        INT x :
        SEQ
          ALT
            d ? CASE
              -- no bodies here
            c ? CASE
              tag ; x
                check(x, 55, "B569a")
          ALT
            c ? CASE
              tag ; x
                check(x, 66, "B569b")
            d ? CASE
              -- no bodies here
          ALT
            c ? CASE
              tag ; x
                check(x, 77, "B569c")
            d ? CASE
              tag ; x  -- should never be chosen
                SEQ
                  check(1, 0, "B569d")
                  c ? CASE
                    -- no bodies here
                  check(x, 0, "B569e")
    :
    bug.569()
    --}}}
    --{{{  bug 407
    PROC bug.407()
      CHAN OF INT c :
      PAR
        INT x :
        ALT
          ALT i = 0 FOR 0
            TRUE & SKIP
              STOP
          c ? x
            check(x, 99, "B407a")
        c ! 99
    :
    bug.407()
    --}}}
    --{{{  bug 779
    PROC bug.779()
      [2]CHAN OF INT c :
      PAR
        c[0] ! 99
        INT data :
        ALT
          #IF DEFINED (COMPILER.TOCK)
          c[0] ? data
          #ELSE
          c[(INT a :
             VALOF
               a := 0
               RESULT a
            )] ? data
          #ENDIF
            check(data, 99, "B779a")
    :
    bug.779()
    --}}}
    --{{{  bug 1027
    PROC bug.1027()
      INT j :
      ALT i = -99 FOR 2 -- '2' makes sure that the other value of i is wrong
        PROC q ()
          SEQ
            check(i, -99, "B1027A")
            check(j, -99, "B1027B")
        :
        (i = (-99)) & SKIP
          PROC r ()
            SEQ
              check(i, -99, "B1027C")
              check(j, -99, "B1027D")
          :
          SEQ
            j := i
            q()
            r()
            check(i, -99, "B1027E")
            check(j, -99, "B1027F")
    :
    bug.1027()
    --}}}
    --{{{  bug 1159
    PROC bug.1159()
      CHAN OF INT c :
      BOOL FUNCTION f(VAL INT a, b, c, d, e) IS TRUE :
      INT FUNCTION g(VAL INT a, b, c, d, e, f) IS 0 :
      PAR
        ALT
          INT x :
          f(1,2,3,4,g(1,2,3,4,5,6)) & c ? x
            check(x, 99, "B1159")
        c ! 99
    :
    bug.1159()
    --}}}
    --{{{  bug TS/1900
    PROC bug.TS.1900()
    
      -- What we do with these tests is as follows:
      -- The bug is that the compiler is failing to regenerate temporaries
      -- in the disabling sequence. So what we want to test for is using
      -- the wrong value in a temporary.
    
      -- What I'll do is to have two identical 'shape' guards, where they
      -- both are TRUE; thus the first should be chosen.
      -- However, it fails to reevaluate the temporary in the disabling sequence,
      -- so the disabling sequence for the first guard picks up the temporary
      -- for the second one's enabling sequence, and thus fails.
      -- This should mean that the second guard is actually chosen
    
      --{{{  PROC local1
      PROC local1(CHAN OF INT c, VAL INT x, y, z, p, q, r)
      
        -- In this guard expression, "(x + z) + (y + x)" is evaluated into
        -- a temporary
      
        INT dummy :
        PRI ALT
          -- x = 2, y = 0, z = 1
          -- LHS = 5, RHS = 4
          ((x + y) + (z + x)) > ((x + z) + (y + z)) & c ? dummy
            check(1, 1, "B1900a")
          -- p = 4, q = 0, r = 2
          -- LHS = 10, RHS = 8
          ((p + q) + (r + p)) > ((p + r) + (q + r)) & c ? dummy
            check(0, 1, "B1900a")
      :
      --}}}
      --{{{  PROC local2
      PROC local2(CHAN OF INT c)
      
        -- In this guard expression, the rhs fn call is evaluated into
        -- a temporary
      
        INT FUNCTION  f4() IS  4 :
        INT FUNCTION  f5() IS  5 :
        INT FUNCTION  f8() IS  8 :
        INT FUNCTION f10() IS 10 :
        INT dummy :
        PRI ALT
          f5()  > f4() & c ? dummy
            check(1, 1, "B1900b")
          f10() > f8() & c ? dummy
            check(0, 1, "B1900b")
      :
      --}}}
      --{{{  PROC local3
      PROC local3(CHAN OF INT c)
      
        -- In this guard expression, "g(...)" is evaluated into
        -- a temporary
      
        BOOL FUNCTION f(VAL INT a, b, c, d) IS a > d :
        INT  FUNCTION g(VAL INT a, b, c, d, e) IS a :
        INT  dummy :
        PRI ALT
          f( 5, 0, 0, g(4, 0, 0, 0, 0)) & c ? dummy
            check(1, 1, "B1900c")
          f(10, 0, 0, g(8, 0, 0, 0, 0)) & c ? dummy
            check(0, 1, "B1900c")
      :
      --}}}
      CHAN OF INT c :
      PAR
        SEQ
          c ! 0
          c ! 0
          c ! 0
        SEQ
          local1(c, 2, 0, 1, 4, 0, 2)
          local2(c)
          local3(c)
    :
    bug.TS.1900()
    --}}}
    --{{{  bug TS/1893
    PROC bug.TS.1893()
      PROC local([10]CHAN OF INT c, d)
        ALT i = 0 FOR 10
          INT FUNCTION reads.free() IS i :
          INT FUNCTION f(VAL INT i) IS 9 - i :
          INT x:
          --c[f()] ? x
          c[f(i)] ? x
            d[x] ! reads.free()
      :
      [10]CHAN OF INT c, d :
      PAR
        INT i :
        SEQ
          c[6] ! 7
          d[7] ? i
          check(i, 3, "B1893a")
        local(c, d)
    :
    bug.TS.1893()
    --}}}
    --{{{  bug INSdi02047
    PROC bug.INSdi02047()
      VAL NotProcess.p IS MOSTNEG INT16 :
      PROC p (CHAN OF INT c, VAL [2]INT16 FptrReg)
        BOOL ok :
        INT x :
        SEQ
          PRI ALT
            (FptrReg[0] <> NotProcess.p) & SKIP
              ok := TRUE
            (FptrReg[1] = 0(INT16)) & SKIP
              ok := FALSE
            TRUE & SKIP
              ok := FALSE
          check.BOOL(ok, TRUE, "B02047a")
          PRI ALT
            (FptrReg[0] = NotProcess.p) & SKIP
              ok := FALSE
            (FptrReg[1] = 0(INT16)) & SKIP
              ok := FALSE
            TRUE & SKIP
              ok := TRUE
          check.BOOL(ok, TRUE, "B02047b")
          PRI ALT
            (FptrReg[0] <> NotProcess.p) & c ? x
              ok := TRUE
            (FptrReg[1] = 0(INT16)) & c ? x
              ok := FALSE
            c ? x
              ok := FALSE
          check.BOOL(ok, TRUE, "B02047c")
          PRI ALT
            (FptrReg[0] = NotProcess.p) & c ? x
              ok := FALSE
            (FptrReg[1] = 0(INT16)) & SKIP
              ok := FALSE
            c ? x
              ok := TRUE
          check.BOOL(ok, TRUE, "B02047d")
      :
      CHAN OF INT c :
      PAR
        SEQ
          c ! 99
          c ! 99
        p(c, [NotProcess.p + 1(INT16), NotProcess.p])
    :
    bug.INSdi02047()
    --}}}
    --{{{  bug INSdi02244
    PROC bug.INSdi02244()
      --{{{  PROC r
      PROC r([2]CHAN OF INT c, VAL INT index, []CHAN OF INT cc, INT x)
        ALT
          c[index] ? x
            SKIP
          ALT i = 0 FOR SIZE cc
            cc[i] ? x
              SKIP
      :
      --}}}
      --{{{  PROC s
      PROC s([2]CHAN OF INT c, VAL INT index, []CHAN OF INT cc, INT x)
        ALT
          c[index] ? x
            x := x - 1
          ALT i = 0 FOR SIZE cc
            cc[i] ? x
              x := x + i
      :
      --}}}
      [2]CHAN OF INT c, cc :
      VAL index IS 1 :
      SEQ
        PAR
          INT x :
          SEQ
            r(c, index, cc, x)
            check(x, 99, "di2244a")
            r(c, index, cc, x)
            check(x, 97, "di2244b")
            r(c, index, cc, x)
            check(x, 98, "di2244c")
    
            s(c, index, cc, x)
            check(x, 98, "di2244d")
            s(c, index, cc, x)
            check(x, 98, "di2244e")
            s(c, index, cc, x)
            check(x, 98, "di2244f")
          SEQ
            SEQ j = 0 FOR 2
              SEQ
                c[1]  ! 99
                cc[1] ! 97
                cc[0] ! 98
    :
    bug.INSdi02244()
    --}}}
    finish ()
:
