use depyler_core::transpile_python_to_rust;
#[test]
fn test_functools_reduce() {
let python = r#"
from functools import reduce
def sum_reduce(items: list) -> int:
return reduce(lambda x, y: x + y, items)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("fold") || result.contains("reduce"));
}
#[test]
fn test_itertools_chain() {
let python = r#"
from itertools import chain
def chain_lists(a: list, b: list) -> list:
return list(chain(a, b))
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("chain") || result.contains("extend"));
}
#[test]
fn test_itertools_cycle() {
let python = r#"
from itertools import cycle
def cycle_items(items: list, n: int) -> list:
cycler = cycle(items)
return [next(cycler) for _ in range(n)]
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("cycle") || result.contains("iter"));
}