# SVN r94: Getting Ruby String to Rails spec pass rate of 89%

**URL:** <https://www.ruby-forum.com/t/svn-r94-getting-ruby-string-to-rails-spec-pass-rate-of-89/135468>\
**Category:** IronRuby\
**Created:** [April 22, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/svn-r94-getting-ruby-string-to-rails-spec-pass-rate-of-89/135468 "2008-04-22T14:44:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_LSSIRONRUBY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4491bb/32.png) [@John\_LSSIRONRUBY](https://www.ruby-forum.com/u/John_LSSIRONRUBY)\
**Post date:** [April 22, 2008, 2:44pm UTC](https://www.ruby-forum.com/t/svn-r94-getting-ruby-string-to-rails-spec-pass-rate-of-89/135468/1 "2008-04-22T14:44:43Z")

</div>

Summary:

Changes in String to get us closer to running Rails. We are now passing  
Rails specs at a 375/421 (89%) rate. String specs overall are passing at  
a 572/744 (76%) rate. Most of the specs that are failing are related to  
different regex implementation between .NET and Ruby. This shelveset  
passed SNAP this morning.

Details:

This is a targeted set of changes that aims to implement only the String  
methods that our Rails dynamic traces list. The goal is to get these  
changes to maximum conformance with the spec test suite.

Overall, these are the test pass results from methods used by Rails:

```
       Pass Total %

```

% 63 69 91%

- 

```
          6 6 100%

```

- 

```
          4 4 100%

```

\<=\> 10 11 91%  
== 5 5 100%  
[] 88 89 99%  
chop 9 9 100%  
concat 10 10 100%  
delete[!] 10 11 91%  
downcase[!] 7 7 100%  
dump 4 4 100%  
each 8 10 80%  
empty? 1 1 100%  
gsub[!] 26 38 68%  
hash 1 1 100%  
inspect 2 3 67%  
length 1 1 100%  
match[=~] 11 11 100%  
replace 5 5 100%  
scan 11 15 73%  
size 1 1 100%  
split 26 27 96%  
strip[!] 4 5 80%  
sub[!] 26 39 67%  
to\_i 10 12 83%  
to\_s 3 3 100%  
to\_str 3 3 100%  
to\_sym 2 2 100%  
tr 11 11 100%  
unpack 0 1 0%  
upcase[!] 7 7 86%  
375 421 89%

Frozen / taint related changes:

- Added Protocols.FlowTaint() helpers to add taint tracking to String  
APIs
- Added Protocols.AssertNotFrozen() helpers
- Simple changes in Hash and Array to clean up some of the simple frozen  
/ taint specs that were failing.

Regex related changes:

- Added Match#begin, which is used by String APIs
- Fixed Match#match and Match#=~ methods so that they pass the specs
- Added Match.escape/quote and Match.last\_match
- Added some constructors and an IDuplicable implementation for Regexp  
builtin

Miscellaneous changes:

- 1 line change to Socket.cs that reflects changes in MutableString
- Added helper methods and a new char ctor to MutableString
- Kernel#clone, Kernel#dup, Kernel#to\_s now flow taint correctly
- Fixed a bug in at\_exit related to recent DLR DynamicSites refactoring  
(rubycontext.cs).
- Resets the baseline spec excludes to reflect new 572 passing baseline

String formatter related changes:

StringFormatter: This class contains a lot of changes to correctly  
support the String#% specs. That said, right now StringFormatter really  
needs a rewrite so that we align our error messages with Ruby error  
messages when format strings are incorrect. Some of the changes around  
how numbers are formatted will remain, but there is future work to be  
done here to clean up this class. We are mostly correct in the specs  
today, with just a few corner cases where we break. Some of these corner  
case examples are commented out in the modulo\_spec.rb file. When we  
migrate to the latest Rubinius specs these will break again, which is  
fine since that will be a good time for us to revisit these changes.

String related changes

MutableStringOps: The specs that we are failing today fall into one of  
two camps: 1) those that are related to creating subclasses of String in  
methods that return Strings.

- Added helpers to create String subclasses - due to a bug today in not  
calling inherited initializers, these helpers aren’t wired up everywhere  
yet today.
- Added helpers for detecting frozen strings.
- Added RangeParser/IntervalParser helper classes to parse format  
strings used in #delete, #count, and #tr methods. These are strings of  
the form c1-c2 with negation (^) and intersection.
- Started inserting ri#method documentation as comments before each  
method to better capture the Ruby semantics of a method in our sources.  
These docs are not as complete as the specs, which are much more  
authoritative here.
- Many modifications to existing methods to support flowing taint and  
frozen semantics.
- Fixed implementation of #\<\<, #concat.
- Added ‘turn-it-around’ comparison logic to String#\<=\>
- Added Regex support to #slice[!] methods
- Rewrote String#chomp implementation to pass 100% of specs and run on  
Silverlight
- Fixed implementations of #casecmp, #capitalize[!], #downcase[!],  
#swapcase[!], #upcase[!], #chop[!],
- Added some missing metacharacters to #dump, #inspect.
- Fixed implementation of #each, #each\_line to correctly deal with  
defaults
- Fixed a number of bugs in #sub[!], #gsub[!]
- Removed overloads that take a string parameter. We only have overloads  
that accept MutableString and object (via Protocols.CastToString()).
- Cleaned up implementation of #index
- Added new implementations of #delete[!] and #count
- Added #=~ and cleaned up #match
- Added #scan implementation
- Cleaned up #succ[!]
- Added full implementation of #split[!]
- Added an implementation of #to\_i that uses Ruby tokenizer to generate  
output
- Added full implementation of #replace
- Added full implementation of #tr[!]

There are also a ton of other DLR and Ruby-related changes in this  
changeset, but these are the most visible ones at this time. Will  
summarize details in a future mail.

Thanks,  
-John
