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 = "analyzer_tests",
))]

use std::process::Command;
use std::fs;

use crate::test_utils::cargo_check_generated;

fn setup_wj_build_and_build_dir(wj_code: &str) -> (tempfile::TempDir, std::path::PathBuf) {
    let test_root = tempfile::tempdir().expect("tempdir");
    let test_dir = test_root.path();
    let wj_file = test_dir.join("test.wj");
    fs::write(&wj_file, wj_code).expect("write test.wj");

    let output = Command::new(env!("CARGO_BIN_EXE_wj"))
        .args(["build", "--no-cargo", wj_file.to_str().unwrap()])
        .current_dir(test_dir)
        .output()
        .expect("Failed to run wj build");

    assert!(
        output.status.success(),
        "wj build failed:\n{}",
        String::from_utf8_lossy(&output.stderr)
    );

    let build_dir = test_dir.join("build");
    (test_root, build_dir)
}

#[test]
fn test_explicit_deref_both_borrowed() {
    // Case 1: *id == flag_id where BOTH are &String
    // Expected: Remove * → id == flag_id (both &String)
    let wj_code = r#"
pub fn check_flag(flag_id: string) -> bool {
    let flags: Vec<(string, bool)> = Vec::new()
    for (id, value) in &flags {
        if *id == flag_id {
            return *value
        }
    }
    false
}

pub fn main() {
    let test_flag = "test".to_string()
    let result = check_flag(test_flag)
}
"#;

    run_test(wj_code, "both_borrowed");
}

#[test]
fn test_explicit_deref_one_owned() {
    // Case 2: *id == flag_id where id is owned String, flag_id is borrowed &String
    // Expected: Add * to flag_id → *id == *flag_id (both String after deref)
    let wj_code = r#"
pub fn get_custom_flag(flag_id: string) -> bool {
    let custom_flags: Vec<(string, bool)> = Vec::new()
    for (id, value) in custom_flags {
        if *id == flag_id {
            return value
        }
    }
    false
}

pub fn main() {
    let test_flag = "test".to_string()
    let result = get_custom_flag(test_flag)
}
"#;

    run_test(wj_code, "one_owned");
}

fn run_test(wj_code: &str, _test_name: &str) {
    let (_root, build_dir) = setup_wj_build_and_build_dir(wj_code);
    cargo_check_generated(&build_dir);
}