Skip to content

Commit b9c349e

Browse files
chrisseatoneregon
authored andcommitted
Add command-line specs for --enable-frozen-string-literal.
1 parent b6c95d1 commit b9c349e

7 files changed

+31
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require_relative 'freeze_flag_required'
2+
3+
p "abc".freeze.object_id == $second_literal_id
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require_relative 'freeze_flag_required_diff_enc'
2+
3+
p "abc".freeze.object_id != $second_literal_id
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ids = Array.new(2) { "abc".freeze.object_id }
2+
p ids.first == ids.last
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$second_literal_id = "abc".freeze.object_id
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
p "abc".freeze.object_id == "abc".freeze.object_id

command_line/frozen_strings_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
require File.expand_path('../../spec_helper', __FILE__)
2+
3+
describe "The --enable-frozen-string-literal flag causes string literals to" do
4+
5+
it "produce the same object each time" do
6+
ruby_exe(fixture(__FILE__, "freeze_flag_one_literal.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
7+
end
8+
9+
it "produce the same object for literals with the same content" do
10+
ruby_exe(fixture(__FILE__, "freeze_flag_two_literals.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
11+
end
12+
13+
it "produce the same object for literals with the same content in different files" do
14+
ruby_exe(fixture(__FILE__, "freeze_flag_across_files.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
15+
end
16+
17+
it "produce different objects for literals with the same content in different files if they have different encodings" do
18+
ruby_exe(fixture(__FILE__, "freeze_flag_across_files_diff_enc.rb"), options: "--enable-frozen-string-literal").chomp.should == "true"
19+
end
20+
21+
end

0 commit comments

Comments
 (0)