File: test_mtype.pml

package info (click to toggle)
spin 6.5.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,512 kB
  • sloc: ansic: 39,876; yacc: 1,021; makefile: 58; sh: 8
file content (61 lines) | stat: -rwxr-xr-x 1,038 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
mtype { one, two, three }

mtype:fruit = { appel, pear, banana }

mtype:sizes = { small, medium, large }

chan q = [0] of { mtype, mtype:fruit, mtype:sizes, int }

proctype recipient(mtype:fruit z; mtype y)
{	mtype a
	mtype:fruit b
	mtype:sizes c

	atomic {
		printf("z: "); printm(z); printf("\n");
		printf("y: "); printm(y); printf("\n");
	}

	q?a,b,c,_
//	printf("%e %e %e\n", a, b, c)
	atomic {
		printm(a)
		printm(b)
		printm(c)
		printf("\n")
	}
	q?c,a,b,_			// type errors
//	printf("%e %e %e\n", a, b, c)
	atomic {
		printm(a)
		printm(b)
		printm(c)
		printf("\n")
	}
}

init {
	mtype numbers, nn;
	mtype:fruit snack, ss;
	mtype:sizes package, pp;

	run recipient(pear, two)
//	run recipient(small, two)	// type error

//	package = pear		// type error

	numbers = one
	snack = pear
	package = large

//	printf("%e %e %e\n", numbers, snack, package)	// only in simulation mode
	printm(numbers)
	printm(snack)
	printm(package)
	printf("\n")

	q!numbers,snack,large,9		// ok
//	q!large,ss,pp,3			// 1 type error

	assert(false)
}