Merge branch 'DontBreakDev' into FunctionCalls
This commit is contained in:
75
tests/given/test/functionValue.alpha
Normal file
75
tests/given/test/functionValue.alpha
Normal file
@ -0,0 +1,75 @@
|
||||
(* TEST: [-asc -tc] *)
|
||||
(* Type definitions *)
|
||||
|
||||
(* mapping type *)
|
||||
type string2int: string -> integer
|
||||
|
||||
(* array of functions *)
|
||||
type funArray: 1 -> string2int
|
||||
|
||||
(* record of functions *)
|
||||
type funRec: [ string2int: f; string2int: g ]
|
||||
|
||||
(* function returning function *)
|
||||
type integer_2_string2int: integer -> string2int
|
||||
|
||||
(* function returning function *)
|
||||
type string2int_2_integer: string2int -> integer
|
||||
|
||||
|
||||
type iXiXc: [integer: a; integer: b; character: c]
|
||||
|
||||
type iic2b: iXiXc -> Boolean
|
||||
|
||||
(* Function declarations using the above type definitions *)
|
||||
function a: string2int
|
||||
function b: integer_2_string2int
|
||||
function c: string2int_2_integer
|
||||
|
||||
function d: iic2b
|
||||
|
||||
d(x,y,z) := {
|
||||
[string: s]
|
||||
return 0;
|
||||
}
|
||||
|
||||
function entry: string2int
|
||||
|
||||
a(x) := {
|
||||
[string : s]
|
||||
s := x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
b(x) := {
|
||||
[integer: i]
|
||||
i := x;
|
||||
return a;
|
||||
}
|
||||
|
||||
c(x) := {
|
||||
[string: s]
|
||||
s := "Hi!";
|
||||
return x(s);
|
||||
}
|
||||
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[integer: result; string2int: f; integer: temp]
|
||||
temp := a("Hello");
|
||||
f := b(temp);
|
||||
result := c(f);
|
||||
if (d(1,2,'c'))
|
||||
then {
|
||||
result := 0;
|
||||
}
|
||||
else {
|
||||
[ Boolean : b]
|
||||
result := entry("hello");
|
||||
}
|
||||
result := c(f);
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user