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 ();
68 assert (str
== "hello");
70 test_out_weak (out weak_str
);
71 assert (weak_str
== "hello");
73 test_out_weak (out str2
);
74 assert (str2
== "hello");
77 assert (str
== "world");
79 test_ref_weak (ref weak_str
);
80 assert (weak_str
== "world");
82 test_out_array_no_length (out array
);
83 assert (array
[0] == "hello");
84 assert (array
[1] == "world");
85 assert (array
.length
< 0);
87 ClassTest
.run_test ();
94 public void do_action () {
99 class Maman
.FooBar
: Object
{
100 public void do_action () {
101 stdout
.printf (" BAD");
105 class Maman
.SubFooBar
: FooBar
, Foo
{
108 // http://bugzilla.gnome.org/show_bug.cgi?id=523263
110 abstract class Maman
.AbstractBase
: Object
{
111 public abstract void foo ();
114 abstract class Maman
.AbstractDerived
: AbstractBase
{
115 public override void foo () {
119 class Maman
.DeepDerived
: AbstractDerived
{
122 // http://bugzilla.gnome.org/show_bug.cgi?id=528457
123 namespace Maman
.BaseAccess
{
124 public interface IFoo
: Object
{
125 public abstract int interface_method ();
127 public abstract int virtual_interface_method ();
130 public class Foo
: Object
, IFoo
{
131 public virtual int virtual_method () {
135 public int interface_method () {
139 public virtual int virtual_interface_method () {
144 public class Bar
: Foo
{
145 public override int virtual_method () {
146 return base.virtual_method () * 10 + 4;
149 public override int virtual_interface_method () {
150 return base.virtual_interface_method () * 10 + 5;
154 public class FooBar
: Foo
, IFoo
{
155 public int interface_method () {
156 return base.interface_method () * 10 + 6;
159 public int virtual_interface_method () {
164 public void test () {
165 var bar
= new
Bar ();
166 var foobar
= new
FooBar ();
167 assert (bar
.virtual_method () == 14);
168 assert (bar
.virtual_interface_method () == 35);
169 assert (foobar
.interface_method () == 26);
173 void test_out (out string bar
) {
177 void test_out_weak (out weak string bar
) {
181 void test_ref (ref string bar
) {
182 assert (bar
== "hello");
186 void test_ref_weak (ref weak string bar
) {
187 assert (bar
== "hello");
191 void test_out_array_no_length ([CCode (array_length
= false)] out string[] bar
) {
192 bar
= {"hello", "world"};
195 class Maman
.ClassTest
{
196 public class void class_method () {
197 stdout
.printf(" OK\n");
200 public void instance_method () {
201 stdout
.printf ("Access class method in instance method:");
206 stdout
.printf ("Access class method in class constructor:");
211 stdout
.printf ("Access class method in static constructor:");
215 public static void run_test () {
216 var c
= new
ClassTest ();
218 stdout
.printf ("Access class method by member access:");
221 c
.instance_method ();
226 Maman
.SubBar
.main ();