-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkd.rs
More file actions
29 lines (25 loc) · 871 Bytes
/
mkd.rs
File metadata and controls
29 lines (25 loc) · 871 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
29
use rusty_linter::core::QBNumberCast;
use rusty_parser::BuiltInFunction;
use rusty_variant::f64_to_bytes;
use crate::RuntimeError;
use crate::interpreter::interpreter_trait::InterpreterTrait;
use crate::interpreter::string_utils::to_ascii_string;
pub fn run<S: InterpreterTrait>(interpreter: &mut S) -> Result<(), RuntimeError> {
let f: f64 = interpreter.context()[0].try_cast()?;
let bytes = f64_to_bytes(f);
let s: String = to_ascii_string(&bytes);
interpreter
.context_mut()
.set_built_in_function_result(BuiltInFunction::Mkd, s);
Ok(())
}
#[cfg(test)]
mod tests {
use crate::assert_prints;
use crate::interpreter::interpreter_trait::InterpreterTrait;
#[test]
fn prints_expected_value() {
let program = r#"PRINT MKD$(2)"#;
assert_prints!(program, "\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}@");
}
}