2024-04-28 11:58:55 -07:00
func main():
2024-04-12 10:09:31 -07:00
>> str := "Hello Amélie!"
2024-08-18 11:44:15 -07:00
//! Testing strings like $str
2024-07-04 13:23:05 -07:00
2024-04-12 10:09:31 -07:00
>> str:upper()
= "HELLO AMÉLIE!"
>> str:lower()
= "hello amélie!"
>> str:lower():title()
= "Hello Amélie!"
2024-03-03 14:49:40 -08:00
2024-07-04 13:23:05 -07:00
2024-04-12 10:09:31 -07:00
>> \UE9
= "é"
2024-03-03 16:12:53 -08:00
2024-04-12 10:09:31 -07:00
>> \U65\U301
= "é"
2024-03-03 16:12:53 -08:00
2024-04-12 10:09:31 -07:00
>> \UE9 == \U65\U301
= yes
2024-03-03 16:40:01 -08:00
2024-08-18 11:44:15 -07:00
>> amelie := "Am$(\UE9)lie"
2024-04-12 10:09:31 -07:00
>> amelie:clusters()
= ["A", "m", "é", "l", "i", "e"] : [Text]
2024-09-02 17:22:13 -07:00
>> amelie:utf32_codepoints()
2024-09-02 18:18:15 -07:00
= [65_i32, 109_i32, 233_i32, 108_i32, 105_i32, 101_i32] : [Int32]
2024-09-02 17:22:13 -07:00
>> amelie:utf8_bytes()
2024-09-02 18:18:15 -07:00
= [65_i8, 109_i8, -61_i8, -87_i8, 108_i8, 105_i8, 101_i8] : [Int8]
2024-03-03 22:34:12 -08:00
2024-08-18 11:44:15 -07:00
>> amelie2 := "Am$(\U65\U301)lie"
2024-04-12 10:09:31 -07:00
>> amelie2:clusters()
= ["A", "m", "é", "l", "i", "e"] : [Text]
2024-09-02 17:22:13 -07:00
>> amelie2:utf32_codepoints()
2024-09-02 18:18:15 -07:00
= [65_i32, 109_i32, 233_i32, 108_i32, 105_i32, 101_i32] : [Int32]
2024-09-02 17:22:13 -07:00
>> amelie2:utf8_bytes()
2024-09-02 18:18:15 -07:00
= [65_i8, 109_i8, -61_i8, -87_i8, 108_i8, 105_i8, 101_i8] : [Int8]
2024-09-02 17:22:13 -07:00
>> amelie:codepoint_names()
2024-09-02 18:18:15 -07:00
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"]
2024-09-02 17:22:13 -07:00
>> amelie2:codepoint_names()
2024-09-02 18:18:15 -07:00
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"]
2024-03-09 15:22:12 -08:00
2024-04-12 10:09:31 -07:00
>> "Hello":replace("e", "X")
= "HXllo"
2024-05-20 12:19:31 -07:00
>> "Hello":has("l")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("l[..end]")
2024-05-20 12:19:31 -07:00
= no
2024-09-02 17:22:13 -07:00
>> "Hello":has("[..start]l")
2024-05-20 12:19:31 -07:00
= no
>> "Hello":has("o")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("o[..end]")
2024-05-20 12:19:31 -07:00
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("[..start]o")
2024-05-20 12:19:31 -07:00
= no
>> "Hello":has("H")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("H[..end]")
2024-05-20 12:19:31 -07:00
= no
2024-09-02 17:22:13 -07:00
>> "Hello":has("[..start]H")
2024-05-20 12:19:31 -07:00
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":replace("l", "")
2024-05-20 12:19:31 -07:00
= "Heo"
2024-09-02 17:22:13 -07:00
>> "xxxx":replace("x", "")
2024-05-20 12:19:31 -07:00
= ""
2024-09-02 17:22:13 -07:00
>> "xxxx":replace("y", "")
2024-05-20 12:19:31 -07:00
= "xxxx"
2024-09-02 17:22:13 -07:00
>> "One two three four five six":replace("e ", "")
2024-05-20 12:19:31 -07:00
= "Ontwo threfour fivsix"
2024-09-02 18:19:57 -07:00
>> " one ":replace("[..start][..space]", "")
2024-09-02 17:22:13 -07:00
= "one "
2024-09-02 18:19:57 -07:00
>> " one ":replace("[..space][..end]", "")
2024-09-02 17:22:13 -07:00
= " one"
2024-05-20 12:19:31 -07:00
>> amelie:has(amelie2)
2024-07-01 10:09:26 -07:00
>> multiline := "
line one
line two
"
= "line one\nline two"
2024-08-18 11:44:15 -07:00
//! Interpolation tests:
>> "A $(1+2)"
= "A 3"
>> 'A $(1+2)'
= "A $(1+2)"
>> `A $(1+2)`
= "A 3"
>> $"A $(1+2)"
= "A 3"
>> $$"A $(1+2)"
= "A $(1+2)"
>> $="A =(1+2)"
= "A 3"
>> $(one (nested) two $(1+2))
= "one (nested) two 3"
2024-09-02 19:30:19 -07:00
>> "one two three":replace("[..alpha]", "")
2024-09-02 19:42:02 -07:00
= " "
>> "one two three":replace("[..alpha]", "word")
= "word word word"
2024-09-02 19:30:19 -07:00
>> c := "É̩"
>> c:codepoint_names()
= ["LATIN CAPITAL LETTER E WITH ACUTE", "COMBINING VERTICAL LINE BELOW"]
>> c == Text.from_codepoint_names(c:codepoint_names())
= yes
>> c == Text.from_codepoints(c:utf32_codepoints())
= yes
>> c == Text.from_bytes(c:utf8_bytes())
= yes
2024-09-02 19:57:49 -07:00
>> "one$(\n)two$(\n)three":lines()
= ["one", "two", "three"]
>> "one$(\n)two$(\n)three$(\n)":lines()
= ["one", "two", "three"]
>> "one$(\n)two$(\n)three$(\n\n)":lines()
= ["one", "two", "three", ""]
>> "one$(\r\n)two$(\r\n)three$(\r\n)":lines()
= ["one", "two", "three"]