use depyler_core::transpile_python_to_rust;
#[test]
fn test_json_dumps() {
let python = r#"
import json
def serialize_data(data: dict) -> str:
return json.dumps(data)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("serde_json") || result.contains("to_string"));
}
#[test]
fn test_json_loads() {
let python = r#"
import json
def deserialize_data(s: str) -> dict:
return json.loads(s)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("serde_json") || result.contains("from_str"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-JSON: Not implemented yet - RED phase"]
fn test_json_dump() {
let python = r#"
import json
def write_json(data: dict, filename: str) -> None:
with open(filename, 'w') as f:
json.dump(data, f)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("serde_json") || result.contains("to_writer"));
}
#[test]
#[ignore = "DEPYLER-STDLIB-JSON: Not implemented yet - RED phase"]
fn test_json_load() {
let python = r#"
import json
def read_json(filename: str) -> dict:
with open(filename, 'r') as f:
return json.load(f)
"#;
let result = transpile_python_to_rust(python).expect("Transpilation failed");
assert!(result.contains("serde_json") || result.contains("from_reader"));
}