2 // Copyright (c) 2004, Rodrigo B. de Oliveira (rbo@acm.org)
3 // All rights reserved.
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 // * Neither the name of Rodrigo B. de Oliveira nor the names of its
14 // contributors may be used to endorse or promote products derived from this
15 // software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 namespace BooCompiler
.Tests
33 public class ObsoleteClass
36 public static int Bar
= 42;
38 [Obsolete("Indeed it is." )]
39 public static void Foo()
43 [Obsolete("We said so.")]
50 public class ReturnDucks
52 public class DuckBase
{}
54 public class DuckFoo
: DuckBase
56 public string Foo() { return "foo"; }
59 public class DuckBar
: DuckBase
61 public string Bar() { return "bar"; }
64 [Boo
.Lang
.DuckTypedAttribute
]
65 public DuckBase
GetDuck(bool foo
)
67 if (foo
) return new DuckFoo();
78 public struct Rectangle
93 public class Transform
97 public Vector3 position
99 get { return _position; }
100 set { _position = value; }
104 public class BOO313BaseClass
106 Transform _t
= new Transform();
107 public Transform transform
113 public class OutterClass
115 public class InnerClass
117 public static int X
= 3;
121 public class OverrideBoolOperator
123 public static implicit operator bool(OverrideBoolOperator instance
)
125 Console
.WriteLine("OverrideBoolOperator.operator bool");
130 public struct ValueTypeOverrideBoolOperator
132 public static implicit operator bool(ValueTypeOverrideBoolOperator instance
)
134 Console
.WriteLine("ValueTypeOverrideBoolOperator.operator bool");
139 public class ExtendsOverridenBoolOperator
: OverrideBoolOperator
141 [Boo
.Lang
.DuckTypedAttribute
]
142 public ExtendsOverridenBoolOperator
GetFoo()
144 return new ExtendsOverridenBoolOperator();
148 public class OverrideEqualityOperators
150 public static bool operator==(OverrideEqualityOperators lhs
, OverrideEqualityOperators rhs
)
152 if (Object
.Equals(null, lhs
))
154 Console
.WriteLine("lhs is null");
157 if (Object
.Equals(null, rhs
))
159 Console
.WriteLine("rhs is null");
164 public static bool operator!=(OverrideEqualityOperators lhs
, OverrideEqualityOperators rhs
)
166 if (Object
.Equals(null, lhs
))
168 Console
.WriteLine("lhs is null");
171 if (Object
.Equals(null, rhs
))
173 Console
.WriteLine("rhs is null");
179 public class AmbiguousBase
181 public string Path(string empty
)
187 public class AmbiguousSub1
: AmbiguousBase
189 public new string Path
198 public class AmbiguousSub2
: AmbiguousSub1
210 public enum ByteEnum
: byte
217 public enum SByteEnum
: sbyte
247 public string FirstName
260 public string LastName
274 public class PersonCollection
: System
.Collections
.CollectionBase
276 public PersonCollection()
280 public Person
this[int index
]
284 return (Person
)InnerList
[index
];
289 InnerList
[index
] = value;
293 public Person
this[string fname
]
297 foreach (Person p
in InnerList
)
299 if (p
.FirstName
== fname
)
310 foreach (Person p
in InnerList
)
312 if (p
.FirstName
== fname
)
314 InnerList
[index
] = value;
322 public void Add(Person person
)
324 InnerList
.Add(person
);
328 public class Clickable
334 public event EventHandler Click
;
336 public static event EventHandler Idle
;
338 public void RaiseClick()
342 Click(this, EventArgs
.Empty
);
346 public static void RaiseIdle()
350 Idle(null, EventArgs
.Empty
);
355 public class BaseClass
357 protected BaseClass()
361 protected BaseClass(string message
)
363 Console
.WriteLine("BaseClass.constructor('{0}')", message
);
366 public virtual void Method0()
368 Console
.WriteLine("BaseClass.Method0");
371 public virtual void Method0(string text
)
373 Console
.WriteLine("BaseClass.Method0('{0}')", text
);
376 public virtual void Method1()
378 Console
.WriteLine("BaseClass.Method1");
381 //for BOO-632 regression test
382 protected int _protectedfield
= 0;
383 protected int ProtectedProperty
387 return _protectedfield
;
392 _protectedfield
= value;
397 public class DerivedClass
: BaseClass
399 public DerivedClass()
403 public void Method2()
410 public class ClassWithNewMethod
: DerivedClass
412 new public void Method2()
414 Console
.WriteLine("ClassWithNewMethod.Method2");
422 Console
.WriteLine("VarArgs.Method");
425 public void Method(params object[] args
)
427 Console
.WriteLine("VarArgs.Method({0})", Boo
.Lang
.Builtins
.join(args
, ", "));
431 public class Disposable
: System
.IDisposable
435 Console
.WriteLine("Disposable.constructor");
440 Console
.WriteLine("Disposable.foo");
443 void System
.IDisposable
.Dispose()
445 Console
.WriteLine("Disposable.Dispose");
449 public class Constants
451 public const string StringConstant
= "Foo";
453 public const int IntegerConstant
= 14;
455 public const uint UnsignedInt
= 255;
457 public const ulong UnsignedLong
= 297;
462 public static void SetValue(int value, ref int output
)
467 public static void SetRef(object value, ref object output
)
472 public static void ReturnValue(int value, out int output
)
477 public static void ReturnRef(object value, out object output
)
483 public class PointersBase
485 public void Foo(ref int bar
)
487 System
.Console
.WriteLine("PointersBase.Foo(int&)");
490 public unsafe void Foo(int* bar
)
492 System
.Console
.WriteLine("Pointers.Foo(int*)");
496 public class Pointers
: PointersBase
498 public new void Foo(ref int bar
)
500 System
.Console
.WriteLine("Pointers.Foo(int&)");
504 public class NoParameterlessConstructor
506 public NoParameterlessConstructor(object param
)
511 public abstract class AbstractClass
515 public abstract class AnotherAbstractClass
517 protected abstract string Foo();
519 public virtual string Bar()