mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/ruby/test_optimization.rb: redefinition tests for String
* test/ruby/test_optimization.rb (test_string_eq_neq): new test (test_string_ltlt): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5733a57455
commit
a1ad7b51f5
2 changed files with 24 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Oct 15 06:51:13 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* test/ruby/test_optimization.rb (test_string_eq_neq): new test
|
||||
(test_string_ltlt): ditto
|
||||
|
||||
Wed Oct 15 06:50:29 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* test/ruby/test_optimization.rb (test_hash_aset_with):
|
||||
|
|
|
@ -116,6 +116,25 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
assert_redefine_method('String', 'freeze', 'assert_nil "foo".freeze')
|
||||
end
|
||||
|
||||
def test_string_eq_neq
|
||||
%w(== !=).each do |m|
|
||||
assert_redefine_method('String', m, <<-end)
|
||||
assert_equal :b, ("a" #{m} "b").to_sym
|
||||
b = 'b'
|
||||
assert_equal :b, ("a" #{m} b).to_sym
|
||||
assert_equal :b, (b #{m} "b").to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_string_ltlt
|
||||
assert_equal "", "" << ""
|
||||
assert_equal "x", "x" << ""
|
||||
assert_equal "x", "" << "x"
|
||||
assert_equal "ab", "a" << "b"
|
||||
assert_redefine_method('String', '<<', 'assert_equal "b", "a" << "b"')
|
||||
end
|
||||
|
||||
def test_array_plus
|
||||
assert_equal [1,2], [1]+[2]
|
||||
assert_redefine_method('Array', '+', 'assert_equal [2], [1]+[2]')
|
||||
|
|
Loading…
Add table
Reference in a new issue