Fix tests.
This commit is contained in:
parent
56fbe39b7b
commit
89254a04c4
@ -161,9 +161,12 @@ fn bench_eval_loop_strings_no_build(bench: &mut Bencher) {
|
|||||||
fn bench_eval_switch(bench: &mut Bencher) {
|
fn bench_eval_switch(bench: &mut Bencher) {
|
||||||
let script = r#"
|
let script = r#"
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
|
let rem = 0;
|
||||||
|
|
||||||
for x in range(0, 10000) {
|
for x in range(0, 10000) {
|
||||||
sum += switch x % 5 {
|
rem = x % 5;
|
||||||
|
|
||||||
|
sum += switch rem {
|
||||||
0 => 10,
|
0 => 10,
|
||||||
1 => 12,
|
1 => 12,
|
||||||
2 => 42,
|
2 => 42,
|
||||||
@ -185,9 +188,10 @@ fn bench_eval_switch(bench: &mut Bencher) {
|
|||||||
fn bench_eval_nested_if(bench: &mut Bencher) {
|
fn bench_eval_nested_if(bench: &mut Bencher) {
|
||||||
let script = r#"
|
let script = r#"
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
|
let rem = 0;
|
||||||
|
|
||||||
for x in range(0, 10000) {
|
for x in range(0, 10000) {
|
||||||
let rem = x % 5;
|
rem = x % 5;
|
||||||
|
|
||||||
sum += if rem == 0 {
|
sum += if rem == 0 {
|
||||||
10
|
10
|
||||||
|
@ -1718,7 +1718,7 @@ impl Engine {
|
|||||||
Expr::Array(x, _) => Ok(Dynamic(Union::Array(Box::new(
|
Expr::Array(x, _) => Ok(Dynamic(Union::Array(Box::new(
|
||||||
x.iter()
|
x.iter()
|
||||||
.map(|item| self.eval_expr(scope, mods, state, lib, this_ptr, item, level))
|
.map(|item| self.eval_expr(scope, mods, state, lib, this_ptr, item, level))
|
||||||
.collect::<Result<Vec<_>, _>>()?,
|
.collect::<Result<_, _>>()?,
|
||||||
)))),
|
)))),
|
||||||
|
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
|
@ -12,17 +12,14 @@ use crate::module::{Module, NamespaceRef};
|
|||||||
use crate::optimize::OptimizationLevel;
|
use crate::optimize::OptimizationLevel;
|
||||||
use crate::parse_error::ParseErrorType;
|
use crate::parse_error::ParseErrorType;
|
||||||
use crate::result::EvalAltResult;
|
use crate::result::EvalAltResult;
|
||||||
use crate::scope::Scope;
|
use crate::scope::{EntryType as ScopeEntryType, Scope};
|
||||||
use crate::stdlib::ops::Deref;
|
use crate::stdlib::ops::Deref;
|
||||||
use crate::token::NO_POS;
|
use crate::token::NO_POS;
|
||||||
use crate::utils::ImmutableString;
|
use crate::utils::ImmutableString;
|
||||||
use crate::{calc_native_fn_hash, calc_script_fn_hash, StaticVec, INT};
|
use crate::{calc_native_fn_hash, calc_script_fn_hash, StaticVec, INT};
|
||||||
|
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
use crate::{
|
use crate::{ast::ScriptFnDef, r#unsafe::unsafe_cast_var_name_to_lifetime};
|
||||||
ast::ScriptFnDef, r#unsafe::unsafe_cast_var_name_to_lifetime,
|
|
||||||
scope::EntryType as ScopeEntryType,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
use crate::FLOAT;
|
use crate::FLOAT;
|
||||||
|
@ -90,9 +90,7 @@ mod test_switch_enum {
|
|||||||
fn test_switch_enum() -> Result<(), Box<EvalAltResult>> {
|
fn test_switch_enum() -> Result<(), Box<EvalAltResult>> {
|
||||||
let mut engine = Engine::new();
|
let mut engine = Engine::new();
|
||||||
|
|
||||||
engine
|
engine.register_get("get_data", MyEnum::get_enum_data);
|
||||||
.register_type_with_name::<MyEnum>("MyEnum")
|
|
||||||
.register_get("get_data", MyEnum::get_enum_data);
|
|
||||||
|
|
||||||
let mut scope = Scope::new();
|
let mut scope = Scope::new();
|
||||||
scope.push("x", MyEnum::Baz("hello".to_string(), true));
|
scope.push("x", MyEnum::Baz("hello".to_string(), true));
|
||||||
|
Loading…
Reference in New Issue
Block a user