Refine position display in error messages.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#![cfg(not(feature = "no_module"))]
|
||||
use rhai::{module_resolvers, Engine, EvalAltResult, Module, Scope, INT};
|
||||
use rhai::{
|
||||
module_resolvers, Engine, EvalAltResult, Module, ParseError, ParseErrorType, Scope, INT,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_module() {
|
||||
@@ -231,3 +233,20 @@ fn test_module_from_ast() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_module_export() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert!(matches!(
|
||||
engine.compile(r"let x = 10; { export x; }").expect_err("should error"),
|
||||
ParseError(x, _) if *x == ParseErrorType::WrongExport
|
||||
));
|
||||
|
||||
assert!(matches!(
|
||||
engine.compile(r"fn abc(x) { export x; }").expect_err("should error"),
|
||||
ParseError(x, _) if *x == ParseErrorType::WrongExport
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user