Bugs: Browse | Submit New | Admin

[#19873] string and MutableString not equal

Date:
2008-05-01 03:26
Priority:
3
Submitted By:
Steve Eichert (eichert12)
Assigned To:
Tomas Matousek (tmat)
Category:
None
State:
Open
Summary:
string and MutableString not equal

Detailed description
given this csharp class:

public class CSharpClass
{
  public int MyInteger { get; set;}
  public double MyDouble { get; set; }
  public string MyString { get; set;}
  public int? MyNullableInt { get; set; }
  public decimal MyDecimal { get; set; }
}

I should be able to write a test as simple as in IronRuby:

it "should be able to check a string is equal" do
  k = CSharpClass.new
  k.my_string = "this is my string"
		
  k.my_string.should == "this is my string"
end

currently a .to_str is required for this to work

k.my_string.to_str.should == "this is my string"

Adding the below overload to StringOps.cs makes this work but likely isn't the *right* way to handle this.

[RubyMethod("===", RubyMethodAttributes.PublicInstance)]
[RubyMethod("==", RubyMethodAttributes.PublicInstance)]
public static bool Equals(string str, MutableString other) {
  return str.Equals(other.ToString());
}

I also came across a post [1] saying that this was discussed on the mailing list and would be fixed "later"
but I couldn't find the thread via google.

[1] http://rubydoes.net/2008/02/21/testing-net-with-ironrubys-mini_rspecrb/

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
string-mutablestring-equal.patch path with Equals making string and MutableString "equal" Download

Changes:

Field Old Value Date By
assigned_tonone2008-05-02 15:48jlam
File Added3662: string-mutablestring-equal.patch2008-05-01 03:26eichert12