31 lines
615 B
Plaintext
31 lines
615 B
Plaintext
(* TEST: [-asc -tc] *)
|
|
|
|
(* Type definitions *)
|
|
type int2int: integer -> integer
|
|
type string2int: string -> integer
|
|
|
|
(* Function declarations
|
|
They use the above type definitions
|
|
*)
|
|
function square : int2int
|
|
function entry : string2int
|
|
|
|
(* Function definition
|
|
Functions must be declared before they are defined
|
|
*)
|
|
square(x) := {
|
|
return x * x;
|
|
}
|
|
|
|
(* Function definition
|
|
entry is the first function called
|
|
*)
|
|
entry(arg) := {
|
|
[ integer: input ; integer: expected ; integer: actual ; Boolean: result ]
|
|
input := 7;
|
|
expected := 49;
|
|
actual := square(input);
|
|
result := expected = actual;
|
|
return 0;
|
|
}
|