#![cfg(any(
not(any(
feature = "parser_tests",
feature = "analyzer_tests",
feature = "codegen_tests",
feature = "interpreter_tests",
feature = "conformance_tests",
feature = "integration_tests",
)),
feature = "analyzer_tests",
))]
#[path = "common/test_utils.rs"]
mod test_utils;
#[test]
fn test_push_str_with_string_field() {
let source = r#"
struct Menu {
class: string,
}
impl Menu {
pub fn render() -> string {
let mut html = ""
html.push_str("<div class=\"")
html.push_str(self.class)
html.push_str("\">")
html
}
}
"#;
let output = test_utils::compile_single(source);
println!("\n=== Generated Rust ===\n{}\n", output);
assert!(
output.contains("html.push_str"),
"Should contain push_str calls: {}",
output
);
assert!(
!output.contains(".as_str()"),
"Should not need .as_str() - compiler handles it: {}",
output
);
}
#[test]
fn test_push_str_with_string_variable() {
let source = r#"
pub fn concat(a: string, b: string) -> string {
let mut result = ""
result.push_str(a)
result.push_str(b)
result
}
"#;
let output = test_utils::compile_single(source);
println!("\n=== Generated Rust ===\n{}\n", output);
assert!(
!output.contains(".as_str()"),
"Should not need .as_str(): {}",
output
);
}
#[test]
fn test_push_str_with_format_result() {
let source = r#"
pub fn format_message(name: string, age: i32) -> string {
let mut result = ""
result.push_str(format!("Name: {}", name))
result.push_str(format!(", Age: {}", age))
result
}
"#;
let output = test_utils::compile_single(source);
println!("\n=== Generated Rust ===\n{}\n", output);
assert!(
!output.contains(".as_str()"),
"Should not need .as_str() on format! results: {}",
output
);
}