use p101_is::*;
use p101_enc::filter::*;
use p101_enc::pipeline::*;
#[test]
pub fn convert_and_trim_program_136() {
const FILE: &'static str= "tests/p101card.136";
let stages: Vec<Stage> = vec!(
Stage::new(Box::new(ReadFile::new()), false),
Stage::new(Box::new(LariniDecoder::new()), true));
let options = PipelineOptions {
display_messages: false,
display_errors: false,
};
let pipeline = Pipeline::new(stages, options);
let r = pipeline.run(EncodingData::File(FILE.into()));
assert_eq!(true, r.is_ok());
let output = r.unwrap();
assert_eq!(1, output.inspections.len());
match &output.inspections[0] {
EncodingData::Program(p) => {
assert_eq!(Instruction::Label(JumpDestination::AV), p[0]);
assert_eq!(Instruction::Stop, p[1]);
assert_eq!(Instruction::CopyM(Register::B), p[2]);
assert_eq!(Instruction::CopyM(Register::C), p[3]);
assert_eq!(Instruction::Label(JumpDestination::BV), p[4]);
assert_eq!(Instruction::CopyToA(Register::C), p[5]);
assert_eq!(Instruction::Mul(Register::B), p[6]);
assert_eq!(Instruction::Print(Register::A), p[7]);
assert_eq!(Instruction::SwapA(Register::B), p[8]);
assert_eq!(Instruction::Jump(Origin::CV), p[9]);
},
_ => assert!(false),
};
}
#[test]
pub fn convert_and_trim_program_138() {
const FILE: &'static str= "tests/p101card.138";
let stages: Vec<Stage> = vec!(
Stage::new(Box::new(ReadFile::new()), false),
Stage::new(Box::new(LariniDecoder::new()), true));
let options = PipelineOptions {
display_messages: false,
display_errors: false,
};
let pipeline = Pipeline::new(stages, options);
let r = pipeline.run(EncodingData::File(FILE.into()));
assert_eq!(true, r.is_ok());
let output = r.unwrap();
assert!(output.inspections.len() > 0);
}