mlua/tests
kyren 58ce05ff9a Improve the situation with numerical conversion
This is a somewhat involved change with two breaking API changes:

1) Lua::coerce_xxx methods now return Option (this is easier and faster than
dealing with Result)
2) rlua numeric conversions now allow more loss of precision
conversions (e.g. 1.5f32 to 1i32)

The logic for the first breaking change is that mostly the coerce methods are
probably used internally, and they make sense as low-level fallible casts and
are now used as such, and there's no reason to confuse things with a Result with
a large error type and force the user to match on the error which will hopefully
only be FromLuaConversionError anyway.

The logic for the second change is that it matches the behavior of
num_traits::cast, and is more consistent in that *some* loss of precision
conversions were previously allowed (e.g. f64 to f32).

The problem is that now, Lua::coerce_integer and Lua::unpack::<i64> have
different behavior when given, for example, the number 1.5.  I still think this
is the best option, though, because the Lua::coerce_xxx methods represent how
Lua works internally and the standard C API cast functions that Lua provides,
and the ToLua / FromLua code represents the most common form of fallible Rust
numeric conversion.

I could revert this change and turn `Lua::eval::<i64>("1.5", None)` back into an
error, but it seems inconsistent to allow f64 -> f32 loss of precision but not
f64 -> i64 loss of precision.
2018-09-26 21:01:54 -04:00
..
compile-fail Move integration tests into top-level tests directory 2018-09-16 20:15:51 -04:00
compile-fail.rs Attempt to enable compiletest_rs on nightly on travis 2018-02-10 00:27:15 -05:00
function.rs Move integration tests into top-level tests directory 2018-09-16 20:15:51 -04:00
scope.rs cargo fmt 2018-09-24 22:13:42 -04:00
string.rs Move integration tests into top-level tests directory 2018-09-16 20:15:51 -04:00
table.rs cargo fmt 2018-09-24 22:13:42 -04:00
tests.rs Improve the situation with numerical conversion 2018-09-26 21:01:54 -04:00
thread.rs cargo fmt 2018-09-24 22:13:42 -04:00
types.rs Move integration tests into top-level tests directory 2018-09-16 20:15:51 -04:00
userdata.rs Move integration tests into top-level tests directory 2018-09-16 20:15:51 -04:00