-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
178 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use folidity_parser::{ast as parsed_ast, Span}; | ||
|
||
use crate::{ | ||
ast::TypeVariant, contract::ContractDefinition, symtable::SymTable, types::ExpectedType, | ||
}; | ||
|
||
use super::expression; | ||
|
||
#[test] | ||
fn test_list() { | ||
let loc = Span { start: 0, end: 0 }; | ||
let mut contract = ContractDefinition::default(); | ||
let mut symtable = SymTable::default(); | ||
let parsed_list = parsed_ast::Expression::List(parsed_ast::UnaryExpression { | ||
loc: loc.clone(), | ||
element: vec![ | ||
parsed_ast::Expression::Number(parsed_ast::UnaryExpression { | ||
loc: loc.clone(), | ||
element: "1".to_string(), | ||
}), | ||
parsed_ast::Expression::Number(parsed_ast::UnaryExpression { | ||
loc: loc.clone(), | ||
element: "2".to_string(), | ||
}), | ||
parsed_ast::Expression::Number(parsed_ast::UnaryExpression { | ||
loc: loc.clone(), | ||
element: "3".to_string(), | ||
}), | ||
], | ||
}); | ||
let resolved_expr = expression( | ||
&parsed_list, | ||
ExpectedType::Concrete(TypeVariant::List(Box::new(TypeVariant::Int))), | ||
&mut symtable, | ||
&mut contract, | ||
); | ||
assert!(resolved_expr.is_ok()); | ||
|
||
let resolved_expr_err = expression( | ||
&parsed_list, | ||
ExpectedType::Concrete(TypeVariant::List(Box::new(TypeVariant::Float))), | ||
&mut symtable, | ||
&mut contract, | ||
); | ||
assert!(resolved_expr_err.is_err()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters