Agdlr test w/ ruby string

Hey,

Moonlight currently fails the following agldr test:

it ‘verifies SetProperty works’ do
new_ctl = HtmlPage.Document.CreateElement(‘div’)
new_value = “This is added by Merlin SL Test!”
new_ctl.SetProperty(“innerHTML”, new_value)
new_ctl.GetProperty(“innerHTML”).should.equal new_value.to_clr_string
end

it passes if I change the SetProperty line to:

new_ctl.SetProperty(“innerHTML”, new_value.to_clr_string)

SetProperty’s signature is void SetProperty(string name, object value), so I’d except it to convert the name “innerHTML” to a
clr_string, but not the value argument.

Is IronRuby doing some conversion here, or is it Silverlight doing
interesting things when marshalling the value?

SetProperty converts Ruby string “innerHTML” to CLR string because its
first parameter is strongly typed to CLR string. The second parameter is
not and hence no conversion occurs.

This should work:

new_ctl.SetProperty(“innerHTML”, new_value)
new_ctl.GetProperty(“innerHTML”).should.equal new_value

The current implementation “==” compares Ruby strings and CLR strings by
value.
The implementation of “eql?” doesn’t:

x = ‘str’
=> “str”

y = x.to_clr_string
=> ‘str’

x == y
=> true

x.eql? y
=> false

Which is similar to numerics in MRI:

irb(main):001:0> 1 == 1.0
=> true
irb(main):002:0> 1.eql? 1.0
=> false
irb(main):003:0> exit

Would it be better to override “eql?” on string to compare Ruby string
and CRL string equal if they have the same value?

Tomas

Hey Tomas,

On 4/1/09, Tomas M. [email protected] wrote:

SetProperty converts Ruby string “innerHTML” to CLR string because its first parameter is strongly typed to CLR string. The second parameter is not and hence no conversion occurs.

Alright that’s what I expected.

The current implementation “==” compares Ruby strings and CLR strings by value.

“” == “”.to_clr_string
=> false

I see :slight_smile: Now to fix it in Mono.

Thanks,

On 4/1/09, Jb Evain [email protected] wrote:

Is IronRuby doing some conversion here, or is it Silverlight doing
interesting things when marshalling the value?

Alright, so for the curious, after an update, the string comparison
works ok on Moonlight.

The issue is indeed marshaling in Silverlight, which decides that
innerHTML is a string property, so it stringifies whatever you give it
to. Not obvious :slight_smile: