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

-----Original Message-----
From: ironruby-core-boun...@rubyforge.org 
[mailto:ironruby-core-boun...@rubyforge.org] On Behalf Of Jb Evain
Sent: Wednesday, April 01, 2009 6:16 AM
To: ironruby-core@rubyforge.org
Subject: [Ironruby-core] 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?

-- 
Jb Evain  <j...@nurv.fr>
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to