use xbasic::xbasic::XBasic; mod common; #[test] fn not_1() { common::test_program("print not not 5\n", "true\n"); } #[test] fn not_2() { common::test_program("print not true\n", "false\n"); } #[test] fn not_3() { let tio = common::TestIO::new(""); let mut xb = XBasic::new(tio); assert!(xb.run("print not \"test\"\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 neg_1() { common::test_program("print 3 + -5\n", "-2\n"); } #[test] fn neg_2() { common::test_program("print -(-5)\n", "5\n"); } #[test] fn neg_3() { let tio = common::TestIO::new(""); let mut xb = XBasic::new(tio); assert!(xb.run("print -\"test\"\n").is_err()); assert!(xb.error_handler.had_runtime_error); assert_eq!( xb.error_handler.errors, ["[line 1] Error : Cannot cast string to number."] ); xb.get_io().check(); }