feat: 添加对单引号字符串的支持,更新词法分析器和相关测试用例
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user