depyler-core 3.23.0

Core transpilation engine for the Depyler Python-to-Rust transpiler
Documentation
// Generated by: DEPYLER stdlib validation Phase 1
// Module: random - Python random module validation
// Status: RED phase - Tests written first, implementation pending

use depyler_core::transpile_python_to_rust;

// DEPYLER-STDLIB-RANDOM-001: Basic random functions
#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_random() {
    let python = r#"
import random

def get_random() -> float:
    return random.random()
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    // Should generate rand::random() or thread_rng().gen()
    assert!(result.contains("rand::") || result.contains("random"));
}

#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_randint() {
    let python = r#"
import random

def get_random_int(a: int, b: int) -> int:
    return random.randint(a, b)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    // Should generate gen_range or similar
    assert!(result.contains("gen_range") || result.contains("rand"));
}

#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_uniform() {
    let python = r#"
import random

def get_uniform(a: float, b: float) -> float:
    return random.uniform(a, b)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("gen_range") || result.contains("rand"));
}

// DEPYLER-STDLIB-RANDOM-002: Sequence functions
#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_choice() {
    let python = r#"
import random

def pick_random(items: list[int]) -> int:
    return random.choice(items)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("choose") || result.contains("rand"));
}

#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_shuffle() {
    let python = r#"
import random

def shuffle_list(items: list[int]) -> None:
    random.shuffle(items)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("shuffle") || result.contains("rand"));
}

#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_sample() {
    let python = r#"
import random

def sample_items(items: list[int], k: int) -> list[int]:
    return random.sample(items, k)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("sample") || result.contains("choose_multiple"));
}

// DEPYLER-STDLIB-RANDOM-003: Distribution functions
#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_gauss() {
    let python = r#"
import random

def get_normal(mu: float, sigma: float) -> float:
    return random.gauss(mu, sigma)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("Normal") || result.contains("gauss"));
}

#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_expovariate() {
    let python = r#"
import random

def get_exponential(lambd: float) -> float:
    return random.expovariate(lambd)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("Exp") || result.contains("exponential"));
}

// DEPYLER-STDLIB-RANDOM-004: Seed and state
#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_seed() {
    let python = r#"
import random

def seed_rng(seed: int) -> None:
    random.seed(seed)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("seed") || result.contains("SeedableRng"));
}

// DEPYLER-STDLIB-RANDOM-005: Range functions
#[test]
#[ignore = "DEPYLER-STDLIB-RANDOM: Not implemented yet - RED phase"]
fn test_random_randrange() {
    let python = r#"
import random

def get_random_range(start: int, stop: int, step: int) -> int:
    return random.randrange(start, stop, step)
"#;

    let result = transpile_python_to_rust(python).expect("Transpilation failed");

    assert!(result.contains("gen_range") || result.contains("rand"));
}

// Total: 11 comprehensive tests for random module
// Coverage: Basic random, distributions, sequences, seed/state