tock-mirror/testcases/automatic/usage-check-1.occ.test

194 lines
3.5 KiB
Plaintext

-- This file tests simple array uses without replication
-- Four unknown variables are available; x, y, z.
-- Two arrays are automatically declared; a (size 10) and b (size 12)
PROC p(INT x, y, z)
[10]INT a:
[12]INT b:
PAR
%%
:
PROC m()
SKIP
:
%PASS Distinct constants
a[0] := 3
a[1] := 4
a[4] := 5
%FAIL Identical constants
a[0] := 3
a[0] := 4
%FAIL Identical constants, PAR assign
a[0],a[0] := 3,4
%PASS Self-assign
a[0] := a[0]
a[1] := a[1]
%PASS Self-assign, PAR assign
a[0],a[1] := a[0],a[1]
%PASS PAR assign swap
a[0],a[1] := a[1],a[0]
%PASS Same constant, different array
a[0] := 3
b[0] := 4
%FAIL Identical variables
x := 3
x := 4
%FAIL Identical variables deep within a PAR
PAR
PAR
x := 3
x := 4
SKIP
SKIP
%PASS Identical variables deep within a PAR, but SEQ
PAR
SEQ
x := 3
x := 4
SKIP
SKIP
%FAIL Identical variables, PAR assign
x,x := 3,4
%FAIL Variable and a constant
a[0] := 3
a[x] := 4
%PASS Out of bounds variable overlap #1
a[x * 10] := 3
a[(y * 9) + 1] := 4
%PASS Out of bounds variable overlap #2
a[x * 11] := 3
a[(y * 10) + 1] := 4
%FAIL In bounds variable overlap
a[x * 9] := 3
a[(y * 8) + 1] := 4
%PASS Overlap with constants, but in sequence
SEQ
a[0] := 4
a[0] := 5
a[1] := 6
%FAIL Overlap with constants in nested PAR
PAR
a[0] := 4
a[0] := 5
a[1] := 6
%PASS Overlapping constants in reading
a[1] := a[0]
a[2] := a[0]
%FAIL Two variables
a[x] := 3
a[y] := 5
%PASS Multiplied variables
a[x*y] := 3
a[(x*y) + 1] := 5
%PASS Modulo variable (c.d.) and a constant, safe
a[x REM 3] := 3
a[3] := 4
%FAIL Modulo variable (c.d.) and a constant, unsafe
a[x REM 3] := 3
a[2] := 4
%FAIL Modulo variable (v.d.) and a constant
a[x REM y] := 3
a[0] := 4
%FAIL Modulo variable (v.d.) and normal variable (unsafe)
a[x REM y] := 3
a[x + 1] := 4
%PASS Modulo variable (v.d.) and normal variable (safe)
a[x REM y] := 3
a[y] := 4
%FAIL Overlap with items in nested replication
a[0] := 3
PAR i = 0 FOR 6
a[i] := 4
%PASS Near-overlap with items in nested replication
a[0] := 3
PAR i = 1 FOR 6
a[i] := 4
%FAIL Overlap with replicator start
x := 3
PAR i = x FOR 6
a[i] := 4
%FAIL Overlap with replicator count
x := 3
PAR i = 1 FOR x
a[i] := 4
%PASS Branch inside parallel
IF
x < 0
y := 0
TRUE
y := 2
%PASS PAR inside branch inside parallel
IF
x < 0
PAR
x := 3
y := 4
TRUE
PAR
x := 2
y := 3
%PASS PAR with unuseable (but safe) division #1
a[x / y] := 3
a[(x / y) + 1] := 3
%PASS PAR with unuseable (but safe) division #2
a[x / (y * z)] := 3
a[(x / (z * y)) + 1] := 3
%PASS PAR with confusing multiplied indices #1
a[x * y] := 3
a[(y * x) + 1] := 3
%PASS PAR with confusing multiplied indices #2
a[(x * y) * z] := 3
a[((y * z) * x) + 1] := 3
a[(y * (z * x)) + 2] := 3
a[((x * z) * y) + 3] := 3
%PASS PAR with confusing multiplied indices #3
a[(x * y) / 3] := 3
a[((y * x) / 3) + 1] := 3
%PASS PAR with confusing multiplied indices #4
a[x*(x+y)] := 3
a[((x*x) + (x*y)) + 1] := 3
%PASS PAR with confusing multiplied indices #5
a[(x REM z)*(x+y)] := 3
a[(((x REM z)*x) + ((x REM z)*y)) + 1] := 3
%