-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchr.rs
More file actions
26 lines (22 loc) · 694 Bytes
/
chr.rs
File metadata and controls
26 lines (22 loc) · 694 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
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 i: i32 = interpreter.context()[0].try_cast()?;
let mut s: String = String::new();
s.push((i as u8) as char);
interpreter
.context_mut()
.set_built_in_function_result(BuiltInFunction::Chr, s);
Ok(())
}
#[cfg(test)]
mod tests {
use crate::assert_prints;
use crate::interpreter::interpreter_trait::InterpreterTrait;
#[test]
fn test_chr() {
assert_prints!("PRINT CHR$(33)", "!");
}
}