Skip to content

Commit 12d2eaa

Browse files
committed
rune: Clean tests a bit more
1 parent 496577c commit 12d2eaa

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

crates/rune/src/tests.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) mod prelude {
2525
pub(crate) use crate::tests::{eval, run};
2626
pub(crate) use crate::{
2727
from_value, prepare, sources, span, vm_try, Any, Context, ContextError, Diagnostics,
28-
FromValue, Hash, Item, ItemBuf, Module, Options, Source, Sources, Value, Vm,
28+
FromValue, Hash, Item, ItemBuf, Module, Source, Sources, Value, Vm,
2929
};
3030
pub(crate) use futures_executor::block_on;
3131

@@ -43,7 +43,7 @@ use ::rust_alloc::sync::Arc;
4343

4444
use anyhow::{Context as _, Error, Result};
4545

46-
use crate::runtime::{Args, VmError};
46+
use crate::runtime::{GuardedArgs, VmError};
4747
use crate::{
4848
alloc, termcolor, BuildError, Context, Diagnostics, FromValue, Hash, Options, Source, Sources,
4949
Unit, Vm,
@@ -149,24 +149,21 @@ pub fn run_helper<T>(
149149
context: &Context,
150150
sources: &mut Sources,
151151
diagnostics: &mut Diagnostics,
152-
args: impl Args,
152+
args: impl GuardedArgs,
153153
script: bool,
154154
) -> Result<T, TestError>
155155
where
156156
T: FromValue,
157157
{
158158
let mut vm = vm(context, sources, diagnostics, script)?;
159159

160-
let mut execute = if script {
161-
vm.execute(Hash::EMPTY, args).map_err(TestError::VmError)?
160+
let result = if script {
161+
::futures_executor::block_on(vm.async_call(Hash::EMPTY, args))
162162
} else {
163-
vm.execute(["main"], args).map_err(TestError::VmError)?
163+
::futures_executor::block_on(vm.async_call(["main"], args))
164164
};
165165

166-
let output = ::futures_executor::block_on(execute.async_complete())
167-
.into_result()
168-
.map_err(TestError::VmError)?;
169-
166+
let output = result.map_err(TestError::VmError)?;
170167
crate::from_value(output).map_err(|error| TestError::VmError(error.into()))
171168
}
172169

@@ -180,7 +177,7 @@ pub fn sources(source: &str) -> Sources {
180177
}
181178

182179
/// Run the given source with diagnostics being printed to stderr.
183-
pub fn run<T>(context: &Context, source: &str, args: impl Args, script: bool) -> Result<T>
180+
pub fn run<T>(context: &Context, source: &str, args: impl GuardedArgs, script: bool) -> Result<T>
184181
where
185182
T: FromValue,
186183
{
@@ -487,6 +484,7 @@ mod getter_setter;
487484
mod iterator;
488485
#[cfg(not(miri))]
489486
mod macros;
487+
mod matching;
490488
#[cfg(not(miri))]
491489
mod moved;
492490
#[cfg(not(miri))]

0 commit comments

Comments
 (0)