#![allow(missing_docs)]
use predicates::prelude::*;
#[test]
fn test_parser_087_01_two_str_refs_bool_return() {
let code = r"
impl ConfigManager {
fun test_two_refs_bool(&self, key: &str, value: &str) -> bool {
return true
}
}
";
let temp_file = "/tmp/test_parser_087_01.ruchy";
std::fs::write(temp_file, code).expect("Failed to write test file");
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
.arg("check")
.arg(temp_file)
.assert()
.success()
.stdout(predicate::str::contains("Syntax is valid"));
std::fs::remove_file(temp_file).ok();
}
#[test]
fn test_parser_087_02_two_str_refs_string_return() {
let code = r#"
impl ConfigManager {
fun test_two_refs_string(&self, key: &str, default: &str) -> String {
return "test".to_string()
}
}
"#;
let temp_file = "/tmp/test_parser_087_02.ruchy";
std::fs::write(temp_file, code).expect("Failed to write test file");
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
.arg("check")
.arg(temp_file)
.assert()
.success()
.stdout(predicate::str::contains("Syntax is valid"));
std::fs::remove_file(temp_file).ok();
}
#[test]
fn test_parser_087_03_one_str_ref_string_return() {
let code = r#"
impl ConfigManager {
fun test_one_ref_string(&self, key: &str) -> String {
return "test".to_string()
}
}
"#;
let temp_file = "/tmp/test_parser_087_03.ruchy";
std::fs::write(temp_file, code).expect("Failed to write test file");
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
.arg("check")
.arg(temp_file)
.assert()
.success()
.stdout(predicate::str::contains("Syntax is valid"));
std::fs::remove_file(temp_file).ok();
}
#[test]
fn test_parser_087_04_three_str_refs_string_return() {
let code = r"
impl ConfigManager {
fun get_config(&self, section: &str, key: &str, default: &str) -> String {
return default.to_string()
}
}
";
let temp_file = "/tmp/test_parser_087_04.ruchy";
std::fs::write(temp_file, code).expect("Failed to write test file");
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
.arg("check")
.arg(temp_file)
.assert()
.success()
.stdout(predicate::str::contains("Syntax is valid"));
std::fs::remove_file(temp_file).ok();
}
#[test]
fn test_parser_087_05_mixed_types_with_str_refs() {
let code = r#"
impl ConfigManager {
fun complex_method(&self, name: &str, age: i32, city: &str) -> String {
return name.to_string() + " " + city
}
}
"#;
let temp_file = "/tmp/test_parser_087_05.ruchy";
std::fs::write(temp_file, code).expect("Failed to write test file");
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
.arg("check")
.arg(temp_file)
.assert()
.success()
.stdout(predicate::str::contains("Syntax is valid"));
std::fs::remove_file(temp_file).ok();
}
#[test]
fn test_parser_087_06_regular_function_multiple_str_refs() {
let code = r"
fun join_strings(left: &str, right: &str, separator: &str) -> String {
return left.to_string() + separator + right
}
";
let temp_file = "/tmp/test_parser_087_06.ruchy";
std::fs::write(temp_file, code).expect("Failed to write test file");
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
.arg("check")
.arg(temp_file)
.assert()
.success()
.stdout(predicate::str::contains("Syntax is valid"));
std::fs::remove_file(temp_file).ok();
}