ccm/tests/str.ccm

30 lines
565 B
Plaintext

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 (
"hello world", "hello "
+ "world"
)
assert_eq ("www", "w" * 3)
assert_eq ("wwww", 4 * "w")
assert_eq ("abab", ("a" + "b") * 2)
assert_eq ("abab", 2 * ("a" + "b"))