#![allow(missing_docs)]
use assert_cmd::Command;
use std::fs;
use tempfile::TempDir;
fn ruchy_cmd() -> Command {
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
}
#[test]
fn test_dict_literal_in_function_call() {
let temp_dir = TempDir::new().unwrap();
let script = temp_dir.path().join("test.ruchy");
let code = r#"
fun main() {
let items = [];
items.append({ name: "test", value: 42 });
println!("Done");
}
main()
"#;
fs::write(&script, code).unwrap();
ruchy_cmd().arg("transpile").arg(&script).assert().success();
}
#[test]
fn test_transactions_append_pattern() {
let temp_dir = TempDir::new().unwrap();
let script = temp_dir.path().join("test.ruchy");
let code = r#"
fun main() {
let transactions = [];
let amount = 100.0;
transactions.append({
type: "deposit",
amount: amount,
timestamp: 12345
});
println!("Transaction added");
}
main()
"#;
fs::write(&script, code).unwrap();
ruchy_cmd().arg("transpile").arg(&script).assert().success();
}
#[test]
fn test_multiple_dict_literals_in_calls() {
let temp_dir = TempDir::new().unwrap();
let script = temp_dir.path().join("test.ruchy");
let code = r#"
fun main() {
let list = [];
list.append({ id: 1, name: "first" });
list.append({ id: 2, name: "second" });
println!("Done");
}
main()
"#;
fs::write(&script, code).unwrap();
ruchy_cmd().arg("transpile").arg(&script).assert().success();
}
#[test]
fn test_dict_literal_with_expressions() {
let temp_dir = TempDir::new().unwrap();
let script = temp_dir.path().join("test.ruchy");
let code = r#"
fun process(data) {
println!("Processing");
}
fun main() {
let x = 5;
let y = 10;
process({ sum: x + y, product: x * y });
println!("Done");
}
main()
"#;
fs::write(&script, code).unwrap();
ruchy_cmd().arg("transpile").arg(&script).assert().success();
}