Update tests to proposed changes
This commit is contained in:
parent
d28862422b
commit
94149f7a48
1 changed files with 39 additions and 16 deletions
|
|
@ -10,25 +10,48 @@ import
|
||||||
proc testStrip() =
|
proc testStrip() =
|
||||||
write(stdout, strip(" ha "))
|
write(stdout, strip(" ha "))
|
||||||
|
|
||||||
proc testChomp =
|
proc testRemoveSuffix =
|
||||||
assert "hello".chomp == "hello"
|
var s = "hello\n\r"
|
||||||
assert "hello\n".chomp == "hello"
|
s.removeSuffix
|
||||||
assert "hello\r\n".chomp == "hello"
|
assert s == "hello\n"
|
||||||
assert "hello\n\r".chomp == "hello\n"
|
s.removeSuffix
|
||||||
assert "hello\n\n".chomp == "hello\n"
|
assert s == "hello"
|
||||||
assert "hello\r".chomp == "hello"
|
s.removeSuffix
|
||||||
assert "hello \n there".chomp == "hello \n there"
|
assert s == "hello"
|
||||||
assert "hello".chomp("llo") == "he"
|
|
||||||
assert "hellos".chomp('s') == "hello"
|
s = "hello\n\n"
|
||||||
assert "hellos".chomp({'s','z'}) == "hello"
|
s.removeSuffix
|
||||||
assert "hellos".chomp({'o','s'}) == "hello"
|
assert s == "hello\n"
|
||||||
assert "hello\r\n\r\n".chomp("") == "hello"
|
|
||||||
assert "hello\r\n\r\r\n".chomp("") == "hello\r\n\r"
|
s = "hello\r"
|
||||||
assert "hello\n\n\n\n\n".chomp("") == "hello"
|
s.removeSuffix
|
||||||
|
assert s == "hello"
|
||||||
|
|
||||||
|
s = "hello \n there"
|
||||||
|
s.removeSuffix
|
||||||
|
assert s == "hello \n there"
|
||||||
|
|
||||||
|
s = "hello"
|
||||||
|
s.removeSuffix("llo")
|
||||||
|
assert s == "he"
|
||||||
|
s.removeSuffix('e')
|
||||||
|
assert s == "h"
|
||||||
|
|
||||||
|
s = "hellos"
|
||||||
|
s.removeSuffix({'s','z'})
|
||||||
|
assert s == "hello"
|
||||||
|
s.removeSuffix({'l','o'})
|
||||||
|
assert s == "hell"
|
||||||
|
|
||||||
|
# Contrary to Chomp in other languages
|
||||||
|
# empty string does not change behaviour
|
||||||
|
s = "hello\r\n\r\n"
|
||||||
|
s.removeSuffix("")
|
||||||
|
assert s == "hello\r\n\r\n"
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
testStrip()
|
testStrip()
|
||||||
testChomp()
|
testRemoveSuffix()
|
||||||
for p in split("/home/a1:xyz:/usr/bin", {':'}):
|
for p in split("/home/a1:xyz:/usr/bin", {':'}):
|
||||||
write(stdout, p)
|
write(stdout, p)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue