Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make replace with count=0 a no-op #22325

Merged
merged 13 commits into from
Jul 4, 2017
Merged
Prev Previous commit
Next Next commit
check replace is implemented for GenericString (nalimilan)
  • Loading branch information
rfourquet committed Jul 4, 2017
commit 06a7706c799f0f70b8824cd9930883b6d8d2fde1
18 changes: 11 additions & 7 deletions test/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,17 @@ end
# Issue 13332
@test replace("abc", 'b', 2.1) == "a2.1c"

# test replace with a count, check that replace is a no-op if count==0
# @test replace("aaa", 'a', 'z', 0) == "aaa" # re-enable when undeprecated
@test replace("aaa", 'a', 'z', 1) == "zaa"
@test replace("aaa", 'a', 'z', 2) == "zza"
@test replace("aaa", 'a', 'z', 3) == "zzz"
@test replace("aaa", 'a', 'z', 4) == "zzz"
@test replace("aaa", 'a', 'z', typemax(Int)) == "zzz"
# test replace with a count for String and GenericString
# check that replace is a no-op if count==0
for s in ["aaa", Base.Test.GenericString("aaa")]
# @test replace("aaa", 'a', 'z', 0) == "aaa" # enable when undeprecated
@test replace(s, 'a', 'z', 1) == "zaa"
@test replace(s, 'a', 'z', 2) == "zza"
@test replace(s, 'a', 'z', 3) == "zzz"
@test replace(s, 'a', 'z', 4) == "zzz"
@test replace(s, 'a', 'z', typemax(Int)) == "zzz"
@test replace(s, 'a', 'z') == "zzz"
end

# chomp/chop
@test chomp("foo\n") == "foo"
Expand Down