summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-05 13:27:48 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-05 13:27:48 +0000
commit805c20a8e59315f15dbb22ac1518de6a27385039 (patch)
tree81b4d726b3ee9e06afa2f0781dfbad263c62dbff /test
parentfab171e541f7b7373efe386ae956d7a44ce4e330 (diff)
* lib/pp.rb: Use frozen_string_literal: true.
* lib/prettyprint.rb: Ditto. * lib/resolv.rb: Ditto. * lib/tmpdir.rb: Ditto. * test/test_pp.rb: Ditto. * test/test_prettyprint.rb: Ditto. * tool/transcode-tblgen.rb: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/test_pp.rb50
-rw-r--r--test/test_prettyprint.rb14
2 files changed, 34 insertions, 30 deletions
diff --git a/test/test_pp.rb b/test/test_pp.rb
index 813daf0446..69594c0aef 100644
--- a/test/test_pp.rb
+++ b/test/test_pp.rb
@@ -1,3 +1,5 @@
+# -*- frozen_string_literal: true -*-
+
require 'pp'
require 'delegate'
require 'test/unit'
@@ -6,24 +8,24 @@ module PPTestModule
class PPTest < Test::Unit::TestCase
def test_list0123_12
- assert_equal("[0, 1, 2, 3]\n", PP.pp([0,1,2,3], '', 12))
+ assert_equal("[0, 1, 2, 3]\n", PP.pp([0,1,2,3], ''.dup, 12))
end
def test_list0123_11
- assert_equal("[0,\n 1,\n 2,\n 3]\n", PP.pp([0,1,2,3], '', 11))
+ assert_equal("[0,\n 1,\n 2,\n 3]\n", PP.pp([0,1,2,3], ''.dup, 11))
end
OverriddenStruct = Struct.new("OverriddenStruct", :members, :class)
def test_struct_override_members # [ruby-core:7865]
a = OverriddenStruct.new(1,2)
- assert_equal("#<struct Struct::OverriddenStruct members=1, class=2>\n", PP.pp(a, ''))
+ assert_equal("#<struct Struct::OverriddenStruct members=1, class=2>\n", PP.pp(a, ''.dup))
end
def test_redefined_method
- o = ""
+ o = "".dup
def o.method
end
- assert_equal(%(""\n), PP.pp(o, ""))
+ assert_equal(%(""\n), PP.pp(o, "".dup))
end
end
@@ -76,17 +78,17 @@ end
class PPInspectTest < Test::Unit::TestCase
def test_hasinspect
a = HasInspect.new(1)
- assert_equal("<inspect:1>\n", PP.pp(a, ''))
+ assert_equal("<inspect:1>\n", PP.pp(a, ''.dup))
end
def test_hasprettyprint
a = HasPrettyPrint.new(1)
- assert_equal("<pretty_print:1>\n", PP.pp(a, ''))
+ assert_equal("<pretty_print:1>\n", PP.pp(a, ''.dup))
end
def test_hasboth
a = HasBoth.new(1)
- assert_equal("<pretty_print:1>\n", PP.pp(a, ''))
+ assert_equal("<pretty_print:1>\n", PP.pp(a, ''.dup))
end
def test_pretty_print_inspect
@@ -98,21 +100,21 @@ class PPInspectTest < Test::Unit::TestCase
def test_proc
a = proc {1}
- assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup))
end
def test_to_s_with_iv
a = Object.new
def a.to_s() "aaa" end
a.instance_eval { @a = nil }
- result = PP.pp(a, '')
+ result = PP.pp(a, ''.dup)
assert_equal("#{a.inspect}\n", result)
end
def test_to_s_without_iv
a = Object.new
def a.to_s() "aaa" end
- result = PP.pp(a, '')
+ result = PP.pp(a, ''.dup)
assert_equal("#{a.inspect}\n", result)
end
end
@@ -121,48 +123,48 @@ class PPCycleTest < Test::Unit::TestCase
def test_array
a = []
a << a
- assert_equal("[[...]]\n", PP.pp(a, ''))
- assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ assert_equal("[[...]]\n", PP.pp(a, ''.dup))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup))
end
def test_hash
a = {}
a[0] = a
- assert_equal("{0=>{...}}\n", PP.pp(a, ''))
- assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ assert_equal("{0=>{...}}\n", PP.pp(a, ''.dup))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup))
end
S = Struct.new("S", :a, :b)
def test_struct
a = S.new(1,2)
a.b = a
- assert_equal("#<struct Struct::S a=1, b=#<struct Struct::S:...>>\n", PP.pp(a, ''))
- assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ assert_equal("#<struct Struct::S a=1, b=#<struct Struct::S:...>>\n", PP.pp(a, ''.dup))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup))
end
def test_object
a = Object.new
a.instance_eval {@a = a}
- assert_equal(a.inspect + "\n", PP.pp(a, ''))
+ assert_equal(a.inspect + "\n", PP.pp(a, ''.dup))
end
def test_anonymous
a = Class.new.new
- assert_equal(a.inspect + "\n", PP.pp(a, ''))
+ assert_equal(a.inspect + "\n", PP.pp(a, ''.dup))
end
def test_withinspect
a = []
a << HasInspect.new(a)
- assert_equal("[<inspect:[...]>]\n", PP.pp(a, ''))
- assert_equal("#{a.inspect}\n", PP.pp(a, ''))
+ assert_equal("[<inspect:[...]>]\n", PP.pp(a, ''.dup))
+ assert_equal("#{a.inspect}\n", PP.pp(a, ''.dup))
end
def test_share_nil
begin
PP.sharing_detection = true
a = [nil, nil]
- assert_equal("[nil, nil]\n", PP.pp(a, ''))
+ assert_equal("[nil, nil]\n", PP.pp(a, ''.dup))
ensure
PP.sharing_detection = false
end
@@ -171,8 +173,8 @@ end
class PPSingleLineTest < Test::Unit::TestCase
def test_hash
- assert_equal("{1=>1}", PP.singleline_pp({ 1 => 1}, '')) # [ruby-core:02699]
- assert_equal("[1#{', 1'*99}]", PP.singleline_pp([1]*100, ''))
+ assert_equal("{1=>1}", PP.singleline_pp({ 1 => 1}, ''.dup)) # [ruby-core:02699]
+ assert_equal("[1#{', 1'*99}]", PP.singleline_pp([1]*100, ''.dup))
end
end
diff --git a/test/test_prettyprint.rb b/test/test_prettyprint.rb
index 1d6b75a569..0d087b4a78 100644
--- a/test/test_prettyprint.rb
+++ b/test/test_prettyprint.rb
@@ -1,3 +1,5 @@
+# -*- frozen_string_literal: true -*-
+
require 'prettyprint'
require 'test/unit'
@@ -14,7 +16,7 @@ class WadlerExample < Test::Unit::TestCase # :nodoc:
end
def hello(width)
- PrettyPrint.format('', width) {|hello|
+ PrettyPrint.format(''.dup, width) {|hello|
hello.group {
hello.group {
hello.group {
@@ -81,7 +83,7 @@ End
end
def tree(width)
- PrettyPrint.format('', width) {|q| @tree.show(q)}
+ PrettyPrint.format(''.dup, width) {|q| @tree.show(q)}
end
def test_tree_00_19
@@ -126,7 +128,7 @@ End
end
def tree_alt(width)
- PrettyPrint.format('', width) {|q| @tree.altshow(q)}
+ PrettyPrint.format(''.dup, width) {|q| @tree.altshow(q)}
end
def test_tree_alt_00_18
@@ -242,7 +244,7 @@ end
class StrictPrettyExample < Test::Unit::TestCase # :nodoc:
def prog(width)
- PrettyPrint.format('', width) {|q|
+ PrettyPrint.format(''.dup, width) {|q|
q.group {
q.group {q.nest(2) {
q.text "if"; q.breakable;
@@ -387,7 +389,7 @@ end
class TailGroup < Test::Unit::TestCase # :nodoc:
def test_1
- out = PrettyPrint.format('', 10) {|q|
+ out = PrettyPrint.format(''.dup, 10) {|q|
q.group {
q.group {
q.text "abc"
@@ -426,7 +428,7 @@ end
class Fill < Test::Unit::TestCase # :nodoc:
def format(width)
- PrettyPrint.format('', width) {|q|
+ PrettyPrint.format(''.dup, width) {|q|
q.group {
q.text 'abc'
q.fill_breakable