depyler-core 3.22.0

Core transpilation engine for the Depyler Python-to-Rust transpiler
Documentation
// Generated by: DEPYLER stdlib validation Phase 1
// Module: random - Additional random functions (batch 2)
// Status: GREEN phase - Tests enabled

use depyler_core::transpile_python_to_rust;

// Note: randint, choice, choices, expovariate were already implemented
// This commit adds 1 NEW function: randbytes

// DEPYLER-STDLIB-RANDOM-MORE-001: Random bytes
#[test]
fn test_randbytes() {
    let python = r#"
import random

def get_random_bytes(n: int) -> bytes:
    return random.randbytes(n)
"#;

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

    // Should generate random bytes
    assert!(result.contains("gen") && result.contains("u8"));
}

// DEPYLER-STDLIB-RANDOM-MORE-002: Random integer (already implemented)
#[test]
fn test_randint() {
    let python = r#"
import random

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

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

    // Should generate random integer in range
    assert!(result.contains("gen_range"));
}

// DEPYLER-STDLIB-RANDOM-MORE-003: Random choice (already implemented)
#[test]
fn test_choice() {
    let python = r#"
import random

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

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

    // Should pick random element
    assert!(result.contains("choose"));
}

// DEPYLER-STDLIB-RANDOM-MORE-004: Random choices (already implemented)
#[test]
fn test_choices() {
    let python = r#"
import random

def pick_many(items: list, k: int) -> list:
    return random.choices(items, k=k)
"#;

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

    // Should pick k random elements with replacement
    assert!(result.contains("map") || result.contains("choose"));
}

// DEPYLER-STDLIB-RANDOM-MORE-005: Exponential distribution (already implemented)
#[test]
fn test_expovariate() {
    let python = r#"
import random

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

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

    // Should generate exponential distribution
    assert!(result.contains("Exp"));
}

// Total: 1 NEW random function (randint, choice, choices, expovariate already existed)
// Coverage: randbytes()