|
264 | 264 |
|
265 | 265 | # string manipulation
|
266 | 266 | @test strip("\t hi \n") == "hi"
|
| 267 | +@test strip("foobarfoo", ['f', 'o']) == "bar" |
267 | 268 |
|
268 | 269 | # some test strings
|
269 | 270 | astr = "Hello, world.\n"
|
|
573 | 574 | @test search("foo,bar,baz", r"az") == 10:11
|
574 | 575 | @test search("foo,bar,baz", r"az", 12) == 0:-1
|
575 | 576 |
|
| 577 | +@test searchindex("foo", 'o') == 2 |
| 578 | +@test searchindex("foo", 'o', 3) == 3 |
| 579 | + |
576 | 580 | # string searchindex with a two-char UTF-8 (2 byte) string literal
|
577 | 581 | @test searchindex("ééé", "éé") == 1
|
578 | 582 | @test searchindex("ééé", "éé", 1) == 1
|
|
778 | 782 | @test replace("ḟøøƀäṙḟøø", r"(ḟø|ƀä)", "xx") == "xxøxxṙxxø"
|
779 | 783 | @test replace("ḟøøƀäṙḟøø", r"(ḟøø|ƀä)", "ƀäṙ") == "ƀäṙƀäṙṙƀäṙ"
|
780 | 784 |
|
| 785 | +@test replace("foo", "oo", uppercase) == "fOO" |
| 786 | + |
| 787 | +# chomp/chop |
| 788 | +@test chomp("foo\n") == "foo" |
| 789 | +@test chop("foob") == "foo" |
| 790 | + |
781 | 791 | # lower and upper
|
782 | 792 | @test uppercase("aBc") == "ABC"
|
783 | 793 | @test uppercase('A') == 'A'
|
|
806 | 816 | @test !endswith("abcd", "dc")
|
807 | 817 | @test !endswith("cd", "abcd")
|
808 | 818 |
|
| 819 | +@test filter(x -> x ∈ ['f', 'o'], "foobar") == "foo" |
| 820 | + |
809 | 821 | # RepStrings and SubStrings
|
810 | 822 | u8str2 = u8str^2
|
811 | 823 | len_u8str = length(u8str)
|
@@ -848,6 +860,8 @@ ss=SubString(str2,1,4) #empty source string
|
848 | 860 | ss=SubString(str2,1,1) #empty source string, identical start and end index
|
849 | 861 | @test length(ss)==0
|
850 | 862 |
|
| 863 | +@test SubString("foobar",big(1),big(3)) == "foo" |
| 864 | + |
851 | 865 | str = "aa\u2200\u2222bb"
|
852 | 866 | u = SubString(str, 3, 6)
|
853 | 867 | @test length(u)==2
|
@@ -1153,6 +1167,7 @@ end
|
1153 | 1167 |
|
1154 | 1168 | @test symbol("asdf") === :asdf
|
1155 | 1169 | @test symbol(:abc,"def",'g',"hi",0) === :abcdefghi0
|
| 1170 | +@test :a < :b |
1156 | 1171 | @test startswith(string(gensym("asdf")),"##asdf#")
|
1157 | 1172 | @test gensym("asdf") != gensym("asdf")
|
1158 | 1173 | @test gensym() != gensym()
|
|
0 commit comments