Repository navigation
Port the interop specs that needed C# fixtures; fix the bugs they found - #156
Merged
Merged
Conversation
The Tests/Interop/net mspec specs deleted in #119 that compiled C# fixtures from heredocs were never ported: fields by visibility and with PrivateBinding, Ruby classes implementing .NET interfaces (overloads, generic methods, method_missing), non-public classes through public interfaces, explicit generic interface implementations, abstract classes and super, inherited optional-parameter constructors, CP#2949, and the method binding matrices. The fixtures are now C# types in IronRuby.Tests (IronRubyTests.InteropFixtures in Runtime/ClrInteropFixtureTests.cs), and eleven ClrInterop_* tests check the behaviour. For the binding matrices, the tests sample the inputs the old specs tagged as failing in 2009. Porting them turned up these bugs: - RubyClass's cache of failed CLR member lookups is static, shared by every runtime in the process, and its key left out PrivateBinding. A runtime without it cached "privateField is missing", and a later runtime with PrivateBinding got that miss back. The key now includes the setting. - A Proc or Method passed for a Boolean parameter raised TypeError, while any other object is truthy. The Proc's meta-object decided convertibility at narrowing level 0 and returned before the any-to-Boolean rule; it now answers only for the conversions it supports (delegates). - obj.Event(&nil) subscribed a nil handler (ArgumentNullException) instead of returning the event as obj.Event does. That broke forwarding through clr_member(I, name).call(*args, &blk). The rule now tests the block for nil. - A Ruby subclass of String did not bind to a char parameter where a String does. The DLR looks for op_Explicit/op_Implicit only on the type itself, and reflection does not inherit statics, so MutableString's operators were not found for MutableString.Subclass. IronRuby's Converter now walks the base types, as C# does. - The NoMethodError from C# calling an abstract method that the Ruby class does not define named the class "Name@<id>", because it was formatted with RubyContext._Default (the first runtime in the process). It now uses the receiver's context. System::Char into double/float (to_f, so 0.0 for 'a') versus decimal (the code point) is a design question, filed as #153; the test leaves those rows out and names the issue. Checked: the full IronRuby.Tests suite (net10.0) passes; ruby/spec core, library and language were swept against a master build: no new failures but a known Timeout timing flake and a $LOAD_PATH example that depends on where the swept binary lives. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e-specs # Conflicts: # Src/IronRuby.Tests/RubyTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #144.
Ports the
Tests/Interop/netspecs that needed C# fixtures. The fixtures are now C# types in the test assembly (IronRubyTests.InteropFixturesinSrc/IronRuby.Tests/Runtime/ClrInteropFixtureTests.cs), which the tests load withRuntime.LoadAssemblyand include from Ruby.ClrInterop_Fields1/Fields2fields/access_spec.rb,method/invocation/internal_spec.rb(public/protected; private/internal with PrivateBinding)ClrInterop_InterfaceImplementation1interface/implementation_spec.rb,reflection_spec.rb,mapping_spec.rb: overloads, generic interface methods and method_missing called from C#, unimplemented methodsClrInterop_InterfaceMethods1interface/methods_spec.rb: a non-public class through its public interface, and an explicit implementation throughclr_memberClrInterop_ExplicitGenericInterfaces1interface/methods_spec.rb:I3<object>,I3<int>,I3<T>ClrInterop_AbstractClasses1class/instantiation/abstract_spec.rb,class/derivation/attribute_spec.rb:superinto virtual and abstract methodsClrInterop_Constructors1class/fixtures,class/derivation/*,bcl/regressions_spec.rb(CP#2949):[Optional]and defaulted constructorsClrInterop_Binding*1(4 tests)method/binding/*_spec.rb, sampled from the cases tagged failing in 2009Porting them found five bugs, all fixed here:
RubyClass._clrFailedMemberLookupCache). It is static and shared by all runtimes in the process. A runtime without PrivateBinding cached "privateField is missing", and a later runtime with PrivateBinding got that miss back. The key now includes the setting.Fields2runs afterFields1to cover it.boolparameter raised TypeError, while every other object converts by truthiness. The Proc meta-object decided convertibility at narrowing level 0 and returned before the any-to-Boolean rule (Converter.CanConvertFrom).obj.Event(&nil)subscribed a nil handler (ArgumentNullException) instead of returning the event, asobj.Eventdoes. This broke forwarding withclr_member(I, name).call(*args, &blk).RubyEventInfonow tests the block for nil.charparameter where a String does. The DLR looks forop_Explicit/op_Implicitonly on the type itself, soMutableString's operators were invisible onMutableString.Subclass. IronRuby'sConverternow walks base types, as C# does.Name@<runtime id>:RubyTypeEmitter.InvokeMethodMissingusedRubyContext._Default. It now uses the receiver's context.Deferred:
System::Charpassed todouble/floatgoes throughto_f(0.0 for'a'), whiledecimalgets the code point. That is a design question, filed as #153. The test leaves those rows out and names the issue.Some 2009 expectations no longer hold, and these are now the asserted behaviour:
CStruct[]does not bind toobject[]: CLR array covariance does not cover value types.Checked:
Util/parallel-sweep.shover ruby/spec core, library, language, command_line and security, this branch against a master build, run from the same tree: identical counts except a known Timeout timing flake and one$LOAD_PATHexample. That example only fails because the swept branch binary was built to a separate directory, which movessitelibdir.🤖 Generated with Claude Code