Skip to content

Commit

Permalink
Tweak the simple_contract test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Nov 21, 2023
1 parent 2431458 commit ad3264d
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ fn simple_contract() -> Result<()> {
let parse_output = language.parse(ProductionKind::ContractDefinition, "contract Foo {}");

let parse_tree = parse_output.tree();
let rule = parse_tree
.into_rule()
.expect("Expected root node to be a rule");

let rule = if let Node::Rule(rule) = parse_tree {
assert_eq!(rule.kind, RuleKind::ContractDefinition);
rule
} else {
panic!("Unexpected parse_tree");
};
let children = &rule.children;

assert_eq!(children.len(), 6);
assert_eq!(rule.kind, RuleKind::ContractDefinition);
assert_eq!(rule.children.len(), 6);

let children = &rule.children;
assert!(matches!(&children[0], Node::Token(token) if token.kind == TokenKind::ContractKeyword));
assert!(matches!(&children[1], Node::Rule(rule) if rule.kind == RuleKind::LeadingTrivia));
assert!(matches!(&children[2], Node::Token(token) if token.kind == TokenKind::Identifier));
Expand Down

0 comments on commit ad3264d

Please sign in to comment.