-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspace.rs
More file actions
28 lines (24 loc) · 732 Bytes
/
space.rs
File metadata and controls
28 lines (24 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use rusty_linter::core::QBNumberCast;
use rusty_parser::BuiltInFunction;
use crate::RuntimeError;
use crate::interpreter::interpreter_trait::InterpreterTrait;
pub fn run<S: InterpreterTrait>(interpreter: &mut S) -> Result<(), RuntimeError> {
let len: i32 = interpreter.context()[0].try_cast()?;
let mut s: String = String::new();
for _ in 0..len {
s.push(' ');
}
interpreter
.context_mut()
.set_built_in_function_result(BuiltInFunction::Space, s);
Ok(())
}
#[cfg(test)]
mod tests {
use crate::assert_prints_exact;
use crate::interpreter::interpreter_trait::InterpreterTrait;
#[test]
fn test() {
assert_prints_exact!("PRINT SPACE$(4)", " ", "");
}
}