parent
c3574bce92
commit
11bfa81c25
|
@ -8,3 +8,6 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.3.0", features = ["derive"] }
|
clap = { version = "4.3.0", features = ["derive"] }
|
||||||
ruxnasm = { git = "https://git.disroot.org/phyto/ruxnasm.git" }
|
ruxnasm = { git = "https://git.disroot.org/phyto/ruxnasm.git" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
temp-dir = "0.1.11"
|
||||||
|
|
16
src/lib.rs
16
src/lib.rs
|
@ -14,13 +14,13 @@ mod tests {
|
||||||
use super::bf::Op;
|
use super::bf::Op;
|
||||||
use super::uxn;
|
use super::uxn;
|
||||||
|
|
||||||
fn interp_uxn(uxn: Vec<u8>, _input: &str) -> Vec<u8> {
|
fn interp_uxn(uxn: std::path::PathBuf, input: String) -> Vec<u8> {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
let mut x = Command::new("uxncli")
|
let mut x = Command::new("uxncli")
|
||||||
.env_clear()
|
.env_clear()
|
||||||
.arg("/dev/stdin")
|
.arg(uxn.into_os_string())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
|
@ -30,7 +30,9 @@ mod tests {
|
||||||
|
|
||||||
let mut stdin = x.stdin.take().expect("failed to get stdin");
|
let mut stdin = x.stdin.take().expect("failed to get stdin");
|
||||||
let thread = std::thread::spawn(move || {
|
let thread = std::thread::spawn(move || {
|
||||||
stdin.write_all(&uxn).expect("failed to write to stdin");
|
stdin
|
||||||
|
.write_all(input.as_bytes())
|
||||||
|
.expect("failed to write to stdin");
|
||||||
dbg!("done writing");
|
dbg!("done writing");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,6 +55,10 @@ mod tests {
|
||||||
fn compare_bf_uxn() {
|
fn compare_bf_uxn() {
|
||||||
let files = std::fs::read_dir("tests/samples").unwrap();
|
let files = std::fs::read_dir("tests/samples").unwrap();
|
||||||
|
|
||||||
|
// make our temp dir
|
||||||
|
use temp_dir::TempDir;
|
||||||
|
let d = TempDir::new().unwrap();
|
||||||
|
|
||||||
for f in files {
|
for f in files {
|
||||||
let path = f.unwrap().path();
|
let path = f.unwrap().path();
|
||||||
dbg!(&path);
|
dbg!(&path);
|
||||||
|
@ -69,7 +75,9 @@ mod tests {
|
||||||
let tal = uxn::from_ops(&bf);
|
let tal = uxn::from_ops(&bf);
|
||||||
let (uxn, err) = ruxnasm::assemble(tal.as_bytes()).unwrap();
|
let (uxn, err) = ruxnasm::assemble(tal.as_bytes()).unwrap();
|
||||||
assert_eq!(err, vec![]);
|
assert_eq!(err, vec![]);
|
||||||
let uxn_out = interp_uxn(uxn, "");
|
let uxn_file = d.child(path.file_name().unwrap().to_string_lossy());
|
||||||
|
std::fs::write(&uxn_file, uxn).unwrap();
|
||||||
|
let uxn_out = interp_uxn(uxn_file, String::new());
|
||||||
eprintln!("uxn done");
|
eprintln!("uxn done");
|
||||||
|
|
||||||
assert_eq!(bf_out, uxn_out);
|
assert_eq!(bf_out, uxn_out);
|
||||||
|
|
Loading…
Reference in New Issue