[MacRuby-devel] When is a String not an NSString?
With respect to the following code
1 require 'test/unit'
2
3 class String
4 def my_method
5 "My Method " + self
6 end
7 end
8
9 class Test_Tumblr < Test::Unit::TestCase
10
11def test_strings
12 cocoa_string = NSString::stringWithString("blah")
13 ruby_string = "Ruby String"
14
15 assert_equal String, cocoa_string.class
16 assert_equal String, ruby_string.class
17 assert_equal cocoa_string.class, ruby_string.class
18
19 assert ruby_string.respond_to?(:my_method),
"ruby_string.respond_to?"
20 assert cocoa_string.respond_to?(:my_method),
"cocoa_string.respond_to?"
21end
22
23 end
What is the expected result of line 20?
On the one hand cocoa_string is an NSString so the monkey patch shouldn't have
any effect, but on the other cocoa_string is claiming to be a ruby String.
Henry
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
[MacRuby-devel] [MacRuby] #784: Exception is generated when change Hash's key.
#784: Exception is generated when change Hash's key.
--+-
Reporter: watson1...@… | Owner: lsansone...@…
Type: defect| Status: new
Priority: blocker | Milestone:
Component: MacRuby |Keywords:
--+-
It seems that this issue blocks #753
Test Script:
{{{
$ cat test_hash.rb
# based on send_header() in "lib/webrick/httpresponse.rb"
hash = {}
hash["content-type"] = "text/html"
hash.each{|key,value|
p "#{key} : #{value}"
tmp = key.gsub(/\bwww|^te$|\b\w/){
p $&
p $&.upcase
}
p tmp
}
}}}
Result of Ruby 1.9.1:
{{{
$ ruby test_hash.rb
"content-type : text/html"
"c"
"C"
"t"
"T"
"Content-Type"
}}}
Result of MacRuby Trunk:
{{{
$ macruby test_hash.rb
"content-type : text/html"
"c"
"C"
/Users/watson/test/ruby/macruby/test_hash.rb:6:in `block': string frozen
(RuntimeError)
from /Users/watson/test/ruby/macruby/test_hash.rb:5:in `'
}}}
Test Script works when changed "key.gsub" to "key.dup.gsub".
--
Ticket URL:
MacRuby
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
