Skip to content

Commit

Permalink
Add spec to test String literals behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin authored and eregon committed Mar 19, 2024
1 parent 3446315 commit e2f39fe
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions language/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,18 @@ def long_string_literals
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files.rb")).chomp.should == "true"
end

it "produce different objects for literals with the same content in different files if the other file doesn't have the comment" do
frozen_literals_by_default = eval("'test'").frozen?
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == (!frozen_literals_by_default).to_s
guard -> { !eval("'test'").frozen? } do
it "produces different objects for literals with the same content in different files if the other file doesn't have the comment and String literals aren't frozen by default" do
frozen_literals_by_default = eval("'test'").frozen?
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == "true"
end
end

guard -> { eval("'test'").frozen? } do
it "produces the same objects for literals with the same content in different files if the other file doesn't have the comment and String literals are frozen by default" do
frozen_literals_by_default = eval("'test'").frozen?
ruby_exe(fixture(__FILE__, "freeze_magic_comment_across_files_no_comment.rb")).chomp.should == "false"
end
end

it "produce different objects for literals with the same content in different files if they have different encodings" do
Expand Down

0 comments on commit e2f39fe

Please sign in to comment.