use xbasic::xbasic::XBasicBuilder; mod common; #[test] fn below_compute_limit() { let tio = common::TestIO::new("3240\n"); let mut xbb = XBasicBuilder::new(tio); xbb.compute_limit(1000); let mut xb = xbb.build(); assert!(xb .run( " for a = 0 to 80 b = b + a next a print b ", ) .is_ok()); assert!(!xb.error_handler.had_runtime_error); xb.get_io().check(); } #[test] fn above_compute_limit() { let tio = common::TestIO::new(""); let mut xbb = XBasicBuilder::new(tio); xbb.compute_limit(1000); let mut xb = xbb.build(); assert!(xb .run( " for a = 0 to 98 b = b + a next a print b ", ) .is_err()); assert!(xb.error_handler.had_runtime_error); assert_eq!( "[line 5] Error : Compute limit exceeded.", xb.error_handler.errors[0] ); xb.get_io().check(); } #[test] fn compute_error_line_one() { let tio = common::TestIO::new(""); let mut xbb = XBasicBuilder::new(tio); xbb.compute_limit(1000); let mut xb = xbb.build(); assert!(xb .run( " while true wend ", ) .is_err()); assert!(xb.error_handler.had_runtime_error); assert_eq!( "[line 2] Error : Compute limit exceeded.", xb.error_handler.errors[0] ); xb.get_io().check(); }