use gaia_assembler::{assembler::GaiaAssembler, program::{GaiaBlock, GaiaFunction, GaiaModule, GaiaTerminator}, types::{GaiaSignature, GaiaType}};
use gaia_types::helpers::{AbiCompatible, ApiCompatible, Architecture, CompilationTarget};
#[test]
#[cfg(feature = "clr-assembler")]
fn test_fsharp_integration() {
let program = GaiaModule {
name: "fsharp_test".to_string(),
functions: vec![GaiaFunction {
name: "main".to_string(),
signature: GaiaSignature {
params: vec![],
return_type: GaiaType::Void,
},
blocks: vec![GaiaBlock {
label: "entry".to_string(),
instructions: vec![],
terminator: GaiaTerminator::Return,
}],
is_external: false,
}],
structs: vec![],
classes: vec![],
constants: vec![],
globals: vec![],
imports: vec![],
};
let mut assembler = GaiaAssembler::new();
let target = CompilationTarget {
build: Architecture::CLR,
host: AbiCompatible::MicrosoftIntermediateLanguage,
target: ApiCompatible::ClrRuntime(4),
};
let result = assembler.compile(&program, &target);
assert!(result.is_ok(), "Failed to compile Gaia module");
let generated_files = result.unwrap();
assert!(generated_files.files.contains_key("main.il"), "Expected main.il file");
let il_content = String::from_utf8(generated_files.files["main.il"].clone()).unwrap();
println!("Generated MSIL code:");
println!("{}", il_content);
assert!(il_content.contains(".assembly fsharp_test"));
assert!(il_content.contains(".class public auto ansi beforefieldinit fsharp_test"));
assert!(il_content.contains(".method public hidebysig static void main() cil managed"));
assert!(il_content.contains("ret"));
println!("F# integration test passed!");
}