Skip to content

Commit

Permalink
Fix: test roundtrip of program->string->program
Browse files Browse the repository at this point in the history
  • Loading branch information
notmgsk committed Jul 4, 2022
1 parent a64e45c commit a197442
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/parser/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,11 @@ mod tests {
assert_eq!(parsed, expected);
}

/// Assert that an instruction can be parsed and then identically re-serialized to string.
/// Assert that when a program is converted to a string, the conversion of
/// that string into a program produces a program identical to the original
/// program.
#[test]
fn parse_and_serialize() {
fn parse_roundtrip() {
let inputs = vec![
r#"DEFCAL MEASURE 0 dest:
DECLARE iq REAL[2]
Expand All @@ -856,8 +858,9 @@ mod tests {
for input in inputs {
let program = Program::from_str(input).unwrap();
let output = program.to_string(true);
let roundtrip = Program::from_str(&output).unwrap();

assert_eq!(input.trim(), output.trim());
assert_eq!(program, roundtrip);
}
}
}

0 comments on commit a197442

Please sign in to comment.