[vala] Add man or boy test



commit a70502446b65d34a6508ce33a8b28c4a12441598
Author: Jürg Billeter <j bitron ch>
Date:   Tue Sep 15 17:52:59 2009 +0200

    Add man or boy test

 tests/Makefile.am           |    1 +
 tests/methods/closures.test |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a3f0535..bde7362 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -22,6 +22,7 @@ TESTS = \
 	basic-types/pointers.test \
 	namespaces.test \
 	methods/lambda.test \
+	methods/closures.test \
 	control-flow/break.test \
 	control-flow/expressions-conditional.test \
 	control-flow/for.test \
diff --git a/tests/methods/closures.test b/tests/methods/closures.test
new file mode 100644
index 0000000..526621a
--- /dev/null
+++ b/tests/methods/closures.test
@@ -0,0 +1,19 @@
+
+Program: test
+
+delegate int Func ();
+
+int A (int k, Func x1, Func x2, Func x3, Func x4, Func x5) {
+	Func B = null;
+	B = () => {
+		k = k - 1;
+		return A (k, B, x1, x2, x3, x4);
+	};
+	return k <= 0 ? x4 () + x5 () : B ();
+}
+
+void main () {
+	int result = A (10, () => 1, () => -1, () => -1, () => 1, () => 0);
+	assert (result == -67);
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]