Fix comments parsing.
This commit is contained in:
@@ -21,5 +21,62 @@ fn test_comments() -> Result<(), Box<EvalAltResult>> {
|
||||
42
|
||||
);
|
||||
|
||||
assert_eq!(engine.eval::<()>("/* Hello world */")?, ());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
#[test]
|
||||
fn test_comments_doc() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
let ast = engine.compile(
|
||||
r"
|
||||
/// Hello world
|
||||
|
||||
|
||||
fn foo() {}
|
||||
",
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
ast.iter_functions().next().unwrap().comments[0],
|
||||
"/// Hello world"
|
||||
);
|
||||
|
||||
assert!(engine
|
||||
.compile(
|
||||
r"
|
||||
/// Hello world
|
||||
let x = 42;
|
||||
"
|
||||
)
|
||||
.is_err());
|
||||
|
||||
let ast = engine.compile(
|
||||
r"
|
||||
/** Hello world
|
||||
** how are you?
|
||||
**/
|
||||
|
||||
fn foo() {}
|
||||
",
|
||||
)?;
|
||||
|
||||
assert_eq!(
|
||||
ast.iter_functions().next().unwrap().comments[0],
|
||||
"/** Hello world\n ** how are you?\n **/"
|
||||
);
|
||||
|
||||
assert!(engine
|
||||
.compile(
|
||||
r"
|
||||
/** Hello world */
|
||||
let x = 42;
|
||||
"
|
||||
)
|
||||
.is_err());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user