tomo/test/text.tm

106 lines
2.2 KiB
Plaintext
Raw Normal View History

2024-04-28 11:58:55 -07:00
func main():
2024-04-12 10:09:31 -07:00
>> str := "Hello Amélie!"
//! 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-04-12 10:09:31 -07:00
>> \U65\U301
= "é"
2024-04-12 10:09:31 -07:00
>> \UE9 == \U65\U301
= yes
>> 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-04-12 10:09:31 -07:00
= [65_i32, 109_i32, 101_i32, 769_i32, 108_i32, 105_i32, 101_i32] : [Int32]
2024-09-02 17:22:13 -07:00
>> amelie:utf8_bytes()
2024-04-12 10:09:31 -07:00
= [65_i8, 109_i8, 101_i8, -52_i8, -127_i8, 108_i8, 105_i8, 101_i8] : [Int8]
>> 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-04-12 10:09:31 -07:00
= [65_i32, 109_i32, 101_i32, 769_i32, 108_i32, 105_i32, 101_i32] : [Int32]
2024-09-02 17:22:13 -07:00
>> amelie2:utf8_bytes()
2024-04-12 10:09:31 -07:00
= [65_i8, 109_i8, 101_i8, -52_i8, -127_i8, 108_i8, 105_i8, 101_i8] : [Int8]
2024-09-02 17:22:13 -07:00
>> amelie:codepoint_names()
2024-04-12 10:09:31 -07:00
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E", "COMBINING ACUTE ACCENT", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"]
2024-09-02 17:22:13 -07:00
>> amelie2:codepoint_names()
2024-04-12 10:09:31 -07:00
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E", "COMBINING ACUTE ACCENT", "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"
>> "Hello":has("l")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("l[..end]")
= no
2024-09-02 17:22:13 -07:00
>> "Hello":has("[..start]l")
= no
>> "Hello":has("o")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("o[..end]")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("[..start]o")
= no
>> "Hello":has("H")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":has("H[..end]")
= no
2024-09-02 17:22:13 -07:00
>> "Hello":has("[..start]H")
= yes
2024-09-02 17:22:13 -07:00
>> "Hello":replace("l", "")
= "Heo"
2024-09-02 17:22:13 -07:00
>> "xxxx":replace("x", "")
= ""
2024-09-02 17:22:13 -07:00
>> "xxxx":replace("y", "")
= "xxxx"
2024-09-02 17:22:13 -07:00
>> "One two three four five six":replace("e ", "")
= "Ontwo threfour fivsix"
2024-09-02 17:22:13 -07:00
>> " one ":replace("[start][..space]", "")
= "one "
>> " one ":replace("[..space][end]", "")
= " one"
>> amelie:has(amelie2)
2024-07-01 10:09:26 -07:00
>> multiline := "
line one
line two
"
= "line one\nline two"
//! 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"