diff options
Diffstat (limited to 'spec/ruby/core/string/dup_spec.rb')
-rw-r--r-- | spec/ruby/core/string/dup_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/ruby/core/string/dup_spec.rb b/spec/ruby/core/string/dup_spec.rb index d650788210..073802d84b 100644 --- a/spec/ruby/core/string/dup_spec.rb +++ b/spec/ruby/core/string/dup_spec.rb @@ -49,4 +49,17 @@ describe "String#dup" do orig.should == "xtring" dup.should == "string" end + + it "does not modify the original setbyte-mutated string when changing dupped string" do + orig = +"a" + orig.setbyte 0, "b".ord + copy = orig.dup + orig.setbyte 0, "c".ord + orig.should == "c" + copy.should == "b" + end + + it "returns a String in the same encoding as self" do + "hello".encode("US-ASCII").dup.encoding.should == Encoding::US_ASCII + end end |