ruby-changes:45478
From: kazu <ko1@a...>
Date: Mon, 6 Feb 2017 22:23:45 +0900 (JST)
Subject: [ruby-changes:45478] kazu:r57551 (trunk): {ext, test}/strscan: Specify frozen_string_literal: true.
kazu 2017-02-06 22:23:39 +0900 (Mon, 06 Feb 2017) New Revision: 57551 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57551 Log: {ext,test}/strscan: Specify frozen_string_literal: true. Modified files: trunk/ext/strscan/extconf.rb trunk/test/strscan/test_stringscanner.rb Index: ext/strscan/extconf.rb =================================================================== --- ext/strscan/extconf.rb (revision 57550) +++ ext/strscan/extconf.rb (revision 57551) @@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/ext/strscan/extconf.rb#L1 -# frozen_string_literal: false +# frozen_string_literal: true require 'mkmf' $INCFLAGS << " -I$(top_srcdir)" create_makefile 'strscan' Index: test/strscan/test_stringscanner.rb =================================================================== --- test/strscan/test_stringscanner.rb (revision 57550) +++ test/strscan/test_stringscanner.rb (revision 57551) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L1 # -*- coding: utf-8 -*- -# frozen_string_literal: false +# frozen_string_literal: true # # test/strscan/test_stringscanner.rb # @@ -14,7 +14,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L14 assert_equal false, s.eos? assert_equal false, s.tainted? - str = 'test string' + str = 'test string'.dup str.taint s = StringScanner.new(str, false) assert_instance_of StringScanner, s @@ -22,7 +22,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L22 assert_same str, s.string assert_equal true, s.string.tainted? - str = 'test string' + str = 'test string'.dup str.taint s = StringScanner.new(str) assert_equal true, s.string.tainted? @@ -96,7 +96,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L96 end def test_inspect - str = 'test string' + str = 'test string'.dup str.taint s = StringScanner.new(str, false) assert_instance_of String, s.inspect @@ -124,7 +124,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L124 s.scan(/\w+/) assert_equal true, s.eos? - s = StringScanner.new('test') + s = StringScanner.new('test'.dup) s.scan(/te/) s.string.replace '' assert_equal true, s.eos? @@ -181,11 +181,11 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L181 end def test_string_append - s = StringScanner.new('tender') + s = StringScanner.new('tender'.dup) s << 'love' assert_equal 'tenderlove', s.string - s.string = 'tender' + s.string = 'tender'.dup s << 'love' assert_equal 'tenderlove', s.string end @@ -213,7 +213,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L213 end def test_concat - s = StringScanner.new('a') + s = StringScanner.new('a'.dup) s.scan(/a/) s.concat 'b' assert_equal false, s.eos? @@ -246,7 +246,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L246 assert_nil s.scan(/\w+/) - str = 'stra strb strc' + str = 'stra strb strc'.dup str.taint s = StringScanner.new(str, false) tmp = s.scan(/\w+/) @@ -267,7 +267,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L267 assert_nil s.scan(/\w+/) assert_nil s.scan(/\w+/) - s = StringScanner.new('test') + s = StringScanner.new('test'.dup) s.scan(/te/) # This assumes #string does not duplicate string, # but it is implementation specific issue. @@ -293,7 +293,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L293 assert_nil s.skip(/\s+/) assert_equal true, s.eos? - s = StringScanner.new('test') + s = StringScanner.new('test'.dup) s.scan(/te/) s.string.replace '' assert_equal nil, s.skip(/./) @@ -313,7 +313,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L313 assert_equal 'e', s.getch assert_nil s.getch - str = 'abc' + str = 'abc'.dup str.taint s = StringScanner.new(str) assert_equal true, s.getch.tainted? @@ -321,11 +321,11 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L321 assert_equal true, s.getch.tainted? assert_nil s.getch - s = StringScanner.new("\244\242".force_encoding("euc-jp")) - assert_equal "\244\242".force_encoding("euc-jp"), s.getch + s = StringScanner.new("\244\242".dup.force_encoding("euc-jp")) + assert_equal "\244\242".dup.force_encoding("euc-jp"), s.getch assert_nil s.getch - s = StringScanner.new('test') + s = StringScanner.new('test'.dup) s.scan(/te/) s.string.replace '' assert_equal nil, s.getch @@ -341,7 +341,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L341 assert_nil s.get_byte assert_nil s.get_byte - str = 'abc' + str = 'abc'.dup str.taint s = StringScanner.new(str) assert_equal true, s.get_byte.tainted? @@ -349,12 +349,12 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L349 assert_equal true, s.get_byte.tainted? assert_nil s.get_byte - s = StringScanner.new("\244\242".force_encoding("euc-jp")) - assert_equal "\244".force_encoding("euc-jp"), s.get_byte - assert_equal "\242".force_encoding("euc-jp"), s.get_byte + s = StringScanner.new("\244\242".dup.force_encoding("euc-jp")) + assert_equal "\244".dup.force_encoding("euc-jp"), s.get_byte + assert_equal "\242".dup.force_encoding("euc-jp"), s.get_byte assert_nil s.get_byte - s = StringScanner.new('test') + s = StringScanner.new('test'.dup) s.scan(/te/) s.string.replace '' assert_equal nil, s.get_byte @@ -387,7 +387,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L387 assert_equal 't', s.matched assert_equal false, s.matched.tainted? - str = 'test' + str = 'test'.dup str.taint s = StringScanner.new(str) s.scan(/\w+/) @@ -447,11 +447,11 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L447 assert_nil s[0] - s = StringScanner.new("\244\242".force_encoding("euc-jp")) + s = StringScanner.new("\244\242".dup.force_encoding("euc-jp")) s.getch - assert_equal "\244\242".force_encoding("euc-jp"), s[0] + assert_equal "\244\242".dup.force_encoding("euc-jp"), s[0] - str = 'test' + str = 'test'.dup str.taint s = StringScanner.new(str) s.scan(/(t)(e)(s)(t)/) @@ -496,7 +496,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L496 s.scan(/never match/) assert_nil s.pre_match - str = 'test string' + str = 'test string'.dup str.taint s = StringScanner.new(str) s.scan(/\w+/) @@ -530,7 +530,7 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L530 s.scan(/./) assert_nil s.post_match - str = 'test string' + str = 'test string'.dup str.taint s = StringScanner.new(str) s.scan(/\w+/) @@ -585,14 +585,14 @@ class TestStringScanner < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/strscan/test_stringscanner.rb#L585 end def test_encoding - ss = StringScanner.new("\xA1\xA2".force_encoding("euc-jp")) + ss = StringScanner.new("\xA1\xA2".dup.force_encoding("euc-jp")) assert_equal(Encoding::EUC_JP, ss.scan(/./e).encoding) end def test_generic_regexp - ss = StringScanner.new("\xA1\xA2".force_encoding("euc-jp")) + ss = StringScanner.new("\xA1\xA2".dup.force_encoding("euc-jp")) t = ss.scan(/./) - assert_equal("\xa1\xa2".force_encoding("euc-jp"), t) + assert_equal("\xa1\xa2".dup.force_encoding("euc-jp"), t) end def test_set_pos -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/