aboutsummaryrefslogtreecommitdiffstats
path: root/modelica-parser-lalrpop/tests
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-12-26 00:43:58 -0800
committerbnewbold <bnewbold@robocracy.org>2016-12-26 00:43:58 -0800
commit851d72cdd58a51adcf93bcd9a5956d82d3b5417d (patch)
treeff37476a74d39926e8c52de470040bbd3b5c7bba /modelica-parser-lalrpop/tests
parent9cf287fef8e614f57d0d52d579d6721ba54683f4 (diff)
downloadmodelthing-851d72cdd58a51adcf93bcd9a5956d82d3b5417d.tar.gz
modelthing-851d72cdd58a51adcf93bcd9a5956d82d3b5417d.zip
parser: refactor vec operations into hashset
Diffstat (limited to 'modelica-parser-lalrpop/tests')
-rw-r--r--modelica-parser-lalrpop/tests/ast.rs41
1 files changed, 18 insertions, 23 deletions
diff --git a/modelica-parser-lalrpop/tests/ast.rs b/modelica-parser-lalrpop/tests/ast.rs
index 51c1014..d551142 100644
--- a/modelica-parser-lalrpop/tests/ast.rs
+++ b/modelica-parser-lalrpop/tests/ast.rs
@@ -5,52 +5,47 @@ use std::collections::HashSet;
use std::iter::FromIterator;
use modelica_parser::*;
-fn set_eq(a: Vec<String>, b: Vec<String>) -> bool {
- let set_a: HashSet<String> = HashSet::from_iter(a);
- let set_b: HashSet<String> = HashSet::from_iter(b);
- return set_a == set_b;
-}
#[test]
fn test_expr_identifiers() {
use modelica_parser::Expr::*;
- assert!(set_eq(
- vec![],
- Integer(0).identifiers()));
- assert!(set_eq(
- vec!["x".to_string()],
- Ident("x".to_string()).identifiers()));
- assert!(set_eq(
- vec!["x".to_string(), "y".to_string(), "z".to_string()],
+ assert_eq!(
+ HashSet::new(),
+ Integer(0).identifiers());
+ assert_eq!(
+ HashSet::from_iter(vec!["x".to_string()]),
+ Ident("x".to_string()).identifiers());
+ assert_eq!(
+ HashSet::from_iter(vec!["x".to_string(), "y".to_string(), "z".to_string()]),
BinExpr(BinOperator::Add,
Box::new(Sign(Box::new(Ident("z".to_string())))),
Box::new(BinExpr(BinOperator::Add,
Box::new(Sign(Box::new(Ident("x".to_string())))),
- Box::new(Sign(Box::new(Ident("y".to_string()))))))).identifiers()));
- assert!(set_eq(
- vec!["z".to_string()],
+ Box::new(Sign(Box::new(Ident("y".to_string()))))))).identifiers());
+ assert_eq!(
+ HashSet::from_iter(vec!["z".to_string()]),
BinExpr(BinOperator::Add,
Box::new(Ident("z".to_string())),
- Box::new(Ident("z".to_string()))).identifiers()));
+ Box::new(Ident("z".to_string()))).identifiers());
}
#[test]
fn test_eqn_identifiers() {
use modelica_parser::Expr::*;
- assert!(set_eq(
- vec![],
+ assert_eq!(
+ HashSet::new(),
SimpleEquation{
lhs: Integer(0),
rhs: Integer(0),
- }.identifiers()));
- assert!(set_eq(
- vec!["z".to_string()],
+ }.identifiers());
+ assert_eq!(
+ HashSet::from_iter(vec!["z".to_string()]),
SimpleEquation{
lhs: Ident("z".to_string()),
rhs: BinExpr(BinOperator::Add,
Box::new(Ident("z".to_string())),
Box::new(Ident("z".to_string()))),
- }.identifiers()));
+ }.identifiers());
}