From 449695dcf87d26b0d06a51ca27bbc8214338f954 Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Wed, 21 Apr 2021 10:19:00 +0100 Subject: Add some comparison tests for Autochomp. --- src/chomp/ast/mod.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/chomp') diff --git a/src/chomp/ast/mod.rs b/src/chomp/ast/mod.rs index e4ed2fc..6d547a3 100644 --- a/src/chomp/ast/mod.rs +++ b/src/chomp/ast/mod.rs @@ -50,7 +50,7 @@ pub struct Alt { pub first: Box, pub punct: Option, pub second: Box, - pub rest: Vec<(Option, NamedExpression)> + pub rest: Vec<(Option, NamedExpression)>, } impl Display for Alt { @@ -69,10 +69,10 @@ impl PartialEq for Alt { && self.second == other.second && self.rest.len() == other.rest.len() && self - .rest - .iter() - .zip(other.rest.iter()) - .all(|((_, me), (_, them))| me == them) + .rest + .iter() + .zip(other.rest.iter()) + .all(|((_, me), (_, them))| me == them) } } @@ -323,3 +323,11 @@ pub struct Function { pub expr: NamedExpression, pub span: Option, } + +impl PartialEq for Function { + fn eq(&self, other: &Self) -> bool { + self.name == other.name && self.params == other.params && self.expr == other.expr + } +} + +impl Eq for Function {} -- cgit v1.2.3