File: optionalParameters.nice

package info (click to toggle)
nice 0.9.13-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,284 kB
  • ctags: 6,893
  • sloc: java: 42,767; xml: 3,508; lisp: 1,084; sh: 742; makefile: 670; cpp: 21; awk: 3
file content (43 lines) | stat: -rw-r--r-- 966 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package regtest.basic;

/**
   Test of named and optional parameters.
*/

int o1(int x, int, int z = 20, int t = 0);
o1(x, a, z, t) = x + 2*a + 3*z;

int o1(int, int x, int y = 10);
o1(a, x, y) = a + x + y/2;

void oP(int, int b, int c = 3, int d, int e, boolean skip = false);
oP(a,b,c,d,e, skip)
{
  if (skip)
    return;
  println("a=" + a + " b=" + b + " c=" + c + " d=" + d + " e=" + e);
}

void oPFunction(int, int b, int c = 3, int d, int e, boolean skip = false) {}

/* This is disabled at the moment. 
   See comment at bossa.syntax.MethodDeclaration method typedResolve,
   line 148 as of CVS version 1.41.
*/
//<T> void printAny(T what = "Nothing");
//printAny(what) = println(what);

void test_optional();
test_optional()
{
  println("### Testing named and optional parameters ###\n");
  println(o1(3,x:2,t:0));

  oP(1, 2, 3, 4, 5);
  oP(d:1, b:2, 3, 4, 5);
  oP(1, b:3, d:3, e:4);
  oP(1, b:3, d:3, e:4, skip:true);

  //printAny(3);
  //printAny();
}