Add f32_float feature.
This commit is contained in:
@@ -34,19 +34,19 @@ fn test_float_parse() -> Result<(), Box<EvalAltResult>> {
|
||||
fn test_struct_with_float() -> Result<(), Box<EvalAltResult>> {
|
||||
#[derive(Clone)]
|
||||
struct TestStruct {
|
||||
x: f64,
|
||||
x: FLOAT,
|
||||
}
|
||||
|
||||
impl TestStruct {
|
||||
fn update(&mut self) {
|
||||
self.x += 5.789_f64;
|
||||
self.x += 5.789;
|
||||
}
|
||||
|
||||
fn get_x(&mut self) -> f64 {
|
||||
fn get_x(&mut self) -> FLOAT {
|
||||
self.x
|
||||
}
|
||||
|
||||
fn set_x(&mut self, new_x: f64) {
|
||||
fn set_x(&mut self, new_x: FLOAT) {
|
||||
self.x = new_x;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#![cfg(not(feature = "no_module"))]
|
||||
use rhai::{
|
||||
module_resolvers::StaticModuleResolver, Dynamic, Engine, EvalAltResult, ImmutableString,
|
||||
Module, ParseError, ParseErrorType, Scope, INT,
|
||||
Module, ParseError, ParseErrorType, Scope, FLOAT, INT,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -81,7 +81,7 @@ fn test_module_resolver() -> Result<(), Box<EvalAltResult>> {
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
module.set_fn_4_mut(
|
||||
"sum_of_three_args".to_string(),
|
||||
|target: &mut INT, a: INT, b: INT, c: f64| {
|
||||
|target: &mut INT, a: INT, b: INT, c: FLOAT| {
|
||||
*target = a + b + c as INT;
|
||||
Ok(())
|
||||
},
|
||||
|
@@ -4,7 +4,7 @@ use rhai::{Engine, EvalAltResult, INT};
|
||||
use rhai::FLOAT;
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
const EPSILON: FLOAT = 0.000_000_000_1;
|
||||
const EPSILON: FLOAT = 0.000_001;
|
||||
|
||||
#[test]
|
||||
fn test_power_of() -> Result<(), Box<EvalAltResult>> {
|
||||
|
@@ -16,7 +16,13 @@ fn test_type_of() -> Result<(), Box<EvalAltResult>> {
|
||||
assert_eq!(engine.eval::<String>("type_of(60 + 5)")?, "i32");
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
assert_eq!(engine.eval::<String>("type_of(1.0 + 2.0)")?, "f64");
|
||||
{
|
||||
#[cfg(not(feature = "f32_float"))]
|
||||
assert_eq!(engine.eval::<String>("type_of(1.0 + 2.0)")?, "f64");
|
||||
|
||||
#[cfg(feature = "f32_float")]
|
||||
assert_eq!(engine.eval::<String>("type_of(1.0 + 2.0)")?, "f32");
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_index"))]
|
||||
assert_eq!(
|
||||
|
Reference in New Issue
Block a user