Improve integer tests
[vala-lang.git] / tests / objects / classes.test
blobedcbaca4881665a9997f4fffe9ace01acf0e7248
2 Program: test
4 using GLib;
6 [Compact]
7 class CompactClass {
8         public int field;
11 [Compact]
12 class CompactClassWithDestructor {
13         ~CompactClassWithDestructor () {
14                 stdout.printf ("~CompactClassWithDestructor\n");
15         }
17         /* FIXME bug 533977 */
18         public char dummy;
21 class DerivedClass : CompactClass {
24 [Compact]
25 public class PublicClass {
26         public int field;
29 [Compact]
30 abstract class AbstractClass {
31         public int field;
34 [Compact]
35 class ClassWithCreationMethod {
36         public ClassWithCreationMethod () {
37                 stdout.printf ("ClassWithCreationMethod\n");
38         }
40         public int field;
43 [Compact]
44 class ClassWithNamedCreationMethod {
45         public ClassWithNamedCreationMethod.named () {
46                 stdout.printf ("ClassWithNamedCreationMethod\n");
47         }
49         public int field;
52 class SimpleGTypeInstanceClass {
55 class DerivedGTypeInstanceClass : SimpleGTypeInstanceClass {
58 public class PublicGTypeInstanceClass {
61 class GTypeInstanceClassWithCreationMethod {
62         public GTypeInstanceClassWithCreationMethod () {
63                 stdout.printf ("GTypeInstanceClassWithCreationMethod\n");
64         }
67 class GTypeInstanceClassWithNamedCreationMethod {
68         public GTypeInstanceClassWithNamedCreationMethod.named () {
69                 stdout.printf ("GTypeInstanceClassWithNamedCreationMethod\n");
70         }
73 class SimpleGObjectClass : Object {
76 class DerivedGObjectClass : SimpleGObjectClass {
79 public class PublicGObjectClass : Object {
82 abstract class AbstractGObjectClass : Object {
85 class GObjectClassWithCreationMethod : Object {
86         public GObjectClassWithCreationMethod () {
87         }
90 class GObjectClassWithNamedCreationMethod : Object {
91         public GObjectClassWithNamedCreationMethod.named () {
92         }
95 void main () {
96         stdout.printf ("Classes Test:\n");
98         stdout.printf ("new CompactClass ()\n");
99         var compact_class = new CompactClass ();
100         stdout.printf ("new DerivedClass ()\n");
101         var derived_class = new DerivedClass ();
102         stdout.printf ("new PublicClass ()\n");
103         var public_class = new PublicClass ();
104         stdout.printf ("new ClassWithCreationMethod ()\n");
105         var class_with_creation_method = new ClassWithCreationMethod ();
106         stdout.printf ("new ClassWithNamedCreationMethod ()\n");
107         var class_with_named_creation_method = new ClassWithNamedCreationMethod.named ();
108         stdout.printf ("new CompactClassWithDestructor ()\n");
109         var compact_class_with_destructor = new CompactClassWithDestructor ();
110         compact_class_with_destructor = null;
112         stdout.printf ("new SimpleGTypeInstanceClass ()\n");
113         var simple_gtypeinstance_class = new SimpleGTypeInstanceClass ();
114         stdout.printf ("new DerivedGTypeInstanceClass ()\n");
115         var derived_gtypeinstance_class = new DerivedGTypeInstanceClass ();
116         stdout.printf ("new PublicGTypeInstanceClass ()\n");
117         var public_gtypeinstance_class = new PublicGTypeInstanceClass ();
118         stdout.printf ("new GTypeInstanceClassWithCreationMethod ()\n");
119         var gtypeinstance_class_with_creation_method = new GTypeInstanceClassWithCreationMethod ();
120         stdout.printf ("new GTypeInstanceClassWithNamedCreationMethod ()\n");
121         var gtypeinstance_class_with_named_creation_method = new GTypeInstanceClassWithNamedCreationMethod.named ();
123         stdout.printf ("new SimpleGObjectClass ()\n");
124         var simple_gobject_class = new SimpleGObjectClass ();
125         stdout.printf ("new DerivedGObjectClass ()\n");
126         var derived_gobject_class = new DerivedGObjectClass ();
127         stdout.printf ("new PublicGObjectClass ()\n");
128         var public_gobject_class = new PublicGObjectClass ();
129         stdout.printf ("new GObjectClassWithCreationMethod ()\n");
130         var gobject_class_with_creation_method = new GObjectClassWithCreationMethod ();
131         stdout.printf ("new GObjectClassWithNamedCreationMethod ()\n");
132         var gobject_class_with_named_creation_method = new GObjectClassWithNamedCreationMethod.named ();
134         stdout.printf ("new CompactClass () { field = 1 }\n");
135         compact_class = new CompactClass () { field = 1 };
136         stdout.printf ("compact_class.field = %d\n", compact_class.field);
138         stdout.printf (".\n");