From: Rico Tzschichholz Date: Wed, 22 Nov 2017 20:49:11 +0000 (+0100) Subject: tests: Make lambda tests fatal and add some more cases X-Git-Tag: 0.39.1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4a80b11e19b8fcb1134049e2a33dfc08475c83e;p=thirdparty%2Fvala.git tests: Make lambda tests fatal and add some more cases --- diff --git a/tests/methods/lambda.vala b/tests/methods/lambda.vala index d533f688b..c659cb65b 100644 --- a/tests/methods/lambda.vala +++ b/tests/methods/lambda.vala @@ -1,20 +1,31 @@ using GLib; static delegate int Maman.ActionCallback (int i); +static delegate void Maman.ActionOutCallback (out int i); +static delegate void Maman.ActionRefCallback (ref int i); class Maman.Bar : Object { static int do_action (ActionCallback cb) { return cb (1); } + static int do_out_action (ActionOutCallback cb) { + int i; + cb (out i); + return i; + } + + static int do_ref_action (ActionRefCallback cb) { + int i = 1; + cb (ref i); + return i; + } + public static int main () { - stdout.printf ("Lambda Test: 1"); - - stdout.printf (" %d", do_action (i => i * 2)); - - stdout.printf (" %d", do_action (i => { return i * 3; })); - - stdout.printf (" 4\n"); + assert (do_action (i => i * 2) == 2); + assert (do_action (i => { return i * 3; }) == 3); + assert (do_out_action ((out i) => { i = 4; }) == 4); + assert (do_ref_action ((ref i) => { i += 4; }) == 5); return 0; }