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 (str2
== "hello");
76 assert (str
== "world");
78 test_ref_weak (ref weak_str
);
79 assert (weak_str
== "world");
81 ClassTest
.run_test ();
88 public void do_action () {
93 class Maman
.FooBar
: Object
{
94 public void do_action () {
95 stdout
.printf (" BAD");
99 class Maman
.SubFooBar
: FooBar
, Foo
{
102 // http://bugzilla.gnome.org/show_bug.cgi?id=523263
104 abstract class Maman
.AbstractBase
: Object
{
105 public abstract void foo ();
108 abstract class Maman
.AbstractDerived
: AbstractBase
{
109 public override void foo () {
113 class Maman
.DeepDerived
: AbstractDerived
{
116 // http://bugzilla.gnome.org/show_bug.cgi?id=528457
117 namespace Maman
.BaseAccess
{
118 public interface IFoo
: Object
{
119 public abstract int interface_method ();
121 public abstract int virtual_interface_method ();
124 public class Foo
: Object
, IFoo
{
125 public virtual int virtual_method () {
129 public int interface_method () {
133 public virtual int virtual_interface_method () {
138 public class Bar
: Foo
{
139 public override int virtual_method () {
140 return base.virtual_method () * 10 + 4;
143 public override int virtual_interface_method () {
144 return base.virtual_interface_method () * 10 + 5;
148 public class FooBar
: Foo
, IFoo
{
149 public int interface_method () {
150 return base.interface_method () * 10 + 6;
153 public int virtual_interface_method () {
158 public void test () {
159 var bar
= new
Bar ();
160 var foobar
= new
FooBar ();
161 assert (bar
.virtual_method () == 14);
162 assert (bar
.virtual_interface_method () == 35);
163 assert (foobar
.interface_method () == 26);
167 void test_out (out string bar
) {
171 void test_out_weak (out weak string bar
) {
175 void test_ref (ref string bar
) {
176 assert (bar
== "hello");
180 void test_ref_weak (ref weak string bar
) {
181 assert (bar
== "hello");
185 class Maman
.ClassTest
{
186 public class void class_method () {
187 stdout
.printf(" OK\n");
190 public void instance_method () {
191 stdout
.printf ("Access class method in instance method:");
196 stdout
.printf ("Access class method in class constructor:");
201 stdout
.printf ("Access class method in static constructor:");
205 public static void run_test () {
206 var c
= new
ClassTest ();
208 stdout
.printf ("Access class method by member access:");
211 c
.instance_method ();
216 Maman
.SubBar
.main ();