[vala] tests: Add a test for enum methods and constants



commit 7a851ad6181f2797595a7a4b28a4db0faf2d5e5a
Author: Sebastian Dröge <sebastian droege collabora co uk>
Date:   Thu Apr 8 10:28:46 2010 +0200

    tests: Add a test for enum methods and constants

 tests/enums/enums.vala |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/tests/enums/enums.vala b/tests/enums/enums.vala
index 2ee0b63..c9f913f 100644
--- a/tests/enums/enums.vala
+++ b/tests/enums/enums.vala
@@ -6,6 +6,17 @@ enum Maman.Foo {
 	VAL5 = 5
 }
 
+enum Maman.Fooish {
+	VAL1,
+	VAL2;
+
+	public int something () {
+		return (int) this;
+	}
+
+	public const int FOO = 2;
+}
+
 class Maman.Bar : Object {
 	public void run () {
 		stdout.printf (" %d", Foo.VAL2);
@@ -21,6 +32,12 @@ class Maman.Bar : Object {
 		Foo foo = 0;
 	}
 
+	static void test_enum_methods_constants () {
+		Fooish x = Fooish.VAL1;
+		stdout.printf ("%d", x.something ());
+		stdout.printf ("%d", Fooish.FOO);
+	}
+
 	public static int main () {
 		stdout.printf ("Enum Test: 1");
 		
@@ -30,6 +47,7 @@ class Maman.Bar : Object {
 		stdout.printf (" 6\n");
 
 		test_enums_0_conversion ();
+		test_enum_methods_constants ();
 
 		return 0;
 	}



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