[vala/0.54] tests: Add more "statement" tests for genie to increase coverage



commit b0a9d7b36a6e122487933ed8c31bf921b186a8c8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Nov 6 15:35:12 2021 +0100

    tests: Add more "statement" tests for genie to increase coverage

 tests/Makefile.am                         | 11 ++++
 tests/genie/case.c-expected               | 41 ++++++++++++++
 tests/genie/case.gs                       |  6 ++
 tests/genie/do-while.c-expected           | 40 +++++++++++++
 tests/genie/do-while.gs                   |  8 +++
 tests/genie/for-downto.c-expected         | 49 ++++++++++++++++
 tests/genie/for-downto.gs                 |  3 +
 tests/genie/for-in.c-expected             | 93 +++++++++++++++++++++++++++++++
 tests/genie/for-in.gs                     |  4 ++
 tests/genie/for-to.c-expected             | 49 ++++++++++++++++
 tests/genie/for-to.gs                     |  3 +
 tests/genie/initializer-list.c-expected   | 82 +++++++++++++++++++++++++++
 tests/genie/initializer-list.gs           |  7 +++
 tests/genie/print.c-expected              | 25 +++++++++
 tests/genie/print.gs                      |  2 +
 tests/genie/sizeof.c-expected             | 32 +++++++++++
 tests/genie/sizeof.gs                     |  3 +
 tests/genie/try-except-finally.c-expected | 85 ++++++++++++++++++++++++++++
 tests/genie/try-except-finally.gs         | 13 +++++
 tests/genie/typeof.c-expected             | 33 +++++++++++
 tests/genie/typeof.gs                     |  3 +
 tests/genie/while.c-expected              | 30 ++++++++++
 tests/genie/while.gs                      |  6 ++
 23 files changed, 628 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 194eaf10c..a453523fd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1227,6 +1227,7 @@ TESTS = \
        version/since-local-variable.test \
        version/since-method.test \
        version/since-parameter.test \
+       genie/case.gs \
        genie/class.gs \
        genie/class-field.gs \
        genie/class-init.gs \
@@ -1240,9 +1241,13 @@ TESTS = \
        genie/control-flow-if.gs \
        genie/control-flow-if-identity.gs \
        genie/control-flow-if-less-than.gs \
+       genie/do-while.gs \
        genie/enum.gs \
        genie/enum-with-keyword-values.gs \
        genie/exception.gs \
+       genie/for-downto.gs \
+       genie/for-in.gs \
+       genie/for-to.gs \
        genie/function.gs \
        genie/function-returns-closure.gs \
        genie/function-with-argument.gs \
@@ -1250,6 +1255,7 @@ TESTS = \
        genie/indentation-with-spaces.gs \
        genie/init.gs \
        genie/init-int.gs \
+       genie/initializer-list.gs \
        genie/interface.gs \
        genie/literal-boolean-assignment.gs \
        genie/literal-boolean.gs \
@@ -1296,8 +1302,13 @@ TESTS = \
        genie/preparser.gs \
        genie/preparser-not.gs \
        genie/preparser-or-expression.gs \
+       genie/print.gs \
+       genie/sizeof.gs \
        genie/struct.gs \
        genie/struct-after-class.gs \
+       genie/try-except-finally.gs \
+       genie/typeof.gs \
+       genie/while.gs \
        glib/conditional-glib-api.vala \
        $(LINUX_TESTS) \
        $(NULL)
diff --git a/tests/genie/case.c-expected b/tests/genie/case.c-expected
new file mode 100644
index 000000000..5bca8f57c
--- /dev/null
+++ b/tests/genie/case.c-expected
@@ -0,0 +1,41 @@
+/* genie_case.c generated by valac, the Vala compiler
+ * generated from genie_case.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       gint a = 0;
+       a = 13;
+       switch (a) {
+               case 13:
+               {
+                       break;
+               }
+               case 23:
+               case 42:
+               {
+                       break;
+               }
+               default:
+               {
+                       break;
+               }
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/case.gs b/tests/genie/case.gs
new file mode 100644
index 000000000..405587627
--- /dev/null
+++ b/tests/genie/case.gs
@@ -0,0 +1,6 @@
+init
+       a:int = 13
+       case a
+               when 13
+               when 23, 42
+               default
diff --git a/tests/genie/do-while.c-expected b/tests/genie/do-while.c-expected
new file mode 100644
index 000000000..d5f3c5fd8
--- /dev/null
+++ b/tests/genie/do-while.c-expected
@@ -0,0 +1,40 @@
+/* genie_do_while.c generated by valac, the Vala compiler
+ * generated from genie_do_while.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       while (TRUE) {
+               break;
+       }
+       {
+               gboolean _tmp0_ = FALSE;
+               _tmp0_ = TRUE;
+               while (TRUE) {
+                       if (!_tmp0_) {
+                               if (!FALSE) {
+                                       break;
+                               }
+                       }
+                       _tmp0_ = FALSE;
+                       continue;
+               }
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/do-while.gs b/tests/genie/do-while.gs
new file mode 100644
index 000000000..6ffb22757
--- /dev/null
+++ b/tests/genie/do-while.gs
@@ -0,0 +1,8 @@
+init
+       do
+               break
+       while true
+
+       do
+               continue
+       while false
diff --git a/tests/genie/for-downto.c-expected b/tests/genie/for-downto.c-expected
new file mode 100644
index 000000000..e286dbada
--- /dev/null
+++ b/tests/genie/for-downto.c-expected
@@ -0,0 +1,49 @@
+/* genie_for_downto.c generated by valac, the Vala compiler
+ * generated from genie_for_downto.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       {
+               gint i = 0;
+               i = 42;
+               {
+                       gboolean _tmp0_ = FALSE;
+                       _tmp0_ = TRUE;
+                       while (TRUE) {
+                               if (!_tmp0_) {
+                                       gint _tmp1_;
+                                       _tmp1_ = i;
+                                       i = _tmp1_ - 1;
+                               }
+                               _tmp0_ = FALSE;
+                               if (!(i >= 23)) {
+                                       break;
+                               }
+                               _vala_assert (i >= 23, "i >= 23");
+                       }
+               }
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/for-downto.gs b/tests/genie/for-downto.gs
new file mode 100644
index 000000000..1a7163717
--- /dev/null
+++ b/tests/genie/for-downto.gs
@@ -0,0 +1,3 @@
+init
+       for i:int = 42 downto 23
+               assert( i >= 23)
diff --git a/tests/genie/for-in.c-expected b/tests/genie/for-in.c-expected
new file mode 100644
index 000000000..461ae185e
--- /dev/null
+++ b/tests/genie/for-in.c-expected
@@ -0,0 +1,93 @@
+/* genie_for_in.c generated by valac, the Vala compiler
+ * generated from genie_for_in.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+static void _vala_array_destroy (gpointer array,
+                          gssize array_length,
+                          GDestroyNotify destroy_func);
+static void _vala_array_free (gpointer array,
+                       gssize array_length,
+                       GDestroyNotify destroy_func);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       gchar* a[3] = {0};
+       gchar* _tmp0_;
+       gchar* _tmp1_;
+       gchar* _tmp2_;
+       gchar* _tmp3_[3] = {0};
+       _tmp0_ = g_strdup ("a");
+       _tmp1_ = g_strdup ("b");
+       _tmp2_ = g_strdup ("c");
+       _tmp3_[0] = _tmp0_;
+       _tmp3_[1] = _tmp1_;
+       _tmp3_[2] = _tmp2_;
+       memcpy (a, _tmp3_, 3 * sizeof (gchar*));
+       {
+               gchar** s_collection = NULL;
+               gint s_collection_length1 = 0;
+               gint _s_collection_size_ = 0;
+               gint s_it = 0;
+               s_collection = a;
+               s_collection_length1 = 3;
+               for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
+                       gchar* _tmp4_;
+                       gchar* s = NULL;
+                       _tmp4_ = g_strdup (s_collection[s_it]);
+                       s = _tmp4_;
+                       {
+                               const gchar* _tmp5_;
+                               _tmp5_ = s;
+                               _vala_assert (g_strcmp0 (_tmp5_, "d") != 0, "s != \"d\"");
+                               _g_free0 (s);
+                       }
+               }
+       }
+       _vala_array_destroy (a, 3, (GDestroyNotify) g_free);
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
+static void
+_vala_array_destroy (gpointer array,
+                     gssize array_length,
+                     GDestroyNotify destroy_func)
+{
+       if ((array != NULL) && (destroy_func != NULL)) {
+               gssize i;
+               for (i = 0; i < array_length; i = i + 1) {
+                       if (((gpointer*) array)[i] != NULL) {
+                               destroy_func (((gpointer*) array)[i]);
+                       }
+               }
+       }
+}
+
+static void
+_vala_array_free (gpointer array,
+                  gssize array_length,
+                  GDestroyNotify destroy_func)
+{
+       _vala_array_destroy (array, array_length, destroy_func);
+       g_free (array);
+}
+
diff --git a/tests/genie/for-in.gs b/tests/genie/for-in.gs
new file mode 100644
index 000000000..890e1b1ff
--- /dev/null
+++ b/tests/genie/for-in.gs
@@ -0,0 +1,4 @@
+init
+       a:string[] = { "a", "b", "c" }
+       for s:string in a
+               assert( s != "d" )
diff --git a/tests/genie/for-to.c-expected b/tests/genie/for-to.c-expected
new file mode 100644
index 000000000..5b3cf80f3
--- /dev/null
+++ b/tests/genie/for-to.c-expected
@@ -0,0 +1,49 @@
+/* genie_for_to.c generated by valac, the Vala compiler
+ * generated from genie_for_to.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       {
+               gint i = 0;
+               i = 0;
+               {
+                       gboolean _tmp0_ = FALSE;
+                       _tmp0_ = TRUE;
+                       while (TRUE) {
+                               if (!_tmp0_) {
+                                       gint _tmp1_;
+                                       _tmp1_ = i;
+                                       i = _tmp1_ + 1;
+                               }
+                               _tmp0_ = FALSE;
+                               if (!(i <= 23)) {
+                                       break;
+                               }
+                               _vala_assert (i < 42, "i < 42");
+                       }
+               }
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/for-to.gs b/tests/genie/for-to.gs
new file mode 100644
index 000000000..771bc305b
--- /dev/null
+++ b/tests/genie/for-to.gs
@@ -0,0 +1,3 @@
+init
+       for i:int = 0 to 23
+               assert( i < 42)
diff --git a/tests/genie/initializer-list.c-expected b/tests/genie/initializer-list.c-expected
new file mode 100644
index 000000000..9bc4e7baf
--- /dev/null
+++ b/tests/genie/initializer-list.c-expected
@@ -0,0 +1,82 @@
+/* genie_initializer_list.c generated by valac, the Vala compiler
+ * generated from genie_initializer_list.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+static void _vala_array_destroy (gpointer array,
+                          gssize array_length,
+                          GDestroyNotify destroy_func);
+static void _vala_array_free (gpointer array,
+                       gssize array_length,
+                       GDestroyNotify destroy_func);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       gchar* s[3] = {0};
+       gchar* _tmp0_;
+       gchar* _tmp1_;
+       gchar* _tmp2_;
+       gchar* _tmp3_[3] = {0};
+       const gchar* _tmp4_;
+       const gchar* _tmp5_;
+       const gchar* _tmp6_;
+       _tmp0_ = g_strdup ("a");
+       _tmp1_ = g_strdup ("b");
+       _tmp2_ = g_strdup ("c");
+       _tmp3_[0] = _tmp0_;
+       _tmp3_[1] = _tmp1_;
+       _tmp3_[2] = _tmp2_;
+       memcpy (s, _tmp3_, 3 * sizeof (gchar*));
+       _vala_assert (3 == 3, "s.length == 3");
+       _tmp4_ = s[0];
+       _vala_assert (g_strcmp0 (_tmp4_, "a") == 0, "s[0] == \"a\"");
+       _tmp5_ = s[1];
+       _vala_assert (g_strcmp0 (_tmp5_, "b") == 0, "s[1] == \"b\"");
+       _tmp6_ = s[2];
+       _vala_assert (g_strcmp0 (_tmp6_, "c") == 0, "s[2] == \"c\"");
+       _vala_array_destroy (s, 3, (GDestroyNotify) g_free);
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
+static void
+_vala_array_destroy (gpointer array,
+                     gssize array_length,
+                     GDestroyNotify destroy_func)
+{
+       if ((array != NULL) && (destroy_func != NULL)) {
+               gssize i;
+               for (i = 0; i < array_length; i = i + 1) {
+                       if (((gpointer*) array)[i] != NULL) {
+                               destroy_func (((gpointer*) array)[i]);
+                       }
+               }
+       }
+}
+
+static void
+_vala_array_free (gpointer array,
+                  gssize array_length,
+                  GDestroyNotify destroy_func)
+{
+       _vala_array_destroy (array, array_length, destroy_func);
+       g_free (array);
+}
+
diff --git a/tests/genie/initializer-list.gs b/tests/genie/initializer-list.gs
new file mode 100644
index 000000000..baa02457f
--- /dev/null
+++ b/tests/genie/initializer-list.gs
@@ -0,0 +1,7 @@
+init
+       s:string[] = { "a", "b", "c" }
+
+       assert( s.length == 3 )
+       assert( s[0] == "a" )
+       assert( s[1] == "b" )
+       assert( s[2] == "c" )
diff --git a/tests/genie/print.c-expected b/tests/genie/print.c-expected
new file mode 100644
index 000000000..d74c80c1e
--- /dev/null
+++ b/tests/genie/print.c-expected
@@ -0,0 +1,25 @@
+/* genie_print.c generated by valac, the Vala compiler
+ * generated from genie_print.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       g_print ("%s = %i + %.4f\n", "a", 42, 3.1415);
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/print.gs b/tests/genie/print.gs
new file mode 100644
index 000000000..8c82e3e1e
--- /dev/null
+++ b/tests/genie/print.gs
@@ -0,0 +1,2 @@
+init
+       print( "%s = %i + %.4f", "a", 42, 3.1415 )
diff --git a/tests/genie/sizeof.c-expected b/tests/genie/sizeof.c-expected
new file mode 100644
index 000000000..18c1deaac
--- /dev/null
+++ b/tests/genie/sizeof.c-expected
@@ -0,0 +1,32 @@
+/* genie_sizeof.c generated by valac, the Vala compiler
+ * generated from genie_sizeof.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       gulong a = 0UL;
+       a = sizeof (guint32);
+       _vala_assert (a == ((gulong) 4), "a == 4");
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/sizeof.gs b/tests/genie/sizeof.gs
new file mode 100644
index 000000000..db7d659e5
--- /dev/null
+++ b/tests/genie/sizeof.gs
@@ -0,0 +1,3 @@
+init
+       a:ulong = sizeof( uint32 )
+       assert( a == 4 )
diff --git a/tests/genie/try-except-finally.c-expected b/tests/genie/try-except-finally.c-expected
new file mode 100644
index 000000000..4c945480d
--- /dev/null
+++ b/tests/genie/try-except-finally.c-expected
@@ -0,0 +1,85 @@
+/* genie_try_except_finally.c generated by valac, the Vala compiler
+ * generated from genie_try_except_finally.gs, do not modify */
+
+#include <gio/gio.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if !defined(VALA_EXTERN)
+#if defined(_MSC_VER)
+#define VALA_EXTERN __declspec(dllexport) extern
+#elif __GNUC__ >= 4
+#define VALA_EXTERN __attribute__((visibility("default"))) extern
+#else
+#define VALA_EXTERN extern
+#endif
+#endif
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+VALA_EXTERN void test (GError** error);
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+void
+test (GError** error)
+{
+       GError* _tmp0_;
+       GError* _inner_error0_ = NULL;
+       _tmp0_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "failed");
+       _inner_error0_ = _tmp0_;
+       g_propagate_error (error, _inner_error0_);
+       return;
+}
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       gint a = 0;
+       GError* _inner_error0_ = NULL;
+       a = 0;
+       {
+               gint _tmp0_;
+               _tmp0_ = a;
+               a = _tmp0_ + 1;
+               test (&_inner_error0_);
+               if (G_UNLIKELY (_inner_error0_ != NULL)) {
+                       goto __catch0_g_error;
+               }
+       }
+       goto __finally0;
+       __catch0_g_error:
+       {
+               gint _tmp1_;
+               g_clear_error (&_inner_error0_);
+               _tmp1_ = a;
+               a = _tmp1_ + 1;
+       }
+       __finally0:
+       {
+               GError* _inner_error1_ = NULL;
+               gint _tmp2_;
+               _tmp2_ = a;
+               a = _tmp2_ + 1;
+       }
+       if (G_UNLIKELY (_inner_error0_ != NULL)) {
+               g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
+               g_clear_error (&_inner_error0_);
+               return;
+       }
+       _vala_assert (a == 3, "a == 3");
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/try-except-finally.gs b/tests/genie/try-except-finally.gs
new file mode 100644
index 000000000..038995c58
--- /dev/null
+++ b/tests/genie/try-except-finally.gs
@@ -0,0 +1,13 @@
+def test() raises IOError, Error
+       raise new IOError.FAILED( "failed" )
+
+init
+       a:int = 0
+       try
+               a++
+               test()
+       except e:Error
+               a++
+       finally
+               a++
+       assert( a == 3 )
diff --git a/tests/genie/typeof.c-expected b/tests/genie/typeof.c-expected
new file mode 100644
index 000000000..0428b636b
--- /dev/null
+++ b/tests/genie/typeof.c-expected
@@ -0,0 +1,33 @@
+/* genie_typeof.c generated by valac, the Vala compiler
+ * generated from genie_typeof.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       GType a = 0UL;
+       a = G_TYPE_INT;
+       _vala_assert (a == G_TYPE_INT, "a == Type.INT");
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/typeof.gs b/tests/genie/typeof.gs
new file mode 100644
index 000000000..0069d1b49
--- /dev/null
+++ b/tests/genie/typeof.gs
@@ -0,0 +1,3 @@
+init
+       a:Type = typeof( int )
+       assert( a == Type.INT )
diff --git a/tests/genie/while.c-expected b/tests/genie/while.c-expected
new file mode 100644
index 000000000..42a2f172f
--- /dev/null
+++ b/tests/genie/while.c-expected
@@ -0,0 +1,30 @@
+/* genie_while.c generated by valac, the Vala compiler
+ * generated from genie_while.gs, do not modify */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+static void _vala_main (gchar** args,
+                 gint args_length1);
+
+static void
+_vala_main (gchar** args,
+            gint args_length1)
+{
+       while (TRUE) {
+               break;
+       }
+       while (TRUE) {
+               break;
+       }
+}
+
+int
+main (int argc,
+      char ** argv)
+{
+       _vala_main (argv, argc);
+       return 0;
+}
+
diff --git a/tests/genie/while.gs b/tests/genie/while.gs
new file mode 100644
index 000000000..aed846938
--- /dev/null
+++ b/tests/genie/while.gs
@@ -0,0 +1,6 @@
+init
+       while true do
+               break
+
+       while false
+               assert_not_reached()


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