tock-mirror/testcases/automatic/direction-decorators-3.occ.test
Adam Sampson 62a0873d3d Implement channel direction decorators.
This is mostly straightforward: modify the parser to allow direction
decorators in the right places, and extend the type checker to match.
There's some slight awkwardness in that some of the Types functions
have to perform the same checks as the type checker (e.g. directing a
non-channel), so I've tidied up their error messages a bit.

At the backend, I've just added a little pass to strip out all the
DirectedVariables, since the other backend passes don't handle them
gracefully. From the occam/C point of view this is fine, but I'm not
sure if it's going to cause problems for C++.
2008-06-09 21:35:20 +00:00

62 lines
886 B
Plaintext

-- This file tests direction decorators for formals.
PROC main ()
INT n:
SEQ
%%
SKIP
:
%PASS Nothing to do
%PASS Abbreviate unknown as input
PROC p (CHAN INT c)
CHAN INT in? IS c?:
SKIP
:
%PASS Abbreviate input as input
PROC p (CHAN INT c?)
CHAN INT in? IS c?:
SKIP
:
%FAIL Abbreviate input as output
PROC p (CHAN INT c?)
CHAN INT out! IS c?:
SKIP
:
%PASS Use unknown as input
PROC p (CHAN INT c)
c ? n
:
%PASS Use input as input
PROC p (CHAN INT c?)
c ? n
:
%FAIL Use input as output
PROC p (CHAN INT c?)
c ! 42
:
%PASS Use unknown array as input
PROC p ([]CHAN INT cs)
cs[0] ? n
:
%PASS Use input array as input
PROC p ([]CHAN INT cs?)
cs[0] ? n
:
%FAIL Use input array as output
PROC p ([]CHAN INT cs?)
cs[0] ! 42
:
%