// use prometeu_bytecode::disasm::disasm; // use prometeu_bytecode::BytecodeLoader; // use prometeu_compiler::compiler::compile; // use prometeu_compiler::frontends::pbs::parser::Parser; // use prometeu_compiler::common::spans::FileId; // use prometeu_analysis::NameInterner; // use std::fs; // use std::path::Path; // // #[test] // fn generate_canonical_goldens() { // println!("CWD: {:?}", std::env::current_dir().unwrap()); // let project_dir = Path::new("../../test-cartridges/canonical"); // if !project_dir.exists() { // // Fallback for when running from project root (some IDEs/environments) // let project_dir = Path::new("../../../../test-cartridges/canonical"); // if !project_dir.exists() { // panic!("Could not find project directory at ../../test-cartridges/canonical or test-cartridges/canonical"); // } // } // // // We need a stable path for the actual compilation which might use relative paths internally // let project_dir = if Path::new("../../test-cartridges/canonical").exists() { // Path::new("../../test-cartridges/canonical") // } else { // Path::new("../../../../test-cartridges/canonical") // }; // // let unit = compile(project_dir).map_err(|e| { // println!("Compilation Error: {}", e); // e // }).expect("Failed to compile canonical cartridge"); // // let golden_dir = project_dir.join("golden"); // fs::create_dir_all(&golden_dir).unwrap(); // // // 1. Bytecode (.pbc) // fs::write(golden_dir.join("program.pbc"), &unit.rom).unwrap(); // // // 2. Disassembly // let module = BytecodeLoader::load(&unit.rom).expect("Failed to load BytecodeModule"); // let instrs = disasm(&module.code).expect("Failed to disassemble"); // let mut disasm_text = String::new(); // for instr in instrs { // let operands_str = instr.operands.iter() // .map(|o| format!("{:?}", o)) // .collect::>() // .join(" "); // let line = if operands_str.is_empty() { // format!("{:04X} {:?}\n", instr.pc, instr.opcode) // } else { // format!("{:04X} {:?} {}\n", instr.pc, instr.opcode, operands_str.trim()) // }; // disasm_text.push_str(&line); // } // fs::write(golden_dir.join("program.disasm.txt"), disasm_text).unwrap(); // // // 3. AST JSON // let source = fs::read_to_string(project_dir.join("src/main/modules/main.pbs")).unwrap(); // let mut interner = NameInterner::new(); // let mut parser = Parser::new(&source, FileId(0), &mut interner); // let parsed = parser.parse_file().expect("Failed to parse AST"); // let ast_json = serde_json::to_string_pretty(parsed.arena.kind(parsed.root)).unwrap(); // fs::write(golden_dir.join("ast.json"), ast_json).unwrap(); // // println!("Golden artifacts generated in test-cartridges/canonical/golden/"); // }