File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 output . should == 'foobar'
1414 end
1515
16- it 'returns self if the String is not frozen ' do
17- input = ' foo'
16+ it 'returns a mutable String itself ' do
17+ input = String . new ( " foo" )
1818 output = +input
1919
20- output . equal? ( input ) . should == true
20+ output . should . equal? ( input )
21+
22+ input << "bar"
23+ output . should == "foobar"
24+ end
25+
26+ context 'if file has "frozen_string_literal: true" magic comment' do
27+ it 'returns mutable copy of a literal' do
28+ ruby_exe ( fixture ( __FILE__ , "freeze_magic_comment.rb" ) ) . should == 'mutable'
29+ end
2130 end
2231
23- it 'returns mutable copy despite freeze-magic-comment in file' do
24- ruby_exe ( fixture ( __FILE__ , "freeze_magic_comment.rb" ) ) . should == 'mutable'
32+ context 'if file has "frozen_string_literal: false" magic comment' do
33+ it 'returns literal string itself' do
34+ input = 'foo'
35+ output = +input
36+
37+ output . equal? ( input ) . should == true
38+ end
39+ end
40+
41+ context 'if file has no frozen_string_literal magic comment' do
42+ ruby_version_is '' ...'3.4' do
43+ it 'returns literal string itself' do
44+ eval ( <<~RUBY ) . should == true
45+ s = "foo"
46+ s.equal?(+s)
47+ RUBY
48+ end
49+ end
50+
51+ ruby_version_is '3.4' do
52+ it 'returns mutable copy of a literal' do
53+ eval ( <<~RUBY ) . should == false
54+ s = "foo"
55+ s.equal?(+s)
56+ RUBY
57+ end
58+ end
2559 end
2660end
You can’t perform that action at this time.
0 commit comments