mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 23:05:27 +00:00
Update removeSuffix implementations to match removePrefix (#6636)
This commit is contained in:
@@ -13,15 +13,13 @@ proc testStrip() =
|
||||
proc testRemoveSuffix =
|
||||
var s = "hello\n\r"
|
||||
s.removeSuffix
|
||||
assert s == "hello\n"
|
||||
s.removeSuffix
|
||||
assert s == "hello"
|
||||
s.removeSuffix
|
||||
assert s == "hello"
|
||||
|
||||
s = "hello\n\n"
|
||||
s.removeSuffix
|
||||
assert s == "hello\n"
|
||||
assert s == "hello"
|
||||
|
||||
s = "hello\r"
|
||||
s.removeSuffix
|
||||
@@ -41,7 +39,31 @@ proc testRemoveSuffix =
|
||||
s.removeSuffix({'s','z'})
|
||||
assert s == "hello"
|
||||
s.removeSuffix({'l','o'})
|
||||
assert s == "hell"
|
||||
assert s == "he"
|
||||
|
||||
s = "aeiou"
|
||||
s.removeSuffix("")
|
||||
assert s == "aeiou"
|
||||
|
||||
s = ""
|
||||
s.removeSuffix("")
|
||||
assert s == ""
|
||||
|
||||
s = " "
|
||||
s.removeSuffix
|
||||
assert s == " "
|
||||
|
||||
s = " "
|
||||
s.removeSuffix("")
|
||||
assert s == " "
|
||||
|
||||
s = " "
|
||||
s.removeSuffix(" ")
|
||||
assert s == " "
|
||||
|
||||
s = " "
|
||||
s.removeSuffix(' ')
|
||||
assert s == ""
|
||||
|
||||
# Contrary to Chomp in other languages
|
||||
# empty string does not change behaviour
|
||||
|
||||
Reference in New Issue
Block a user