windjammer 0.48.0

A simple language inspired by Go, Ruby, and Elixir that transpiles to Rust - 80% of Rust's power with 20% of the complexity
Documentation
#![cfg(any(
    not(any(
        feature = "parser_tests",
        feature = "analyzer_tests",
        feature = "codegen_tests",
        feature = "interpreter_tests",
        feature = "conformance_tests",
        feature = "integration_tests",
    )),
    feature = "integration_tests",
))]

// Integration test: std::ops imports should map to Rust std::ops, not windjammer_runtime

use std::path::PathBuf;
use std::process::Command;

use tempfile::tempdir;

#[test]
#[cfg_attr(tarpaulin, ignore)]
fn test_std_ops_imports_map_to_rust_stdlib() {
    let wj_file = PathBuf::from("tests/std_ops_import_test.wj");
    let output_dir = PathBuf::from("./build/tests/std_ops_test");

    // Clean output directory
    if output_dir.exists() {
        std::fs::remove_dir_all(&output_dir).ok();
    }
    std::fs::create_dir_all(&output_dir).expect("Failed to create output directory");

    // Get compiler path - use the test-built binary
    let wj_compiler = PathBuf::from(env!("CARGO_BIN_EXE_wj"));

    // Compile the test file
    let output = Command::new(&wj_compiler)
        .arg("build")
        .arg(&wj_file)
        .arg("--output")
        .arg(&output_dir)
        .arg("--target")
        .arg("rust")
        .arg("--no-cargo")
        .output()
        .expect("Failed to execute wj compiler");

    // Check compilation succeeded
    if !output.status.success() {
        let stdout = String::from_utf8_lossy(&output.stdout);
        let stderr = String::from_utf8_lossy(&output.stderr);
        panic!(
            "Compilation failed:\nSTDOUT: {}\nSTDERR: {}",
            stdout, stderr
        );
    }

    // Read the generated Rust file
    let generated_file = output_dir.join("std_ops_import_test.rs");
    let generated_code =
        std::fs::read_to_string(&generated_file).expect("Failed to read generated Rust file");

    // CRITICAL ASSERTIONS:
    // 1. Must contain "use std::ops::Add;"
    assert!(
        generated_code.contains("use std::ops::Add;"),
        "Generated code should contain 'use std::ops::Add;'\nGenerated code:\n{}",
        generated_code
    );

    // 2. Must contain "use std::ops::Sub;"
    assert!(
        generated_code.contains("use std::ops::Sub;"),
        "Generated code should contain 'use std::ops::Sub;'"
    );

    // 3. Must contain "use std::ops::Mul;"
    assert!(
        generated_code.contains("use std::ops::Mul;"),
        "Generated code should contain 'use std::ops::Mul;'"
    );

    // 4. Must contain "use std::ops::Div;"
    assert!(
        generated_code.contains("use std::ops::Div;"),
        "Generated code should contain 'use std::ops::Div;'"
    );

    // 5. Must NOT contain "windjammer_runtime::ops"
    assert!(
        !generated_code.contains("windjammer_runtime::ops"),
        "Generated code should NOT contain 'windjammer_runtime::ops'\nGenerated code:\n{}",
        generated_code
    );

    // Verify the generated Rust code compiles with rustc (artifacts only in temp dir)
    let rustc_tmp = tempdir().expect("tempdir");
    let rustc_output = Command::new("rustc")
        .arg("--crate-type")
        .arg("bin")
        .arg(&generated_file)
        .arg("--out-dir")
        .arg(rustc_tmp.path())
        .output()
        .expect("Failed to run rustc");

    if !rustc_output.status.success() {
        let stderr = String::from_utf8_lossy(&rustc_output.stderr);
        panic!("Generated Rust code failed to compile:\n{}", stderr);
    }

    // Clean up
    std::fs::remove_dir_all(&output_dir).ok();
}