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 44 45 46 47 48 49
|
/**************************************************************************/
/* N I C E */
/* A high-level object-oriented research language */
/* (c) Daniel Bonniot 2002 */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/**************************************************************************/
package regtest.basic;
/**
Test class constructors.
@version $Date: 2002/05/03 12:56:03 $
@author Daniel Bonniot (bonniot@users.sourceforge.net)
*/
String f(int x) = new String(x == 1 ? "1" : "11");
class Constr
{
int a;
String b = "2";
toString() = this.b + "," + this.a;
}
class Con1<T> { T x; }
// Inherit a parameterized field, while renaming the type parameter.
class Con2<U> extends Con1<U> { }
void test_constructors()
{
Constr c = new Constr(a: 0, b: "1");
println(c);
println(new Constr(a: 0));
println(new Constr(b: "", a: 0));
Con1<String> cc = new Con1(x: "Tricky");
String s = cc.x;
}
// Local Variables:
// nice-xprogram: "$HOME/Nice/bin/nicec -e -r -d \"$HOME/Nice/classes\" --classpath=\"$HOME/Nice:$HOME/Nice/classes\""
// End:
|