add some test

This commit is contained in:
CrescentonC 2021-07-15 11:49:23 +08:00
parent 7823851fd6
commit f33b3d3482
1 changed files with 28 additions and 10 deletions

View File

@ -418,22 +418,41 @@ pub mod test {
struct S;
impl SymbolResolver for S {
fn get_symbol_location(&self, _str: &str) -> Option<Location> {
None
}
fn get_symbol_location(&self, _str: &str) -> Option<Location> { None }
fn get_symbol_type(&self, _str: &str) -> Option<SymbolType> {
None
}
fn get_symbol_type(&self, _str: &str) -> Option<SymbolType> { None }
fn get_symbol_value(&self, _str: &str) -> Option<SymbolValue> {
None
}
fn get_symbol_value(&self, _str: &str) -> Option<SymbolValue> { None }
}
InferenceContext::new(primitives::basic_ctx(), Box::new(S{}), FileID(3))
}
#[test]
fn test_i32() {
let mut inferencer = new_ctx();
let ast: Expr<Option<Type>> = Expr {
location: ast::Location::new(0, 0),
custom: None,
node: ast::ExprKind::Constant {
value: ast::Constant::Int(123.into()),
kind: None
}
};
let new_ast = inferencer.fold_expr(ast);
assert_eq!(
new_ast,
Ok(ast::Expr {
location: ast::Location::new(0, 0),
custom: Some(inferencer.get_primitive(primitives::INT32_TYPE)),
node: ast::ExprKind::Constant {
value: ast::Constant::Int(123.into()),
kind: None
}
})
);
}
#[test]
fn test_i64() {
@ -530,5 +549,4 @@ pub mod test {
}
);
}
}