tomo/test/text.tm

118 lines
2.3 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]
>> amelie:codepoints()
= [65_i32, 109_i32, 101_i32, 769_i32, 108_i32, 105_i32, 101_i32] : [Int32]
>> amelie:bytes()
= [65_i8, 109_i8, 101_i8, -52_i8, -127_i8, 108_i8, 105_i8, 101_i8] : [Int8]
>> amelie:num_clusters()
= 6
>> amelie:num_codepoints()
= 7
>> amelie:num_bytes()
= 8
>> amelie2 := "Am$(\U65\U301)lie"
2024-04-12 10:09:31 -07:00
>> amelie2:clusters()
= ["A", "m", "é", "l", "i", "e"] : [Text]
>> amelie2:codepoints()
= [65_i32, 109_i32, 101_i32, 769_i32, 108_i32, 105_i32, 101_i32] : [Int32]
>> amelie2:bytes()
= [65_i8, 109_i8, 101_i8, -52_i8, -127_i8, 108_i8, 105_i8, 101_i8] : [Int8]
>> amelie2:num_clusters()
= 6
>> amelie2:num_codepoints()
= 7
>> amelie2:num_bytes()
= 8
2024-04-12 10:09:31 -07:00
>> amelie:character_names()
= ["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"]
>> amelie2:character_names()
= ["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
>> "Hello":has("l", End)
= no
>> "Hello":has("l", Start)
= no
>> "Hello":has("o")
= yes
>> "Hello":has("o", where=End)
= yes
>> "Hello":has("o", where=Start)
= no
>> "Hello":has("H")
= yes
>> "Hello":has("H", End)
= no
>> "Hello":has("H", Start)
= yes
>> "Hello":without("l")
= "Heo"
>> "xxxx":without("x")
= ""
>> "xxxx":without("y")
= "xxxx"
>> "One two three four five six":without("e ")
= "Ontwo threfour fivsix"
>> " one ":trimmed()
= "one"
>> " one ":trimmed(" aeiou")
= "n"
>> 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"