summaryrefslogtreecommitdiff
path: root/src/chomp/ast/mod.rs
diff options
context:
space:
mode:
authorGreg Brown <gmb60@cam.ac.uk>2021-04-21 10:19:00 +0100
committerGreg Brown <gmb60@cam.ac.uk>2021-04-21 10:19:00 +0100
commit449695dcf87d26b0d06a51ca27bbc8214338f954 (patch)
tree32edf289a1d8287149f160a9b54cecb339be321c /src/chomp/ast/mod.rs
parentbb3c8d1455f7a102a0c0abffd757ccace94f77d5 (diff)
Add some comparison tests for Autochomp.
Diffstat (limited to 'src/chomp/ast/mod.rs')
-rw-r--r--src/chomp/ast/mod.rs18
1 files changed, 13 insertions, 5 deletions
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<NamedExpression>,
pub punct: Option<Span>,
pub second: Box<NamedExpression>,
- pub rest: Vec<(Option<Span>, NamedExpression)>
+ pub rest: Vec<(Option<Span>, 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<Span>,
}
+
+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 {}