1.2.8. test/regress/rt-1.01.08

Start felix section to test/regress/rt-1.01.08-0.flx[1 /1 ]
     1: #line 374 "./lpsrc/flx_regress.pak"
     2: //Check closures
     3: #import <flx.flxh>
     4: // closure formation test
     5: 
     6: // primitive function
     7: fun appl(x:int, f:int * int -> int):int = {
     8:   return f (x,x);
     9: }
    10: 
    11: print "closure of add primitive ";
    12: print (appl (2, add of (int*int))); endl;
    13: 
    14: // struct as function
    15: struct X { x:int; }
    16: fun execX(p:int->X):X = { return p(1); }
    17: proc xprint(x:X){ print "struct X"; }
    18: xprint (execX (X of (int))); endl;
    19: xprint (execX (X)); endl;
    20: 
    21: // struct get projection as function
    22: fun execx(p:X->int,a:X):int => p a;
    23: proc pprint(x:int){ print "struct X: x get projection "; print x; }
    24: 
    25: // note: old get_x method not supported now!
    26: fun getx(a:X):int=>a.x;
    27: pprint (execx (getx of (X), X(42))); endl;
    28: 
    29: // C struct as function
    30: header """
    31: struct CX {int x; };
    32: """;
    33: 
    34: cstruct CX { x:int; }
    35: fun execCX(p:int->CX):CX = { return p(1); }
    36: proc xprint(x:CX){ print "struct CX"; }
    37: xprint (execCX (CX of (int))); endl;
    38: xprint (execCX (CX)); endl;
    39: 
    40: 
    41: // anonymous variant type constructor as function
    42: typedef Y = 1 + int;
    43: fun exec2(y2:int->Y,a:int):Y= { return  y2 a; }
    44: proc yprint(y:Y) { print "union Y"; }
    45: yprint (exec2(case 1 of Y, 1)); endl;
    46: 
    47: // named variant type constructor as function
    48: union U = | A | B of int;
    49: fun exec3(y2:int->U,a:int):U= { return  y2 a; }
    50: proc xprint(y:U) { print "union U"; }
    51: xprint (exec3(B of (int), 1)); endl;
End felix section to test/regress/rt-1.01.08-0.flx[1]
Start data section to test/regress/rt-1.01.08-0.expect[1 /1 ]
     1: closure of add primitive 4
     2: struct X
     3: struct X
     4: struct X: x get projection 42
     5: struct CX
     6: struct CX
     7: union Y
     8: union U
End data section to test/regress/rt-1.01.08-0.expect[1]