summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2021-06-18 23:13:56 +0100
committerAlex Orlenko <zxteam@protonmail.com>2021-06-18 23:13:56 +0100
commitb84d1bd65f63413b1234bbe0f5309a1fe0e3c484 (patch)
tree51702ae16b39b24a85bf297c61fd3b7a753f7208 /tests
parent4e92ea341ba8fab62e5017948995c7bb9ab59aae (diff)
downloadmlua-b84d1bd65f63413b1234bbe0f5309a1fe0e3c484.zip
Update test names
Diffstat (limited to 'tests')
-rw-r--r--tests/byte_string.rs2
-rw-r--r--tests/hooks.rs12
-rw-r--r--tests/scope.rs18
-rw-r--r--tests/string.rs6
-rw-r--r--tests/tests.rs36
-rw-r--r--tests/thread.rs4
6 files changed, 38 insertions, 40 deletions
diff --git a/tests/byte_string.rs b/tests/byte_string.rs
index 3b05ee5..48be2d9 100644
--- a/tests/byte_string.rs
+++ b/tests/byte_string.rs
@@ -2,7 +2,7 @@ use bstr::{BStr, BString};
use mlua::{Lua, Result};
#[test]
-fn byte_string_round_trip() -> Result<()> {
+fn test_byte_string_round_trip() -> Result<()> {
let lua = Lua::new();
lua.load(
diff --git a/tests/hooks.rs b/tests/hooks.rs
index 6c4a3e4..378c134 100644
--- a/tests/hooks.rs
+++ b/tests/hooks.rs
@@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
use mlua::{Error, HookTriggers, Lua, Result, Value};
#[test]
-fn line_counts() -> Result<()> {
+fn test_line_counts() -> Result<()> {
let output = Arc::new(Mutex::new(Vec::new()));
let hook_output = output.clone();
@@ -43,7 +43,7 @@ fn line_counts() -> Result<()> {
}
#[test]
-fn function_calls() -> Result<()> {
+fn test_function_calls() -> Result<()> {
let output = Arc::new(Mutex::new(Vec::new()));
let hook_output = output.clone();
@@ -95,7 +95,7 @@ fn function_calls() -> Result<()> {
}
#[test]
-fn error_within_hook() -> Result<()> {
+fn test_error_within_hook() -> Result<()> {
let lua = Lua::new();
lua.set_hook(
HookTriggers {
@@ -126,7 +126,7 @@ fn error_within_hook() -> Result<()> {
}
#[test]
-fn limit_execution_instructions() -> Result<()> {
+fn test_limit_execution_instructions() -> Result<()> {
let lua = Lua::new();
let mut max_instructions = 10000;
@@ -165,7 +165,7 @@ fn limit_execution_instructions() -> Result<()> {
}
#[test]
-fn hook_removal() -> Result<()> {
+fn test_hook_removal() -> Result<()> {
let lua = Lua::new();
lua.set_hook(
@@ -188,7 +188,7 @@ fn hook_removal() -> Result<()> {
}
#[test]
-fn hook_swap_within_hook() -> Result<()> {
+fn test_hook_swap_within_hook() -> Result<()> {
thread_local! {
static TL_LUA: RefCell<Option<Lua>> = RefCell::new(None);
}
diff --git a/tests/scope.rs b/tests/scope.rs
index 1a726bc..9640383 100644
--- a/tests/scope.rs
+++ b/tests/scope.rs
@@ -8,7 +8,7 @@ use mlua::{
};
#[test]
-fn scope_func() -> Result<()> {
+fn test_scope_func() -> Result<()> {
let lua = Lua::new();
let rc = Rc::new(Cell::new(0));
@@ -38,7 +38,7 @@ fn scope_func() -> Result<()> {
}
#[test]
-fn scope_capture() -> Result<()> {
+fn test_scope_capture() -> Result<()> {
let lua = Lua::new();
let mut i = 0;
@@ -56,7 +56,7 @@ fn scope_capture() -> Result<()> {
}
#[test]
-fn scope_outer_lua_access() -> Result<()> {
+fn test_scope_outer_lua_access() -> Result<()> {
let lua = Lua::new();
let table = lua.create_table()?;
@@ -71,7 +71,7 @@ fn scope_outer_lua_access() -> Result<()> {
}
#[test]
-fn scope_userdata_fields() -> Result<()> {
+fn test_scope_userdata_fields() -> Result<()> {
struct MyUserData<'a>(&'a Cell<i64>);
impl<'a> UserData for MyUserData<'a> {
@@ -106,7 +106,7 @@ fn scope_userdata_fields() -> Result<()> {
}
#[test]
-fn scope_userdata_methods() -> Result<()> {
+fn test_scope_userdata_methods() -> Result<()> {
struct MyUserData<'a>(&'a Cell<i64>);
impl<'a> UserData for MyUserData<'a> {
@@ -147,7 +147,7 @@ fn scope_userdata_methods() -> Result<()> {
}
#[test]
-fn scope_userdata_functions() -> Result<()> {
+fn test_scope_userdata_functions() -> Result<()> {
struct MyUserData<'a>(&'a i64);
impl<'a> UserData for MyUserData<'a> {
@@ -189,7 +189,7 @@ fn scope_userdata_functions() -> Result<()> {
}
#[test]
-fn scope_userdata_mismatch() -> Result<()> {
+fn test_scope_userdata_mismatch() -> Result<()> {
struct MyUserData<'a>(&'a Cell<i64>);
impl<'a> UserData for MyUserData<'a> {
@@ -241,7 +241,7 @@ fn scope_userdata_mismatch() -> Result<()> {
}
#[test]
-fn scope_userdata_drop() -> Result<()> {
+fn test_scope_userdata_drop() -> Result<()> {
let lua = Lua::new();
struct MyUserData(Rc<()>);
@@ -299,7 +299,7 @@ fn scope_userdata_drop() -> Result<()> {
}
#[test]
-fn scope_nonstatic_userdata_drop() -> Result<()> {
+fn test_scope_nonstatic_userdata_drop() -> Result<()> {
let lua = Lua::new();
struct MyUserData<'a>(&'a Cell<i64>, Arc<()>);
diff --git a/tests/string.rs b/tests/string.rs
index 5a6f8ea..706fd44 100644
--- a/tests/string.rs
+++ b/tests/string.rs
@@ -3,7 +3,7 @@ use std::borrow::Cow;
use mlua::{Lua, Result, String};
#[test]
-fn compare() {
+fn test_string_compare() {
fn with_str<F: FnOnce(String)>(s: &str, f: F) {
f(Lua::new().create_string(s).unwrap());
}
@@ -21,7 +21,7 @@ fn compare() {
}
#[test]
-fn string_views() -> Result<()> {
+fn test_string_views() -> Result<()> {
let lua = Lua::new();
lua.load(
@@ -59,7 +59,7 @@ fn string_views() -> Result<()> {
}
#[test]
-fn raw_string() -> Result<()> {
+fn test_raw_string() -> Result<()> {
let lua = Lua::new();
let rs = lua.create_string(&[0, 1, 2, 3, 0, 1, 2, 3])?;
diff --git a/tests/tests.rs b/tests/tests.rs
index 6a786ee..ea224e7 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -83,6 +83,7 @@ fn test_safety() -> Result<()> {
#[test]
fn test_load() -> Result<()> {
let lua = Lua::new();
+
let func = lua.load("return 1+2").into_function()?;
let result: i32 = func.call(())?;
assert_eq!(result, 3);
@@ -395,7 +396,7 @@ fn test_panic() -> Result<()> {
Ok(lua)
}
- // Test triggerting Lua error passing Rust panic (must be resumed)
+ // Test triggering Lua error with sending Rust panic (must be resumed)
{
let lua = make_lua(LuaOptions::default())?;
@@ -451,7 +452,7 @@ fn test_panic() -> Result<()> {
}
}
- // Test representing rust panic as a string
+ // Test representing Rust panic as a string
match catch_unwind(|| -> Result<()> {
let lua = make_lua(LuaOptions::default())?;
lua.load(
@@ -486,7 +487,7 @@ fn test_panic() -> Result<()> {
Err(p) => assert!(*p.downcast::<StdString>().unwrap() == "rust panic from lua"),
}
- // Test enabling `catch_rust_panics` option / xpcall correctness
+ // Test disabling `catch_rust_panics` option / xpcall correctness
match catch_unwind(|| -> Result<()> {
let lua = make_lua(LuaOptions::new().catch_rust_panics(false))?;
lua.load(
@@ -612,7 +613,7 @@ fn test_pcall_xpcall() -> Result<()> {
assert!(lua.load("xpcall()").exec().is_err());
assert!(lua.load("xpcall(function() end)").exec().is_err());
- // Lua 5.3/5.2 / LuaJIT compatible version of xpcall
+ // Lua >= 5.2 compatible version of xpcall for 5.1
#[cfg(feature = "lua51")]
lua.load(
r#"
@@ -846,7 +847,7 @@ fn test_mismatched_registry_key() -> Result<()> {
}
#[test]
-fn too_many_returns() -> Result<()> {
+fn test_too_many_returns() -> Result<()> {
let lua = Lua::new();
let f = lua.create_function(|_, ()| Ok(Variadic::from_iter(1..1000000)))?;
assert!(f.call::<_, Vec<u32>>(()).is_err());
@@ -854,7 +855,7 @@ fn too_many_returns() -> Result<()> {
}
#[test]
-fn too_many_arguments() -> Result<()> {
+fn test_too_many_arguments() -> Result<()> {
let lua = Lua::new();
lua.load("function test(...) end").exec()?;
let args = Variadic::from_iter(1..1000000);
@@ -868,23 +869,20 @@ fn too_many_arguments() -> Result<()> {
#[test]
#[cfg(not(feature = "luajit"))]
-fn too_many_recursions() -> Result<()> {
+fn test_too_many_recursions() -> Result<()> {
let lua = Lua::new();
+
let f = lua
.create_function(move |lua, ()| lua.globals().get::<_, Function>("f")?.call::<_, ()>(()))?;
- lua.globals().set("f", f)?;
- assert!(lua
- .globals()
- .get::<_, Function>("f")?
- .call::<_, ()>(())
- .is_err());
+ lua.globals().set("f", f.clone())?;
+ assert!(f.call::<_, ()>(()).is_err());
Ok(())
}
#[test]
-fn too_many_binds() -> Result<()> {
+fn test_too_many_binds() -> Result<()> {
let lua = Lua::new();
let globals = lua.globals();
lua.load(
@@ -923,7 +921,7 @@ fn test_ref_stack_exhaustion() {
}
#[test]
-fn large_args() -> Result<()> {
+fn test_large_args() -> Result<()> {
let lua = Lua::new();
let globals = lua.globals();
@@ -958,7 +956,7 @@ fn large_args() -> Result<()> {
}
#[test]
-fn large_args_ref() -> Result<()> {
+fn test_large_args_ref() -> Result<()> {
let lua = Lua::new();
let f = lua.create_function(|_, args: Variadic<String>| {
@@ -974,7 +972,7 @@ fn large_args_ref() -> Result<()> {
}
#[test]
-fn chunk_env() -> Result<()> {
+fn test_chunk_env() -> Result<()> {
let lua = Lua::new();
let assert: Function = lua.globals().get("assert")?;
@@ -1016,7 +1014,7 @@ fn chunk_env() -> Result<()> {
}
#[test]
-fn context_thread() -> Result<()> {
+fn test_context_thread() -> Result<()> {
let lua = Lua::new();
let f = lua
@@ -1039,7 +1037,7 @@ fn context_thread() -> Result<()> {
#[test]
#[cfg(any(feature = "lua51", feature = "luajit"))]
-fn context_thread_51() -> Result<()> {
+fn test_context_thread_51() -> Result<()> {
let lua = Lua::new();
let thread = lua.create_thread(
diff --git a/tests/thread.rs b/tests/thread.rs
index 995b65f..f2c12b6 100644
--- a/tests/thread.rs
+++ b/tests/thread.rs
@@ -137,7 +137,7 @@ fn test_thread_reset() -> Result<()> {
}
#[test]
-fn coroutine_from_closure() -> Result<()> {
+fn test_coroutine_from_closure() -> Result<()> {
let lua = Lua::new();
let thrd_main = lua.create_function(|_, ()| Ok(()))?;
@@ -161,7 +161,7 @@ fn coroutine_from_closure() -> Result<()> {
}
#[test]
-fn coroutine_panic() {
+fn test_coroutine_panic() {
match catch_unwind(|| -> Result<()> {
// check that coroutines propagate panics correctly
let lua = Lua::new();