use typescript_webidl::{convert_to_typescript, parse};
#[test]
fn debug_parse_interface() {
let idl = r#"
interface TestInterface {
attribute string name;
attribute long age;
void doSomething();
string getName();
}
"#;
let result = parse(idl);
assert!(result.is_ok(), "解析接口应该成功");
if let Ok(root) = result {
println!("解析结果: {:?}", root);
let typescript = convert_to_typescript(&root);
println!("转换结果: {}", typescript);
}
}
#[test]
fn debug_parse_interface_with_modifiers() {
let idl = r#"
interface TestInterface {
readonly attribute string name;
static void staticMethod();
string getValue();
}
"#;
let result = parse(idl);
assert!(result.is_ok(), "解析接口应该成功");
if let Ok(root) = result {
println!("解析结果: {:?}", root);
let typescript = convert_to_typescript(&root);
println!("转换结果: {}", typescript);
}
}
#[test]
fn debug_parse_typedef() {
let idl = r#"
typedef string UTF8String;
typedef long long Int64;
interface TestInterface {
attribute UTF8String name;
Int64 getValue();
}
"#;
let result = parse(idl);
assert!(result.is_ok(), "解析类型别名应该成功");
if let Ok(root) = result {
println!("解析结果: {:?}", root);
let typescript = convert_to_typescript(&root);
println!("转换结果: {}", typescript);
}
}