mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
parse.y: remove "f" suffix [ruby-core:57966] [Feature #9042]
revert r42847 "test_string.rb: add test string encoding"
revert r42846 "parse.y: freeze in advance to reduce objects"
revert r42843 "parse.y: deduplicate frozen string literals"
revert r42780 "test_string.rb: yet another test"
revert r42779 "parse.y: valid suffix word only"
revert r42778 "test_string.rb: remove duplicated code"
revert r42775 "parse.y: force_encoding"
This reverts commit 93ea04ecec
.
revert r42773 "Add frozen string literals"
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ca375ee74f
commit
90b9996523
7 changed files with 9 additions and 198 deletions
|
@ -2201,60 +2201,6 @@ class TestString < Test::Unit::TestCase
|
|||
})
|
||||
end
|
||||
assert_equal "hello", str
|
||||
assert_not_predicate str, :frozen?
|
||||
end
|
||||
|
||||
def test_frozen_string
|
||||
assert_equal "hello", "hello"f
|
||||
|
||||
assert_predicate "hello"f, :frozen?
|
||||
|
||||
f = -> { "hello"f }
|
||||
|
||||
assert_equal f.call.object_id, f.call.object_id
|
||||
end
|
||||
|
||||
def test_frozen_dstring
|
||||
assert_equal "hello123", "hello#{123}"f
|
||||
|
||||
assert_predicate "hello#{123}"f, :frozen?
|
||||
|
||||
i = 0
|
||||
f = -> { "#{i += 1}"f }
|
||||
assert_equal "1", f.call
|
||||
assert_equal "2", f.call
|
||||
end
|
||||
|
||||
def test_frozen_string_adjacent
|
||||
str = nil
|
||||
assert_nothing_raised(SyntaxError) do
|
||||
eval(%{
|
||||
str = "hello" "world"f
|
||||
})
|
||||
end
|
||||
assert_equal "helloworld", str
|
||||
assert_predicate str, :frozen?
|
||||
end
|
||||
|
||||
def test_frozen_string_cannot_be_adjacent
|
||||
assert_raise(SyntaxError) do
|
||||
eval(%{
|
||||
"hello"f "world"
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
def test_frozen_strings_are_deduplicated
|
||||
a = "hello"f
|
||||
b = "hello"f
|
||||
assert_equal a.object_id, b.object_id
|
||||
end
|
||||
|
||||
def test_frozen_strings_are_deduplicated_with_encoding
|
||||
a = eval("# coding: utf-8\n'hello'f")
|
||||
b = eval("# coding: ascii\n'hello'f")
|
||||
assert_equal Encoding::UTF_8, a.encoding
|
||||
assert_equal Encoding::US_ASCII, b.encoding
|
||||
end
|
||||
|
||||
def test_eq_tilde_can_be_overridden
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue