use xbasic::xbasic::XBasic;
mod common;
#[test]
fn and_1() {
common::test_program("print 3 and 4\n", "true\n");
}
#[test]
fn and_2() {
common::test_program("print 0 and 4\n", "false\n");
}
#[test]
fn and_3() {
common::test_program("print 4 and 0\n", "false\n");
}
#[test]
fn and_4() {
let tio = common::TestIO::new("");
let mut xb = XBasic::new(tio);
assert!(xb.run("print \"test\" and 4\n").is_err());
assert!(xb.error_handler.had_runtime_error);
assert_eq!(
xb.error_handler.errors,
["[line 1] Error : Cannot cast string to boolean."]
);
xb.get_io().check();
}
#[test]
fn or_1() {
common::test_program("print 3 or 4\n", "true\n");
}
#[test]
fn or_2() {
common::test_program("print 0 or 4\n", "true\n");
}
#[test]
fn or_3() {
common::test_program("print 0 or 0\n", "false\n");
}
#[test]
fn or_4() {
let tio = common::TestIO::new("");
let mut xb = XBasic::new(tio);
assert!(xb.run("print \"test\" or 4\n").is_err());
assert!(xb.error_handler.had_runtime_error);
assert_eq!(
xb.error_handler.errors,
["[line 1] Error : Cannot cast string to boolean."]
);
xb.get_io().check();
}