[macruby-changes] [MacRuby/MacRuby] 11bfef: StringScanner.new, #{string=, concat} will convert...

noreply at github.com noreply at github.com
Sat Apr 2 16:15:40 PDT 2011


Branch: refs/heads/master
Home:   https://github.com/MacRuby/MacRuby

Commit: 11bfefe9d593ec6882674aea93c0c9c84b0a315e
    https://github.com/MacRuby/MacRuby/commit/11bfefe9d593ec6882674aea93c0c9c84b0a315e
Author: Watson <watson1978 at gmail.com>
Date:   2011-04-02 (Sat, 02 Apr 2011)

Changed paths:
  M lib/strscan.rb

Log Message:
-----------
StringScanner.new, #{string=, concat} will convert passed object into string using #to_str.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
require 'strscan'

obj = Object.new
def obj.to_str
  "hello world"
end

s1 = StringScanner.new(obj)
assert_equal("hello world", s1.string)
assert_raise(TypeError) { StringScanner.new(:bar) }

s2 = StringScanner.new("foo")
s2.string = obj
assert_equal("hello world", s2.string)
assert_raise(TypeError) { s2.string = :baz }

s3 = StringScanner.new("bar")
s3 << obj
assert_equal("barhello world", s3.string)
assert_raise(TypeError) { s3 << :baz }

puts :ok
}}}


Commit: 17be4634582ac22c418b0ec676831f3579837b7f
    https://github.com/MacRuby/MacRuby/commit/17be4634582ac22c418b0ec676831f3579837b7f
Author: Watson <watson1978 at gmail.com>
Date:   2011-04-02 (Sat, 02 Apr 2011)

Changed paths:
  M lib/strscan.rb
  M spec/frozen/tags/macruby/library/stringscanner/scan_tags.txt

Log Message:
-----------
StringScanner#scan will raise a TypeError if pattern isn't a Regexp.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
require 'strscan'

s = StringScanner.new("This is a test")
assert_raise(TypeError){ s.scan("abc") }

puts :ok
}}}


Compare: https://github.com/MacRuby/MacRuby/compare/e2ba7f2...17be463


More information about the macruby-changes mailing list