Reduce spelling warnings in codegen.
This commit is contained in:
parent
d2121e2183
commit
61d7356e08
@ -378,8 +378,8 @@ impl Parse for ExportedFn {
|
||||
}
|
||||
|
||||
// Check return type.
|
||||
if let syn::ReturnType::Type(_, ref rtype) = fn_all.sig.output {
|
||||
match flatten_type_groups(rtype.as_ref()) {
|
||||
if let syn::ReturnType::Type(_, ref ret_type) = fn_all.sig.output {
|
||||
match flatten_type_groups(ret_type.as_ref()) {
|
||||
syn::Type::Ptr(_) => {
|
||||
return Err(syn::Error::new(
|
||||
fn_all.sig.output.span(),
|
||||
@ -495,8 +495,8 @@ impl ExportedFn {
|
||||
}
|
||||
|
||||
pub(crate) fn return_type(&self) -> Option<&syn::Type> {
|
||||
if let syn::ReturnType::Type(_, ref rtype) = self.signature.output {
|
||||
Some(flatten_type_groups(rtype))
|
||||
if let syn::ReturnType::Type(_, ref ret_type) = self.signature.output {
|
||||
Some(flatten_type_groups(ret_type))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -616,8 +616,8 @@ impl ExportedFn {
|
||||
let arguments: Vec<syn::Ident> = dynamic_signature
|
||||
.inputs
|
||||
.iter()
|
||||
.filter_map(|fnarg| {
|
||||
if let syn::FnArg::Typed(syn::PatType { ref pat, .. }) = fnarg {
|
||||
.filter_map(|fn_arg| {
|
||||
if let syn::FnArg::Typed(syn::PatType { ref pat, .. }) = fn_arg {
|
||||
if let syn::Pat::Ident(ref ident) = pat.as_ref() {
|
||||
Some(ident.ident.clone())
|
||||
} else {
|
||||
@ -718,7 +718,7 @@ impl ExportedFn {
|
||||
let arg_count = self.arg_count();
|
||||
let is_method_call = self.mutable_receiver();
|
||||
|
||||
let mut unpack_stmts: Vec<syn::Stmt> = Vec::new();
|
||||
let mut unpack_statements: Vec<syn::Stmt> = Vec::new();
|
||||
let mut unpack_exprs: Vec<syn::Expr> = Vec::new();
|
||||
let mut input_type_names: Vec<String> = Vec::new();
|
||||
let mut input_type_exprs: Vec<syn::Expr> = Vec::new();
|
||||
@ -748,7 +748,7 @@ impl ExportedFn {
|
||||
};
|
||||
let downcast_span = quote_spanned!(
|
||||
arg_type.span()=> &mut args[0usize].write_lock::<#arg_type>().unwrap());
|
||||
unpack_stmts.push(
|
||||
unpack_statements.push(
|
||||
syn::parse2::<syn::Stmt>(quote! {
|
||||
let #var = #downcast_span;
|
||||
})
|
||||
@ -811,7 +811,7 @@ impl ExportedFn {
|
||||
}
|
||||
};
|
||||
|
||||
unpack_stmts.push(
|
||||
unpack_statements.push(
|
||||
syn::parse2::<syn::Stmt>(quote! {
|
||||
let #var = #downcast_span;
|
||||
})
|
||||
@ -847,8 +847,8 @@ impl ExportedFn {
|
||||
// that as needing to borrow the entire array, all of the previous argument unpacking via
|
||||
// clone needs to happen first.
|
||||
if is_method_call {
|
||||
let arg0 = unpack_stmts.remove(0);
|
||||
unpack_stmts.push(arg0);
|
||||
let arg0 = unpack_statements.remove(0);
|
||||
unpack_statements.push(arg0);
|
||||
}
|
||||
|
||||
// Handle "raw returns", aka cases where the result is a dynamic or an error.
|
||||
@ -881,7 +881,7 @@ impl ExportedFn {
|
||||
debug_assert_eq!(args.len(), #arg_count,
|
||||
"wrong arg count: {} != {}",
|
||||
args.len(), #arg_count);
|
||||
#(#unpack_stmts)*
|
||||
#(#unpack_statements)*
|
||||
#return_expr
|
||||
}
|
||||
|
||||
|
@ -293,12 +293,12 @@ pub fn combine_with_exported_module(args: proc_macro::TokenStream) -> proc_macro
|
||||
/// ```
|
||||
#[proc_macro]
|
||||
pub fn register_exported_fn(args: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let (engine_expr, export_name, rust_modpath) = match crate::register::parse_register_macro(args)
|
||||
{
|
||||
Ok(triple) => triple,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
let gen_mod_path = crate::register::generated_module_path(&rust_modpath);
|
||||
let (engine_expr, export_name, rust_mod_path) =
|
||||
match crate::register::parse_register_macro(args) {
|
||||
Ok(triple) => triple,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
let gen_mod_path = crate::register::generated_module_path(&rust_mod_path);
|
||||
let tokens = quote! {
|
||||
#engine_expr.register_result_fn(&(#export_name), #gen_mod_path::dynamic_result_fn);
|
||||
};
|
||||
@ -332,12 +332,12 @@ pub fn register_exported_fn(args: proc_macro::TokenStream) -> proc_macro::TokenS
|
||||
/// ```
|
||||
#[proc_macro]
|
||||
pub fn set_exported_fn(args: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let (module_expr, export_name, rust_modpath) = match crate::register::parse_register_macro(args)
|
||||
{
|
||||
Ok(triple) => triple,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
let gen_mod_path = crate::register::generated_module_path(&rust_modpath);
|
||||
let (module_expr, export_name, rust_mod_path) =
|
||||
match crate::register::parse_register_macro(args) {
|
||||
Ok(triple) => triple,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
let gen_mod_path = crate::register::generated_module_path(&rust_mod_path);
|
||||
let tokens = quote! {
|
||||
#module_expr.set_fn(#export_name, FnNamespace::Internal, FnAccess::Public,
|
||||
Some(#gen_mod_path::token_input_names().as_ref()),
|
||||
@ -374,12 +374,12 @@ pub fn set_exported_fn(args: proc_macro::TokenStream) -> proc_macro::TokenStream
|
||||
/// ```
|
||||
#[proc_macro]
|
||||
pub fn set_exported_global_fn(args: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let (module_expr, export_name, rust_modpath) = match crate::register::parse_register_macro(args)
|
||||
{
|
||||
Ok(triple) => triple,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
let gen_mod_path = crate::register::generated_module_path(&rust_modpath);
|
||||
let (module_expr, export_name, rust_mod_path) =
|
||||
match crate::register::parse_register_macro(args) {
|
||||
Ok(triple) => triple,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
let gen_mod_path = crate::register::generated_module_path(&rust_mod_path);
|
||||
let tokens = quote! {
|
||||
#module_expr.set_fn(#export_name, FnNamespace::Global, FnAccess::Public,
|
||||
Some(#gen_mod_path::token_input_names().as_ref()),
|
||||
|
@ -101,7 +101,7 @@ pub(crate) struct Module {
|
||||
mod_all: syn::ItemMod,
|
||||
fns: Vec<ExportedFn>,
|
||||
consts: Vec<ExportedConst>,
|
||||
submodules: Vec<Module>,
|
||||
sub_modules: Vec<Module>,
|
||||
params: ExportedModParams,
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ impl Parse for Module {
|
||||
let mut mod_all: syn::ItemMod = input.parse()?;
|
||||
let fns: Vec<_>;
|
||||
let mut consts: Vec<_> = new_vec![];
|
||||
let mut submodules: Vec<_> = Vec::new();
|
||||
let mut sub_modules: Vec<_> = Vec::new();
|
||||
if let Some((_, ref mut content)) = mod_all.content {
|
||||
// Gather and parse functions.
|
||||
fns = content
|
||||
@ -126,16 +126,16 @@ impl Parse for Module {
|
||||
syn::Item::Fn(f) => Some(f),
|
||||
_ => None,
|
||||
})
|
||||
.try_fold(Vec::new(), |mut vec, itemfn| {
|
||||
.try_fold(Vec::new(), |mut vec, item_fn| {
|
||||
// #[cfg] attributes are not allowed on functions
|
||||
crate::attrs::deny_cfg_attr(&itemfn.attrs)?;
|
||||
crate::attrs::deny_cfg_attr(&item_fn.attrs)?;
|
||||
|
||||
let params: ExportedFnParams =
|
||||
match crate::attrs::inner_item_attributes(&mut itemfn.attrs, "rhai_fn") {
|
||||
match crate::attrs::inner_item_attributes(&mut item_fn.attrs, "rhai_fn") {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
syn::parse2::<ExportedFn>(itemfn.to_token_stream())
|
||||
syn::parse2::<ExportedFn>(item_fn.to_token_stream())
|
||||
.and_then(|mut f| {
|
||||
f.set_params(params)?;
|
||||
Ok(f)
|
||||
@ -163,29 +163,31 @@ impl Parse for Module {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
// Gather and parse submodule definitions.
|
||||
// Gather and parse sub-module definitions.
|
||||
//
|
||||
// They are actually removed from the module's body, because they will need
|
||||
// re-generating later when generated code is added.
|
||||
submodules.reserve(content.len() - fns.len() - consts.len());
|
||||
sub_modules.reserve(content.len() - fns.len() - consts.len());
|
||||
let mut i = 0;
|
||||
while i < content.len() {
|
||||
if let syn::Item::Mod(_) = &content[i] {
|
||||
let mut itemmod = match content.remove(i) {
|
||||
let mut item_mod = match content.remove(i) {
|
||||
syn::Item::Mod(m) => m,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let params: ExportedModParams =
|
||||
match crate::attrs::inner_item_attributes(&mut itemmod.attrs, "rhai_mod") {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
let params: ExportedModParams = match crate::attrs::inner_item_attributes(
|
||||
&mut item_mod.attrs,
|
||||
"rhai_mod",
|
||||
) {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
let module =
|
||||
syn::parse2::<Module>(itemmod.to_token_stream()).and_then(|mut m| {
|
||||
syn::parse2::<Module>(item_mod.to_token_stream()).and_then(|mut m| {
|
||||
m.set_params(params)?;
|
||||
Ok(m)
|
||||
})?;
|
||||
submodules.push(module);
|
||||
sub_modules.push(module);
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
@ -197,7 +199,7 @@ impl Parse for Module {
|
||||
mod_all,
|
||||
fns,
|
||||
consts,
|
||||
submodules,
|
||||
sub_modules,
|
||||
params: ExportedModParams::default(),
|
||||
})
|
||||
}
|
||||
@ -251,7 +253,7 @@ impl Module {
|
||||
mut mod_all,
|
||||
mut fns,
|
||||
consts,
|
||||
mut submodules,
|
||||
mut sub_modules,
|
||||
params,
|
||||
..
|
||||
} = self;
|
||||
@ -266,13 +268,13 @@ impl Module {
|
||||
let mod_gen = crate::rhai_module::generate_body(
|
||||
&mut fns,
|
||||
&consts,
|
||||
&mut submodules,
|
||||
&mut sub_modules,
|
||||
¶ms.scope,
|
||||
);
|
||||
|
||||
// NB: submodules must have their new items for exporting generated in depth-first order
|
||||
// NB: sub-modules must have their new items for exporting generated in depth-first order
|
||||
// to avoid issues caused by re-parsing them
|
||||
let inner_modules: Vec<proc_macro2::TokenStream> = submodules.drain(..)
|
||||
let inner_modules: Vec<proc_macro2::TokenStream> = sub_modules.drain(..)
|
||||
.try_fold::<Vec<proc_macro2::TokenStream>, _,
|
||||
Result<Vec<proc_macro2::TokenStream>, syn::Error>>(
|
||||
Vec::new(), |mut acc, m| { acc.push(m.generate_inner()?); Ok(acc) })?;
|
||||
@ -309,8 +311,8 @@ impl Module {
|
||||
&self.fns
|
||||
}
|
||||
|
||||
pub fn submodules(&self) -> &[Module] {
|
||||
&self.submodules
|
||||
pub fn sub_modules(&self) -> &[Module] {
|
||||
&self.sub_modules
|
||||
}
|
||||
|
||||
pub fn content(&self) -> Option<&Vec<syn::Item>> {
|
||||
|
@ -33,11 +33,11 @@ pub fn parse_register_macro(
|
||||
));
|
||||
}
|
||||
let export_name = match &items[1] {
|
||||
syn::Expr::Lit(litstr) => quote_spanned!(items[1].span()=>
|
||||
#litstr.to_string()),
|
||||
syn::Expr::Lit(lit_str) => quote_spanned!(items[1].span()=>
|
||||
#lit_str.to_string()),
|
||||
expr => quote! { #expr },
|
||||
};
|
||||
let rust_modpath = if let syn::Expr::Path(ref path) = &items[2] {
|
||||
let rust_mod_path = if let syn::Expr::Path(ref path) = &items[2] {
|
||||
path.path.clone()
|
||||
} else {
|
||||
return Err(syn::Error::new(
|
||||
@ -46,5 +46,5 @@ pub fn parse_register_macro(
|
||||
));
|
||||
};
|
||||
let module = items.remove(0);
|
||||
Ok((module, export_name, rust_modpath))
|
||||
Ok((module, export_name, rust_mod_path))
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ pub(crate) type ExportedConst = (String, Box<syn::Type>, syn::Expr);
|
||||
pub(crate) fn generate_body(
|
||||
fns: &mut [ExportedFn],
|
||||
consts: &[ExportedConst],
|
||||
submodules: &mut [Module],
|
||||
sub_modules: &mut [Module],
|
||||
parent_scope: &ExportScope,
|
||||
) -> proc_macro2::TokenStream {
|
||||
let mut set_fn_stmts: Vec<syn::Stmt> = Vec::new();
|
||||
let mut set_const_stmts: Vec<syn::Stmt> = Vec::new();
|
||||
let mut set_fn_statements: Vec<syn::Stmt> = Vec::new();
|
||||
let mut set_const_statements: Vec<syn::Stmt> = Vec::new();
|
||||
let mut add_mod_blocks: Vec<syn::ExprBlock> = Vec::new();
|
||||
let mut set_flattened_mod_blocks: Vec<syn::ExprBlock> = Vec::new();
|
||||
let str_type_path = syn::parse2::<syn::Path>(quote! { str }).unwrap();
|
||||
@ -27,7 +27,7 @@ pub(crate) fn generate_body(
|
||||
for (const_name, _, _) in consts {
|
||||
let const_literal = syn::LitStr::new(&const_name, proc_macro2::Span::call_site());
|
||||
let const_ref = syn::Ident::new(&const_name, proc_macro2::Span::call_site());
|
||||
set_const_stmts.push(
|
||||
set_const_statements.push(
|
||||
syn::parse2::<syn::Stmt>(quote! {
|
||||
m.set_var(#const_literal, #const_ref);
|
||||
})
|
||||
@ -35,17 +35,17 @@ pub(crate) fn generate_body(
|
||||
);
|
||||
}
|
||||
|
||||
for itemmod in submodules {
|
||||
itemmod.update_scope(&parent_scope);
|
||||
if itemmod.skipped() {
|
||||
for item_mod in sub_modules {
|
||||
item_mod.update_scope(&parent_scope);
|
||||
if item_mod.skipped() {
|
||||
continue;
|
||||
}
|
||||
let module_name = itemmod.module_name();
|
||||
let module_name = item_mod.module_name();
|
||||
let exported_name: syn::LitStr = syn::LitStr::new(
|
||||
itemmod.exported_name().as_ref(),
|
||||
item_mod.exported_name().as_ref(),
|
||||
proc_macro2::Span::call_site(),
|
||||
);
|
||||
let cfg_attrs: Vec<&syn::Attribute> = itemmod
|
||||
let cfg_attrs: Vec<&syn::Attribute> = item_mod
|
||||
.attrs()
|
||||
.iter()
|
||||
.filter(|&a| a.path.get_ident().map(|i| *i == "cfg").unwrap_or(false))
|
||||
@ -83,7 +83,7 @@ pub(crate) fn generate_body(
|
||||
|
||||
let fn_input_names: Vec<String> = function
|
||||
.arg_list()
|
||||
.map(|fnarg| match fnarg {
|
||||
.map(|fn_arg| match fn_arg {
|
||||
syn::FnArg::Receiver(_) => panic!("internal error: receiver fn outside impl!?"),
|
||||
syn::FnArg::Typed(syn::PatType { pat, ty, .. }) => {
|
||||
format!("{}: {}", pat.to_token_stream(), print_type(ty))
|
||||
@ -93,7 +93,7 @@ pub(crate) fn generate_body(
|
||||
|
||||
let fn_input_types: Vec<syn::Expr> = function
|
||||
.arg_list()
|
||||
.map(|fnarg| match fnarg {
|
||||
.map(|fn_arg| match fn_arg {
|
||||
syn::FnArg::Receiver(_) => panic!("internal error: receiver fn outside impl!?"),
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => {
|
||||
let arg_type = match flatten_type_groups(ty.as_ref()) {
|
||||
@ -169,7 +169,7 @@ pub(crate) fn generate_body(
|
||||
},
|
||||
fn_literal.span(),
|
||||
);
|
||||
set_fn_stmts.push(
|
||||
set_fn_statements.push(
|
||||
syn::parse2::<syn::Stmt>(quote! {
|
||||
m.set_fn(#fn_literal, FnNamespace::#ns_str, FnAccess::Public,
|
||||
Some(&[#(#fn_input_names,)* #return_type]), &[#(#fn_input_types),*],
|
||||
@ -190,7 +190,7 @@ pub(crate) fn generate_body(
|
||||
gen_fn_tokens.push(function.generate_return_type(&fn_token_name.to_string()));
|
||||
}
|
||||
|
||||
let mut generate_fncall = syn::parse2::<syn::ItemMod>(quote! {
|
||||
let mut generate_fn_call = syn::parse2::<syn::ItemMod>(quote! {
|
||||
pub mod generate_info {
|
||||
#[allow(unused_imports)]
|
||||
use super::*;
|
||||
@ -203,8 +203,8 @@ pub(crate) fn generate_body(
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn rhai_generate_into_module(m: &mut Module, flatten: bool) {
|
||||
#(#set_fn_stmts)*
|
||||
#(#set_const_stmts)*
|
||||
#(#set_fn_statements)*
|
||||
#(#set_const_statements)*
|
||||
|
||||
if flatten {
|
||||
#(#set_flattened_mod_blocks)*
|
||||
@ -216,7 +216,7 @@ pub(crate) fn generate_body(
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let (_, generate_call_content) = generate_fncall.content.take().unwrap();
|
||||
let (_, generate_call_content) = generate_fn_call.content.take().unwrap();
|
||||
|
||||
quote! {
|
||||
#(#generate_call_content)*
|
||||
@ -225,39 +225,39 @@ pub(crate) fn generate_body(
|
||||
}
|
||||
|
||||
pub(crate) fn check_rename_collisions(fns: &Vec<ExportedFn>) -> Result<(), syn::Error> {
|
||||
fn make_key(name: impl ToString, itemfn: &ExportedFn) -> String {
|
||||
itemfn
|
||||
fn make_key(name: impl ToString, item_fn: &ExportedFn) -> String {
|
||||
item_fn
|
||||
.arg_list()
|
||||
.fold(name.to_string(), |mut argstr, fnarg| {
|
||||
let type_string: String = match fnarg {
|
||||
.fold(name.to_string(), |mut arg_str, fn_arg| {
|
||||
let type_string: String = match fn_arg {
|
||||
syn::FnArg::Receiver(_) => unimplemented!("receiver rhai_fns not implemented"),
|
||||
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => print_type(ty),
|
||||
};
|
||||
argstr.push('.');
|
||||
argstr.push_str(&type_string);
|
||||
argstr
|
||||
arg_str.push('.');
|
||||
arg_str.push_str(&type_string);
|
||||
arg_str
|
||||
})
|
||||
}
|
||||
|
||||
let mut renames = HashMap::<String, proc_macro2::Span>::new();
|
||||
let mut fn_defs = HashMap::<String, proc_macro2::Span>::new();
|
||||
|
||||
for itemfn in fns.iter() {
|
||||
if !itemfn.params().name.is_empty() || itemfn.params().special != FnSpecialAccess::None {
|
||||
let mut names: Vec<_> = itemfn
|
||||
for item_fn in fns.iter() {
|
||||
if !item_fn.params().name.is_empty() || item_fn.params().special != FnSpecialAccess::None {
|
||||
let mut names: Vec<_> = item_fn
|
||||
.params()
|
||||
.name
|
||||
.iter()
|
||||
.map(|n| (n.clone(), n.clone()))
|
||||
.collect();
|
||||
|
||||
if let Some((s, n, _)) = itemfn.params().special.get_fn_name() {
|
||||
if let Some((s, n, _)) = item_fn.params().special.get_fn_name() {
|
||||
names.push((s, n));
|
||||
}
|
||||
|
||||
for (name, fn_name) in names {
|
||||
let current_span = itemfn.params().span.unwrap();
|
||||
let key = make_key(&name, itemfn);
|
||||
let current_span = item_fn.params().span.unwrap();
|
||||
let key = make_key(&name, item_fn);
|
||||
if let Some(other_span) = renames.insert(key, current_span) {
|
||||
let mut err = syn::Error::new(
|
||||
current_span,
|
||||
@ -271,7 +271,7 @@ pub(crate) fn check_rename_collisions(fns: &Vec<ExportedFn>) -> Result<(), syn::
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let ident = itemfn.name();
|
||||
let ident = item_fn.name();
|
||||
if let Some(other_span) = fn_defs.insert(ident.to_string(), ident.span()) {
|
||||
let mut err = syn::Error::new(
|
||||
ident.span(),
|
||||
@ -283,7 +283,7 @@ pub(crate) fn check_rename_collisions(fns: &Vec<ExportedFn>) -> Result<(), syn::
|
||||
));
|
||||
return Err(err);
|
||||
}
|
||||
let key = make_key(ident, itemfn);
|
||||
let key = make_key(ident, item_fn);
|
||||
if let Some(fn_span) = renames.get(&key) {
|
||||
let mut err = syn::Error::new(
|
||||
ident.span(),
|
||||
|
@ -106,10 +106,10 @@ mod module_tests {
|
||||
let item_mod = syn::parse2::<Module>(input_tokens).unwrap();
|
||||
assert!(item_mod.fns().is_empty());
|
||||
assert!(item_mod.consts().is_empty());
|
||||
assert_eq!(item_mod.submodules().len(), 1);
|
||||
assert_eq!(&item_mod.submodules()[0].consts()[0].0, "MYSTIC_NUMBER");
|
||||
assert_eq!(item_mod.sub_modules().len(), 1);
|
||||
assert_eq!(&item_mod.sub_modules()[0].consts()[0].0, "MYSTIC_NUMBER");
|
||||
assert_eq!(
|
||||
item_mod.submodules()[0].consts()[0].2,
|
||||
item_mod.sub_modules()[0].consts()[0].2,
|
||||
syn::parse2::<syn::Expr>(quote! { 42 }).unwrap()
|
||||
);
|
||||
}
|
||||
@ -130,11 +130,11 @@ mod module_tests {
|
||||
let item_mod = syn::parse2::<Module>(input_tokens).unwrap();
|
||||
assert!(item_mod.fns().is_empty());
|
||||
assert!(item_mod.consts().is_empty());
|
||||
assert_eq!(item_mod.submodules().len(), 1);
|
||||
assert_eq!(item_mod.submodules()[0].fns().len(), 1);
|
||||
assert!(item_mod.submodules()[0].fns()[0].skipped());
|
||||
assert!(item_mod.submodules()[0].consts().is_empty());
|
||||
assert!(item_mod.submodules()[0].submodules().is_empty());
|
||||
assert_eq!(item_mod.sub_modules().len(), 1);
|
||||
assert_eq!(item_mod.sub_modules()[0].fns().len(), 1);
|
||||
assert!(item_mod.sub_modules()[0].fns()[0].skipped());
|
||||
assert!(item_mod.sub_modules()[0].consts().is_empty());
|
||||
assert!(item_mod.sub_modules()[0].sub_modules().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -153,8 +153,8 @@ mod module_tests {
|
||||
let item_mod = syn::parse2::<Module>(input_tokens).unwrap();
|
||||
assert!(item_mod.fns().is_empty());
|
||||
assert!(item_mod.consts().is_empty());
|
||||
assert_eq!(item_mod.submodules().len(), 1);
|
||||
assert!(item_mod.submodules()[0].skipped());
|
||||
assert_eq!(item_mod.sub_modules().len(), 1);
|
||||
assert!(item_mod.sub_modules()[0].skipped());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -958,7 +958,7 @@ mod generate_tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_skipped_submodule() {
|
||||
fn one_skipped_sub_module() {
|
||||
let input_tokens: TokenStream = quote! {
|
||||
pub mod one_fn {
|
||||
pub fn get_mystic_number() -> INT {
|
||||
|
@ -29,7 +29,7 @@ fn one_fn_module_nested_attr_test() -> Result<(), Box<EvalAltResult>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub mod one_fn_submodule_nested_attr {
|
||||
pub mod one_fn_sub_module_nested_attr {
|
||||
use rhai::plugin::*;
|
||||
|
||||
#[export_module]
|
||||
@ -47,9 +47,9 @@ pub mod one_fn_submodule_nested_attr {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_fn_submodule_nested_attr_test() -> Result<(), Box<EvalAltResult>> {
|
||||
fn one_fn_sub_module_nested_attr_test() -> Result<(), Box<EvalAltResult>> {
|
||||
let mut engine = Engine::new();
|
||||
let m = rhai::exported_module!(crate::one_fn_submodule_nested_attr::advanced_math);
|
||||
let m = rhai::exported_module!(crate::one_fn_sub_module_nested_attr::advanced_math);
|
||||
engine.register_static_module("Math::Advanced", m.into());
|
||||
|
||||
assert_eq!(
|
||||
|
Loading…
Reference in New Issue
Block a user