shithub: mc

Download patch

ref: 184dbb71cbea184856fc28c94f17f19b567472fe
parent: a5495bfdfcd30732c70b450df77d4df03f6b4a0d
author: Ori Bernstein <[email protected]>
date: Tue Aug 19 11:27:19 EDT 2014

Add test for big condition arguments.

    Don't enable it yet. Need to implement deep comparisons first.

--- /dev/null
+++ b/test/bigcondarg.myr
@@ -1,0 +1,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: %t, got, %t: pass\n", expected, actual)
+	else
+		std.put("a == b: expected: %t, got, %t: 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)
+}
+
+