xbasic 0.1.1

A library that allows adding a scripting language onto your project with ease. This lets your users write their own arbitrary logic.
Documentation
use xbasic::xbasic::XBasicBuilder;

mod common;

#[test]
fn below_compute_limit() {
	let mut tio = common::TestIO::new("3240\n");
	let mut xbb = XBasicBuilder::new(&mut 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);
	tio.check();
}

#[test]
fn above_compute_limit() {
	let mut tio = common::TestIO::new("");
	let mut xbb = XBasicBuilder::new(&mut tio);
	xbb.compute_limit(1000);
	let mut xb = xbb.build();
	assert!(xb
		.run(
			"
for a = 0 to 90
b = b + a
next a
print b
    ",
		)
		.is_err());
	assert!(xb.error_handler.had_runtime_error);
	assert_eq!(
		"[line 2] Error : Compute limit exceeded.",
		xb.error_handler.errors[0]
	);
	tio.check();
}