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
// Conformance Test: HashMap Operations
//
// SEMANTIC CONTRACT:
// - HashMap stores key-value pairs
// - insert() adds or updates a key-value pair
// - get() returns Option<&V> for a key
// - contains_key() checks if a key exists
// - remove() removes a key-value pair
// - len() returns the number of pairs
// - is_empty() checks for zero length
//
// EXPECTED OUTPUT:
// [map_create] empty len=0
// [map_insert] after inserts: len=3
// [map_get] alice -> 30
// [map_get] bob -> 25
// [map_get] unknown -> not found
// [map_contains] has alice: true
// [map_contains] has dave: false
// [map_remove] before remove: len=3
// [map_remove] after remove bob: len=2
// [map_remove] bob still exists: false
// [map_update] charlie age before: 35
// [map_update] charlie age after: 36
// [map_empty] is_empty before: true
// [map_empty] is_empty after: false
// [map_all] PASSED

use std::collections::HashMap

// --- Creation and insertion ---
fn test_map_create() {
    let map: HashMap<string, int> = HashMap::new()
    println("[map_create] empty len=${map.len()}")
}

fn test_map_insert() {
    let mut map = HashMap::new()
    map.insert("alice", 30)
    map.insert("bob", 25)
    map.insert("charlie", 35)
    println("[map_insert] after inserts: len=${map.len()}")
}

// --- Get ---
fn test_map_get() {
    let mut map = HashMap::new()
    map.insert("alice", 30)
    map.insert("bob", 25)

    match map.get("alice") {
        Some(age) => println("[map_get] alice -> ${age}"),
        None => println("[map_get] alice -> not found"),
    }
    match map.get("bob") {
        Some(age) => println("[map_get] bob -> ${age}"),
        None => println("[map_get] bob -> not found"),
    }
    match map.get("unknown") {
        Some(age) => println("[map_get] unknown -> ${age}"),
        None => println("[map_get] unknown -> not found"),
    }
}

// --- Contains key ---
fn test_map_contains() {
    let mut map = HashMap::new()
    map.insert("alice", 30)
    println("[map_contains] has alice: ${map.contains_key("alice")}")
    println("[map_contains] has dave: ${map.contains_key("dave")}")
}

// --- Remove ---
fn test_map_remove() {
    let mut map = HashMap::new()
    map.insert("alice", 30)
    map.insert("bob", 25)
    map.insert("charlie", 35)
    println("[map_remove] before remove: len=${map.len()}")
    map.remove("bob")
    println("[map_remove] after remove bob: len=${map.len()}")
    println("[map_remove] bob still exists: ${map.contains_key("bob")}")
}

// --- Update ---
fn test_map_update() {
    let mut map = HashMap::new()
    map.insert("charlie", 35)
    match map.get("charlie") {
        Some(age) => println("[map_update] charlie age before: ${age}"),
        None => println("[map_update] charlie not found"),
    }
    map.insert("charlie", 36)  // Overwrite
    match map.get("charlie") {
        Some(age) => println("[map_update] charlie age after: ${age}"),
        None => println("[map_update] charlie not found"),
    }
}

// --- Empty check ---
fn test_map_empty() {
    let mut map: HashMap<string, int> = HashMap::new()
    println("[map_empty] is_empty before: ${map.is_empty()}")
    map.insert("key", 1)
    println("[map_empty] is_empty after: ${map.is_empty()}")
}

fn main() {
    test_map_create()
    test_map_insert()
    test_map_get()
    test_map_contains()
    test_map_remove()
    test_map_update()
    test_map_empty()
    println("[map_all] PASSED")
}