# Commit to solve bug: String.delete gives a wrong result (http://ironruby.codeplex.com/workitem/5426)

**URL:** <https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836>\
**Category:** IronRuby\
**Created:** [May 11, 2011, 1:50pm UTC](https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836 "2011-05-11T13:50:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 11, 2011, 1:50pm UTC](https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836/1 "2011-05-11T13:50:48Z")

</div>

Hi,

I committed in my fork a very small change to solve the bug which is in  
[http://ironruby.codeplex.com/workitem/5426](http://ironruby.codeplex.com/workitem/5426)  
The commit is in:

> <https://github.com/robjperez/main/commit/7d94882990bc80504a78c7ed9ea989e31b8e19ed>

The problem was inside the range detector in the delete method.  
When it finds a ‘-’ character, it assumes that the string is a range,  
but  
when you use the \ before the ‘-’ you are telling that the ‘-’ char is a  
literal.

The change was in the File MutableStringOps.cs in the Delete Method.

This is my first contribution to IronRuby, so I don’t know if i’m  
following  
all the steps in the right order :), so, forgive me if i’m doing wrong  
but I  
followed the guides written in github wiki.

Shall I proceed with the pull request to main repository, or are you  
going  
to review the commit before?

Regards.  
Roberto

---

<div class="post-metadata">

**Author:** ![Roberto\_Perez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Roberto\_Perez](https://www.ruby-forum.com/u/Roberto_Perez)\
**Post date:** [May 11, 2011, 6:46pm UTC](https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836/2 "2011-05-11T18:46:35Z")

</div>

I’ll take a look. Could you add some tests to the specs, unless there  
already are some? Let me know if you have any questions.

Thanks,  
Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Roberto Perez  
Sent: Wednesday, May 11, 2011 3:56 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Commit to solve bug: String.delete gives a  
wrong result ([http://ironruby.codeplex.com/workitem/5426](http://ironruby.codeplex.com/workitem/5426))

Hi,

I committed in my fork a very small change to solve the bug which is in  
[http://ironruby.codeplex.com/workitem/5426](http://ironruby.codeplex.com/workitem/5426)  
The commit is in:

> <https://github.com/robjperez/main/commit/7d94882990bc80504a78c7ed9ea989e31b8e19ed>

The problem was inside the range detector in the delete method.  
When it finds a ‘-’ character, it assumes that the string is a range,  
but when you use the \ before the ‘-’ you are telling that the ‘-’ char  
is a literal.

The change was in the File MutableStringOps.cs in the Delete Method.

This is my first contribution to IronRuby, so I don’t know if i’m  
following all the steps in the right order :), so, forgive me if i’m  
doing wrong but I followed the guides written in github wiki.

Shall I proceed with the pull request to main repository, or are you  
going to review the commit before?

Regards.  
Roberto

---

<div class="post-metadata">

**Author:** ![Roberto\_Perez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Roberto\_Perez](https://www.ruby-forum.com/u/Roberto_Perez)\
**Post date:** [May 12, 2011, 12:51am UTC](https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836/3 "2011-05-12T00:51:01Z")

</div>

Ok I’ll add some tests to check the functionality of this commit.

I was trying to add one, but i’m having some problems passing the same  
“pattern string” due to the difference between ruby syntax and c# one.  
(As  
the tests are written in c#)

I’ll tell you as soon as I have the test done.

Cheers

On Wed, May 11, 2011 at 6:23 PM, Tomas M. \<

---

<div class="post-metadata">

**Author:** ![Roberto\_Perez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Roberto\_Perez](https://www.ruby-forum.com/u/Roberto_Perez)\
**Post date:** [May 12, 2011, 1:05am UTC](https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836/4 "2011-05-12T01:05:50Z")

</div>

I meant Ruby mspec tests located in  
Languages\Ruby\Tests\mspec\rubyspec\core\string (for strings).  
You might find they are already written but disabled. In that case  
remove the corresponding entries from tags:  
Languages\Ruby\Tests\mspec\ironruby-tags-19\core\string

You can find more on mspec here: [https://github.com/rubyspec/mspec](https://github.com/rubyspec/mspec)

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Roberto Perez  
Sent: Wednesday, May 11, 2011 3:27 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Commit to solve bug: String.delete gives a  
wrong result ([http://ironruby.codeplex.com/workitem/5426](http://ironruby.codeplex.com/workitem/5426))

Ok I’ll add some tests to check the functionality of this commit.

I was trying to add one, but i’m having some problems passing the same  
“pattern string” due to the difference between ruby syntax and c# one.  
(As the tests are written in c#)

I’ll tell you as soon as I have the test done.

Cheers

On Wed, May 11, 2011 at 6:23 PM, Tomas M.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\>  
wrote:  
I’ll take a look. Could you add some tests to the specs, unless there  
already are some? Let me know if you have any questions.

Thanks,  
Tomas

From:  
removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
On Behalf Of Roberto Perez  
Sent: Wednesday, May 11, 2011 3:56 AM  
To: removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: [Ironruby-core] Commit to solve bug: String.delete gives a  
wrong result ([http://ironruby.codeplex.com/workitem/5426](http://ironruby.codeplex.com/workitem/5426))

Hi,

I committed in my fork a very small change to solve the bug which is in  
[http://ironruby.codeplex.com/workitem/5426](http://ironruby.codeplex.com/workitem/5426)  
The commit is in:

> <https://github.com/robjperez/main/commit/7d94882990bc80504a78c7ed9ea989e31b8e19ed>

The problem was inside the range detector in the delete method.  
When it finds a ‘-’ character, it assumes that the string is a range,  
but when you use the \ before the ‘-’ you are telling that the ‘-’ char  
is a literal.

The change was in the File MutableStringOps.cs in the Delete Method.

This is my first contribution to IronRuby, so I don’t know if i’m  
following all the steps in the right order :), so, forgive me if i’m  
doing wrong but I followed the guides written in github wiki.

Shall I proceed with the pull request to main repository, or are you  
going to review the commit before?

Regards.  
Roberto

–

> **[ZButton](https://zbutton.wordpress.com/)**
>
> Technology and Development blog

blog sobre programacin y tecnologa

---

<div class="post-metadata">

**Author:** ![Roberto\_Perez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Roberto\_Perez](https://www.ruby-forum.com/u/Roberto_Perez)\
**Post date:** [May 13, 2011, 9:42pm UTC](https://www.ruby-forum.com/t/commit-to-solve-bug-string-delete-gives-a-wrong-result-http-ironruby-codeplex-com-workitem-5426/206836/5 "2011-05-13T21:42:27Z")

</div>

Hi!

There was no test to check this problem so i added it to the spec file  
in  
this commit:

> <https://github.com/robjperez/main/commit/83f87a4ab1573511bb4de00a7b57c10ea441c5ee>

I added this:  
“he-lo”.delete(‘-'’).should == “helo”  
which fails in current version but is fixed in the commit I mailed  
before.

In the tags file, there was no tag regarding this issue. There is a tag  
regarding another excepcion with ranges, but I think it is not about  
this  
one.

Cheers  
Roberto.

On Thu, May 12, 2011 at 12:54 AM, Tomas M. \<
