rhai/tests/unit.rs

25 lines
563 B
Rust
Raw Normal View History

2020-03-02 15:11:56 +01:00
use rhai::{Engine, EvalAltResult};
2018-05-23 01:44:41 +02:00
#[test]
fn test_unit() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
2022-01-10 06:26:33 +01:00
engine.run("let x = (); x")?;
2020-03-02 15:11:56 +01:00
Ok(())
2018-05-23 01:44:41 +02:00
}
#[test]
fn test_unit_eq() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
2022-12-30 18:07:39 +01:00
assert!(engine
.eval::<bool>("let x = (); let y = (); x == y")
.unwrap());
2020-03-02 15:11:56 +01:00
Ok(())
2018-05-23 01:44:41 +02:00
}
#[test]
fn test_unit_with_spaces() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
2022-12-30 18:07:39 +01:00
let _ = engine.run("let x = ( ); x").expect_err("should error");
2020-03-02 15:11:56 +01:00
Ok(())
}