3 class Maman
.Bar
: Object
{
4 public void do_action () {
8 public static void do_static_action () {
12 public virtual void do_virtual_action () {
13 stdout
.printf (" BAD");
17 class Maman
.SubBar
: Bar
{
18 public override void do_virtual_action () {
22 static void accept_ref_string (ref string str
) {
25 static void test_classes_methods_ref_parameters () {
27 accept_ref_string (ref str
);
30 public static int main () {
31 stdout
.printf ("Inheritance Test: 1");
33 var bar
= new
SubBar ();
36 stdout
.printf (" 3\n");
38 stdout
.printf ("Static Inheritance Test: 1");
42 stdout
.printf (" 3\n");
44 stdout
.printf ("Virtual Method Test: 1");
46 bar
.do_virtual_action ();
48 stdout
.printf (" 3\n");
50 // test symbol resolving to check that methods of implemented
51 // interfaces take precedence of methods in base classes
52 stdout
.printf ("Interface Inheritance Test: 1");
54 var foobar
= new
SubFooBar ();
57 stdout
.printf (" 3\n");
59 test_classes_methods_ref_parameters ();
67 assert (str
== "hello");
69 test_out_weak (out weak_str
);
70 assert (weak_str
== "hello");
72 test_out_weak (out str2
);
73 assert (str
== "hello");
76 assert (str
== "world");
78 test_ref_weak (ref weak_str
);
79 assert (str
== "world");
81 test_ref_weak (ref str2
);
82 assert (str
== "world");
84 ClassTest
.run_test ();
91 public void do_action () {
96 class Maman
.FooBar
: Object
{
97 public void do_action () {
98 stdout
.printf (" BAD");
102 class Maman
.SubFooBar
: FooBar
, Foo
{
105 // http://bugzilla.gnome.org/show_bug.cgi?id=523263
107 abstract class Maman
.AbstractBase
: Object
{
108 public abstract void foo ();
111 abstract class Maman
.AbstractDerived
: AbstractBase
{
112 public override void foo () {
116 class Maman
.DeepDerived
: AbstractDerived
{
119 // http://bugzilla.gnome.org/show_bug.cgi?id=528457
120 namespace Maman
.BaseAccess
{
121 public interface IFoo
: Object
{
122 public abstract int interface_method ();
124 public abstract int virtual_interface_method ();
127 public class Foo
: Object
, IFoo
{
128 public virtual int virtual_method () {
132 public int interface_method () {
136 public virtual int virtual_interface_method () {
141 public class Bar
: Foo
{
142 public override int virtual_method () {
143 return base.virtual_method () * 10 + 4;
146 public override int virtual_interface_method () {
147 return base.virtual_interface_method () * 10 + 5;
151 public class FooBar
: Foo
, IFoo
{
152 public int interface_method () {
153 return base.interface_method () * 10 + 6;
156 public int virtual_interface_method () {
161 public void test () {
162 var bar
= new
Bar ();
163 var foobar
= new
FooBar ();
164 assert (bar
.virtual_method () == 14);
165 assert (bar
.virtual_interface_method () == 35);
166 assert (foobar
.interface_method () == 26);
170 void test_out (out string bar
) {
174 void test_out_weak (out weak string bar
) {
178 void test_ref (ref string bar
) {
179 assert (bar
== "hello");
183 void test_ref_weak (ref weak string bar
) {
184 assert (bar
== "hello");
188 class Maman
.ClassTest
{
189 public class void class_method () {
190 stdout
.printf(" OK\n");
193 public void instance_method () {
194 stdout
.printf ("Access class method in instance method:");
199 stdout
.printf ("Access class method in class constructor:");
204 stdout
.printf ("Access class method in static constructor:");
208 public static void run_test () {
209 var c
= new
ClassTest ();
211 stdout
.printf ("Access class method by member access:");
214 c
.instance_method ();
219 Maman
.SubBar
.main ();