mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-02 22:21:33 +00:00
webidl: emit methods for regular operations
This commit is contained in:
@ -8,34 +8,4 @@ extern crate wasm_bindgen_webidl as wb_webidl;
|
||||
mod util;
|
||||
use util::*;
|
||||
|
||||
/// Tests for parsing WebIDL into an expected wasm-bindgen AST.
|
||||
mod parse {
|
||||
use super::*;
|
||||
|
||||
assert_parse!(empty, backend::ast::Program::default());
|
||||
|
||||
assert_parse!(
|
||||
Event,
|
||||
backend::ast::Program {
|
||||
exports: vec![],
|
||||
imports: vec![backend::ast::Import {
|
||||
module: None,
|
||||
version: None,
|
||||
js_namespace: None,
|
||||
kind: backend::ast::ImportKind::Type(backend::ast::ImportType {
|
||||
vis: syn::Visibility::Public(syn::VisPublic {
|
||||
pub_token: Default::default(),
|
||||
}),
|
||||
name: syn::Ident::new("Event", proc_macro2::Span::call_site()),
|
||||
}),
|
||||
}],
|
||||
enums: vec![],
|
||||
structs: vec![],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// Tests for compiling WebIDL into Rust bindings.
|
||||
mod compile {
|
||||
assert_compile!(Event);
|
||||
}
|
||||
assert_compile!(Event);
|
||||
|
@ -1,31 +1,9 @@
|
||||
use backend;
|
||||
use diff;
|
||||
use std::io::{self, Write};
|
||||
use std::process;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
use wb_webidl;
|
||||
|
||||
pub fn assert_parse(webidl: &str, expected: backend::ast::Program) {
|
||||
let actual = wb_webidl::parse(webidl).expect("should parse the webidl source OK");
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
macro_rules! assert_parse {
|
||||
($test_name:ident, $expected_ast:expr) => {
|
||||
#[test]
|
||||
#[allow(non_snake_case)]
|
||||
fn $test_name() {
|
||||
let webidl_source = include_str!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/tests/fixtures/",
|
||||
stringify!($test_name),
|
||||
".webidl"
|
||||
));
|
||||
$crate::assert_parse(webidl_source, $expected_ast);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn rustfmt<S: Into<String>>(source: S) -> (String, String) {
|
||||
let source = source.into();
|
||||
|
||||
|
Reference in New Issue
Block a user