ccm/tests/str.ccm

30 lines
565 B
Plaintext
Raw Normal View History

2024-03-19 15:25:02 +00:00
assert_eq ("hello", "hello")
assert_ne ("hello", "world")
# INDEX
# =====
assert_eq ("hello"[0], "h")
assert_eq ("hello"[1], "e")
assert_eq ("hello"[2], "l")
assert_eq ("hello"[3], "l")
assert_eq ("hello"[4], "o")
assert_eq ("hello"[-5], "h")
assert_eq ("hello"[-4], "e")
assert_eq ("hello"[-3], "l")
assert_eq ("hello"[-2], "l")
assert_eq ("hello"[-1], "o")
# BINOPS
# ======
assert_eq (
2024-03-21 11:00:20 +00:00
"hello world", "hello "
2024-03-19 15:25:02 +00:00
+ "world"
)
assert_eq ("www", "w" * 3)
assert_eq ("wwww", 4 * "w")
assert_eq ("abab", ("a" + "b") * 2)
assert_eq ("abab", 2 * ("a" + "b"))