PageRenderTime 21ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/t/advanced/05mreturn.t

http://github.com/NotFound/winxed
Unknown | 42 lines | 31 code | 11 blank | 0 comment | 0 complexity | 36087cb7dc39ae3564ba627bb26e5253 MD5 | raw file
 1#! winxed
 2
 3// Test return with multiple values
 4
 5using extern Test.More plan, is, ok;
 6
 7function main()
 8{
 9    plan(6);
10
11    :(int i, int j) = ret2();
12    is(i, 42, "first value of 2");
13    is(j, 24, "second value of 2");
14
15    :(i, j[optional], int has2[opt_flag]) = ret1();
16    is(i, 7, "first value of 1");
17    is(has2, 0, "optional not used");
18
19    :(i, j[optional], has2[opt_flag]) = ret2();
20    is(has2, 1, "optional used");
21
22    :(var v1, var v2, var v3) = retvars();
23    ok(v1 == null && v2 != null && v3 == null, "null/non null vars");
24}
25
26function ret1()
27{
28    return 7;
29}
30
31function ret2()
32{
33    return 42, 24;
34}
35
36function retvars()
37{
38    var v = 1;
39    return null, v, null;
40}
41
42// End