From c190884bca8d9f2fd3818a71c4efc29257a845c7 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 14 Mar 2017 11:17:20 -0700 Subject: [PATCH] Add unit test for value aliasing --- lib/reader/src/parser.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 9f29e54090..414dd291e2 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -1638,6 +1638,25 @@ mod tests { assert_eq!(message, "expected argument type"); } + #[test] + fn aliases() { + let (func, details) = Parser::new("function qux() { + ebb0: + v4 = iconst.i8 6 + vx3 -> v4 + v1 = iadd_imm vx3, 17 + }") + .parse_function(None) + .unwrap(); + assert_eq!(func.name.to_string(), "qux"); + let v4 = details.map.lookup_str("v4").unwrap(); + assert_eq!(v4.to_string(), "v0"); + let vx3 = details.map.lookup_str("vx3").unwrap(); + assert_eq!(vx3.to_string(), "vx0"); + let aliased_to = func.dfg.resolve_aliases(Value::table_with_number(0).unwrap()); + assert_eq!(aliased_to.to_string(), "v0"); + } + #[test] fn signature() { let sig = Parser::new("()").parse_signature(None).unwrap();