Move integration tests into top-level tests directory

other minor refactors
This commit is contained in:
kyren 2018-09-16 20:15:51 -04:00
parent 4a587ca1c5
commit b8da08187d
21 changed files with 45 additions and 38 deletions

View File

@ -5,7 +5,7 @@ use std::iter::FromIterator;
use rlua::{Function, Lua, MetaMethod, Result, UserData, UserDataMethods, Variadic};
fn guided_tour() -> Result<()> {
fn main() -> Result<()> {
// Create a Lua context with `Lua::new()`. Eventually, this will allow further control on the
// lua std library, and will specifically allow limiting Lua to a subset of "safe"
// functionality.
@ -179,7 +179,3 @@ fn guided_tour() -> Result<()> {
Ok(())
}
fn main() {
guided_tour().unwrap();
}

View File

@ -1,4 +1,5 @@
use std::fmt;
use std::result::Result as StdResult;
use std::sync::Arc;
use failure;
@ -121,7 +122,7 @@ pub enum Error {
}
/// A specialized `Result` type used by `rlua`'s API.
pub type Result<T> = ::std::result::Result<T, Error>;
pub type Result<T> = StdResult<T, Error>;
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
@ -221,7 +222,7 @@ pub trait ExternalResult<T> {
fn to_lua_err(self) -> Result<T>;
}
impl<T, E> ExternalResult<T> for ::std::result::Result<T, E>
impl<T, E> ExternalResult<T> for StdResult<T, E>
where
E: ExternalError,
{

View File

@ -40,7 +40,6 @@
// warnings at all.
#![doc(test(attr(deny(warnings))))]
#[cfg_attr(test, macro_use)]
extern crate failure;
extern crate libc;
@ -61,9 +60,6 @@ mod userdata;
mod util;
mod value;
#[cfg(test)]
mod tests;
pub use error::{Error, ExternalError, ExternalResult, Result};
pub use function::Function;
pub use lua::Lua;

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{Function, Lua, Result};
fn main() {
let lua = Lua::new();

View File

@ -2,7 +2,7 @@ extern crate rlua;
use std::panic::catch_unwind;
use rlua::*;
use rlua::Lua;
fn main() {
let lua = Lua::new();

View File

@ -2,7 +2,7 @@ extern crate rlua;
use std::panic::catch_unwind;
use rlua::*;
use rlua::Lua;
fn main() {
let lua = Lua::new();

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{Lua, Table};
fn main() {
struct Test {

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{Lua, Table};
fn main() {
struct Test {

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{Lua, Table};
fn main() {
struct Test {

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{Function, Lua};
fn main() {
struct Test {

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::Lua;
fn main() {
struct Test {

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{Lua, UserData};
fn main() {
let lua = Lua::new();

View File

@ -1,6 +1,6 @@
extern crate rlua;
use rlua::*;
use rlua::{AnyUserData, Lua, Table, UserData};
fn main() {
let lua = Lua::new();

View File

@ -1,4 +1,6 @@
use {Function, Lua, String};
extern crate rlua;
use rlua::{Function, Lua, String};
#[test]
fn test_function() {

View File

@ -1,7 +1,9 @@
extern crate rlua;
use std::cell::Cell;
use std::rc::Rc;
use {Error, Function, Lua, MetaMethod, String, UserData, UserDataMethods};
use rlua::{Error, Function, Lua, MetaMethod, String, UserData, UserDataMethods};
#[test]
fn scope_func() {

View File

@ -1,6 +1,8 @@
extern crate rlua;
use std::borrow::Cow;
use {Lua, String};
use rlua::{Lua, String};
fn with_str<F>(s: &str, f: F)
where

View File

@ -1,4 +1,6 @@
use {Lua, Nil, Result, Table, Value};
extern crate rlua;
use rlua::{Lua, Nil, Result, Table, Value};
#[test]
fn test_set_get() {

View File

@ -1,17 +1,15 @@
mod function;
mod scope;
mod string;
mod table;
mod thread;
mod types;
mod userdata;
extern crate failure;
extern crate rlua;
use std::iter::FromIterator;
use std::panic::catch_unwind;
use std::sync::Arc;
use std::{error, fmt};
use {Error, ExternalError, Function, Lua, Nil, Result, String, Table, UserData, Value, Variadic};
use failure::err_msg;
use rlua::{
Error, ExternalError, Function, Lua, Nil, Result, String, Table, UserData, Value, Variadic,
};
#[test]
fn test_load() {
@ -329,7 +327,7 @@ fn test_result_conversions() {
let err =
lua.create_function(|_, ()| {
Ok(Err::<String, _>(
format_err!("only through failure can we succeed").to_lua_err(),
err_msg("only through failure can we succeed").to_lua_err(),
))
}).unwrap();
let ok = lua

View File

@ -1,6 +1,8 @@
extern crate rlua;
use std::panic::catch_unwind;
use {Error, Function, Lua, Result, Thread, ThreadStatus};
use rlua::{Error, Function, Lua, Result, Thread, ThreadStatus};
#[test]
fn test_thread() {

View File

@ -1,6 +1,8 @@
extern crate rlua;
use std::os::raw::c_void;
use {Function, LightUserData, Lua};
use rlua::{Function, LightUserData, Lua};
#[test]
fn test_lightuserdata() {

View File

@ -1,6 +1,10 @@
extern crate failure;
extern crate rlua;
use std::sync::Arc;
use {ExternalError, Function, Lua, MetaMethod, String, UserData, UserDataMethods};
use failure::err_msg;
use rlua::{ExternalError, Function, Lua, MetaMethod, String, UserData, UserDataMethods};
#[test]
fn test_user_data() {
@ -83,7 +87,7 @@ fn test_metamethods() {
if index.to_str()? == "inner" {
Ok(data.0)
} else {
Err(format_err!("no such custom index").to_lua_err())
Err(err_msg("no such custom index").to_lua_err())
}
});
}