forked from return/malbolge
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
41 lines (36 loc) · 1017 Bytes
/
lib.rs
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
30
31
32
33
34
35
36
37
38
39
40
41
pub mod vm;
pub mod util;
#[macro_export]
macro_rules! malbolge {
($expression:expr) => {
use vm::VirtualMachine;
let mut o = VirtualMachine::new(false);
o.load(Vec::from($expression));
o.exec()
}
}
#[cfg(test)]
mod tests {
use super::*;
use super::vm::*;
use std::path::PathBuf;
#[test]
fn malbolge_hello(){
let mut vm = VirtualMachine::new(false);
let mut test_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_path.push("./mbi/examples/hello.mb");
vm.load_program(test_path);
vm.exec();
}
#[test]
fn malbolge_load_path() {
let mut test_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_path.push("./mbi/examples/cat.mb");
let vm = VirtualMachine::new(false).load_program(test_path);
assert_eq!(vm, true);
}
#[test]
fn malbolge_macro_string() {
malbolge!(r#"(=<`#9]76Z{z2V0/S-Qr*)M:,+*)('&%$#"!~}|{z(Kw%$t"Vq0iAm,,j<h'`%"#);
}
}