These test cases will be stored in interop/using.
Scenarios
- Types in “Getting .NET Types”
- Concrete instance of TypeGroup with [] notation and an array type
- A class with multiple constructor overrides
Negative Scenarios
Instantiating Abstract class
Cases
Member Modification
- Add a property
- Add a method
- Public
- Private
- Protected
- Overloads
- Various numbers of args
- Attempt to add an existing method
- Add a generic method
- Add a method which conflicts with Ruby keywords
- Add an overload to an existing method
- Add a field
- Modify a field
- Static field
- Instance field
- Readonly field
- Volatile field
- Const field
- Remove a property
- Different casing (should error out)
- Created in CLR
- Created in Ruby
- Remove a property multiple times
- Remove a method
- Remove an existing method
- Remove a method overload (?)
- Change the visibility of an existing method
- Instantiate an object and use the above methods.
- Remove an interface method and test for behavior in regard to the broken interface
- Call Type.GetMembers() on a modified class to verify added/deleted members.
- Modify a property defined in an interface
- Use a property defined in an interface
- Modify a virtual method
- Attempt to use a virtual method
Special Parameter types
- Use methods with different parameter lists. In C#:
public void M1(int x, int y) { } public void M2(int x, params int[] y) public void M3(int x, [DefaultParameterValue(5)] int y) public void M6([Optional] int x, [Optional] object y) public void M7([Out] int x) public void M7([ParamsDictionary] IattributesCollection dict) - one special parameter
- two special parameters
- one normal, one special in both orders
- multiple parameters of mixed kind
- Use DefaultParameterValue/Optional attributes
- Can optional parameters be omitted?
- Do DefaultParameterValue’s get used?
- Parameter names that collide with keywords or methods
- Use a method with ref and out parameters in all these scenarios
Overloaded Methods
- Override interesting methods like ToString() and ensure Ruby equivalent #to_str still works.
- Add/remove an override for a base-class virtual method. Also, hide the base-class method with anew one
- Add/remove new operator overloads and verify that the operators work in ruby
- Add/remove operators for unsupported operators in Ruby
- Add/remove implicitly and explicitly implemented interfaces
- Pick an override from Ruby
- Non-generic / generic methods have the same name
- Activator.CreateInstance scenario
- G<T>.M(int), G<T>.M(T)
- G.M(int), G.M<T>(T)
- Static method and instance method have the same name
- instance M(C), static M(thisType, C)
- Same name as explicit interface method
Ruby Considerations
- Call existing Ruby methods from Object and Kernel on .NET objects
- Use
Ruby’s mixin functionality. For example, include Enumerable and define
.each, and test for the existence of other Enumerable methods
- Attempt to add a Ruby object to a typed .NET array
- Attempt to assign an object of the wrong type to a field
- Get an unbound .NET method
- Direct call of method vs. send :method vs eval method
Indexers
- Use a default indexer from within Ruby
- Read only indexers :[]
- Write only indexers :[]=
- Indexer defined in interface
- Overloaded interface
- Indexer defined in VB style
- Parameter list on indexer
Other
- Implicit and explicit conversions in Ruby
- Return a private type
- Check for presence of private members with –X:PrivateBinding
Events/Delegates
- Define a delegate from Ruby
- Use a delegate from Ruby
- Generic delegate types
- With overloaded method
- Add a method to a delegate
- Add a method multiple times
- Remove a method from a delegate
- Remove a repeated method from a delegate (one time should remove one occurrence)
- Remove all methods from the delegate (should be benign)
- Remove a non-existent method from a delegate with other methods (should be benign)
- Empty delegate should have an empty invocation list
- Define an event in an interface
- Define an event in a class
- Static events
- Static delegates
- Add a delegate as an event
- Remove a delegate as an event
- Remove a method as an event
- Event with Add only
- Event with Remove only
- Add a method as an event
- Add an incompatible delegate and method to an event
Special Cases
IronRuby has the ability to modify modules dynamically. This
should work for CLR types too. If you mix in a module to a class,
create an instance of the modified class, add another method to the
module, and use that method in the already existing instance. In pure
Ruby, as an example:
module M
def foo
'foo'
end
end
class C
include M
end
c = C.new
c.foo #=> 'foo'
c.bar #=> NoMethodError
module M
def bar
'bar'
end
end
c.bar #=> 'bar'
This
should work for all of the above scenarios. You should also be able to
add methods to any object that represents itself as a module in Ruby,
including interfaces and namespaces.