3 [CCode (has_target
= false)]
4 public delegate
void Delegate ();
6 public struct RealStruct
{
10 public class NonPrivAccess
: Object
{
12 public RealStruct real_struct
{ get; set; }
15 public class Sample
: Object
{
16 private string automatic
{ get; set; }
18 public Delegate deleg
{ get; owned
set; }
23 set { _name
= value
; }
26 private string _read_only
;
27 public string read_only
{
28 get { return _read_only
; }
31 public Sample (string name
) {
36 _automatic
= "InitialAutomatic";
37 _read_only
= "InitialReadOnly";
42 stdout
.printf("property `%s' has changed!\n",
47 automatic
= "TheNewAutomatic";
50 // The following statement would be rejected
51 // read_only = "TheNewReadOnly";
53 stdout
.printf("automatic: %s\n", automatic
);
54 stdout
.printf("name: %s\n", name
);
55 stdout
.printf("read_only: %s\n", read_only
);
56 stdout
.printf("automatic: %s\n", automatic
);
61 public static int main () {
62 var test
= new
Sample("InitialName");
68 stdout
.printf ("Interface Properties Test: 1");
70 Maman
.Ibaz ibaz
= new Maman
.Baz ();
71 ibaz
.simple_method ();
73 stdout
.printf (" 3\n");
75 var nonpriv
= new
NonPrivAccess ();
76 nonpriv
.real_struct
= { 10 };
77 assert (nonpriv
.real_struct
.field
== 10);
83 abstract class Maman
.Foo
: Object
{
84 private int _public_base_property
= 2;
85 public int public_base_property
{
87 return _public_base_property
;
90 _public_base_property
= value
;
93 public abstract int abstract_base_property
{ get; set; }
100 abstract class Maman
.EnumDefault
{
101 public abstract FooEnum bar
{ get; default = FooEnum
.FOO
; }
104 class Maman
.Bar
: Foo
{
105 public int public_property
{ get; set; default = 3; }
106 public override int abstract_base_property
{ get; set; }
109 stdout
.printf (" %d %d", public_base_property
, public_property
);
110 public_base_property
= 4;
112 stdout
.printf (" %d %d", public_base_property
, public_property
);
115 public static void run () {
116 stdout
.printf ("Property Test: 1");
118 var bar
= new
Bar ();
122 foo
.abstract_base_property
= 6;
123 stdout
.printf (" %d", foo
.abstract_base_property
);
125 stdout
.printf (" 7\n");
129 interface Maman
.Ibaz
: Object
{
130 public abstract int number
{ get; }
132 public void simple_method () {
134 stdout
.printf (" %d", n
);
138 class Maman
.Baz
: Object
, Ibaz
{
144 interface Maman
.IBiz
: Object
{
145 public abstract int number
{ get; construct; }
148 abstract class Maman
.ABiz
: Object
, IBiz
{
149 public int number
{ get; construct; }
150 public abstract int number2
{ get; construct; }
153 class Maman
.Biz
: ABiz
{
154 public override int number2
{ get; construct; }