module lexer fn test_single_byte_spellings_are_exact_terminated_and_source_independent() { for byte in 0 .. 256 { source := [u8(byte)].bytestr() span := TokenSpan{.identifier, 0, 1, 1, 1} text := span.text(source) unsafe { source.free() } gc_collect() assert text.len == 1 assert text[0] == u8(byte) assert unsafe { text.str[1] } == 0 unsafe { text.free() } } } fn test_collected_tokens_keep_their_spellings_after_source_release() { source := 'x 1 + x 1'.clone() tokens := tokenize(source) or { panic(err) } unsafe { source.free() } gc_collect() assert tokens.map(it.lexeme) == ['x', '1', '+', 'x', '1', ''] for token in tokens { unsafe { token.lexeme.free() } } }