[Ironruby-core] agdlr test w/ ruby string

Tomas Matousek Tomas.Matousek at microsoft.com
Wed Apr 1 11:55:29 EDT 2009

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?


-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jb Evain
Sent: Wednesday, April 01, 2009 6:16 AM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] agdlr test w/ ruby string


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

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?

Jb Evain  <jb at nurv.fr>
Ironruby-core mailing list
Ironruby-core at rubyforge.org

More information about the Ironruby-core mailing list