feat: 添加对单引号字符串的支持,更新词法分析器和相关测试用例

This commit is contained in:
0264408
2026-06-16 19:16:48 +08:00
parent 5e431dbba4
commit fdd42fce19
2 changed files with 85 additions and 5 deletions
+24
View File
@@ -750,6 +750,30 @@ mod tests {
}
}
#[test]
fn eval_single_quoted_string() {
match eval_expr("'hello'") {
Value::String(s) => assert_eq!(s, "hello"),
v => panic!("Expected String, got {:?}", v),
}
}
#[test]
fn eval_mixed_quotes_concat() {
match eval_expr("\"a\" + 'b'") {
Value::String(s) => assert_eq!(s, "ab"),
v => panic!("Expected String, got {:?}", v),
}
}
#[test]
fn eval_single_quote_containing_double() {
match eval_expr("'he\"llo'") {
Value::String(s) => assert_eq!(s, "he\"llo"),
v => panic!("Expected String, got {:?}", v),
}
}
#[test]
fn eval_string_plus_number() {
match eval_expr("\"a\" + 42") {