summaryrefslogtreecommitdiff
path: root/test cases/vala
diff options
context:
space:
mode:
authorIgor Gnatenko <i.gnatenko.brain@gmail.com>2015-07-02 00:23:52 +0300
committerIgor Gnatenko <i.gnatenko.brain@gmail.com>2015-07-02 00:23:52 +0300
commitd7ca9eee5a5960a63fdf70edea119afb1db962fc (patch)
tree4c1149a1300fe5f9079df30872b85e49329a8ffd /test cases/vala
parent19ae286aff8827bcc2334dc3daf4e60bba6f32ab (diff)
downloadmeson-d7ca9eee5a5960a63fdf70edea119afb1db962fc.tar.gz
vala: add support for --target-glib
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Diffstat (limited to 'test cases/vala')
-rw-r--r--test cases/vala/5 target glib/GLib.Thread.vala41
-rw-r--r--test cases/vala/5 target glib/meson.build6
2 files changed, 47 insertions, 0 deletions
diff --git a/test cases/vala/5 target glib/GLib.Thread.vala b/test cases/vala/5 target glib/GLib.Thread.vala
new file mode 100644
index 000000000..27c0fca17
--- /dev/null
+++ b/test cases/vala/5 target glib/GLib.Thread.vala
@@ -0,0 +1,41 @@
+public class MyThread : Object {
+ public int x_times { get; private set; }
+
+ public MyThread (int times) {
+ this.x_times = times;
+ }
+
+ public int run () {
+ for (int i = 0; i < this.x_times; i++) {
+ stdout.printf ("ping! %d/%d\n", i + 1, this.x_times);
+ Thread.usleep (10000);
+ }
+
+ // return & exit have the same effect
+ Thread.exit (42);
+ return 43;
+ }
+}
+
+public static int main (string[] args) {
+ // Check whether threads are supported:
+ if (Thread.supported () == false) {
+ stderr.printf ("Threads are not supported!\n");
+ return -1;
+ }
+
+ try {
+ // Start a thread:
+ MyThread my_thread = new MyThread (10);
+ Thread<int> thread = new Thread<int>.try ("My fst. thread", my_thread.run);
+
+ // Wait until thread finishes:
+ int result = thread.join ();
+ // Output: `Thread stopped! Return value: 42`
+ stdout.printf ("Thread stopped! Return value: %d\n", result);
+ } catch (Error e) {
+ stdout.printf ("Error: %s\n", e.message);
+ }
+
+ return 0;
+}
diff --git a/test cases/vala/5 target glib/meson.build b/test cases/vala/5 target glib/meson.build
new file mode 100644
index 000000000..1002abe8c
--- /dev/null
+++ b/test cases/vala/5 target glib/meson.build
@@ -0,0 +1,6 @@
+project('valatest', 'vala', 'c')
+
+valadeps = [dependency('glib-2.0', version : '>=2.32'), dependency('gobject-2.0')]
+
+e = executable('valaprog', 'GLib.Thread.vala', dependencies : valadeps)
+test('valatest', e)