summaryrefslogtreecommitdiff
path: root/test/bigcondarg.myr
blob: 6af216e045e03146a8e5a14be873fa20632e746b (plain)
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
62
63
64
65
use std

type u = union
	`Foo int
	`Bar char
	`Baz byte
;;

type s = struct
	x : int
	y : char
	z : byte
;;

generic expect = {a : @a, b : @a, expected : bool
	var actual

	if a == b
		actual = true
	else
		actual = false
	;;
	if actual == expected
		std.put("a == b: expected: {}, got, {}: pass\n", expected, actual)
	else
		std.put("a == b: expected: {}, got, {}: fail\n", expected, actual)
	;;
}

const main = {
	var u1 : u, u2 : u
	var s1 : s, s2 : s

	/* equal */
	u1 = `Foo 123
	u2 = `Foo 123
	expect(u1, u2, true)
	s1 = [.x=123, .y='a', .z=55]
	s2 = [.x=123, .y='a', .z=55]
	expect(s1, s2, true)

	/* varying first values */
	u1 = `Foo 123
	u2 = `Bar 'x'
	expect(u1, u2, false)
	s1 = [.x=124, .y='a', .z=55]
	s2 = [.x=123, .y='a', .z=55]
	expect(s1, s2, false)

	/* varying later values  */
	u1 = `Foo 123
	u2 = `Foo 124
	expect(u1, u2, false)
	s1 = [.x=123, .y='b', .z=55]
	s2 = [.x=123, .y='c', .z=55]
	expect(s1, s2, false)
	u1 = `Bar 'x'
	u2 = `Bar 'y'
	expect(u1, u2, false)
	s1 = [.x=123, .y='b', .z=57]
	s2 = [.x=123, .y='b', .z=56]
	expect(s1, s2, false)
}