1
0
forked from M-Labs/nac3

nac3core: top level more test

This commit is contained in:
ychenfo 2021-08-31 17:40:38 +08:00
parent 1ae6acc061
commit dc7c014b10

View File

@ -8,8 +8,12 @@ use crate::{
},
};
use indoc::indoc;
use parking_lot::RwLock;
use rustpython_parser::{ast::fold::Fold, parser::parse_program};
use std::collections::{HashMap, HashSet};
use std::{
collections::{HashMap, HashSet},
sync::Arc,
};
use test_case::test_case;
use super::TopLevelComposer;
@ -20,6 +24,12 @@ struct Resolver {
class_names: HashMap<String, Type>,
}
impl Resolver {
pub fn add_id_def(&mut self, id: String, def: DefinitionId) {
self.id_to_def.insert(id, def);
}
}
impl SymbolResolver for Resolver {
fn get_symbol_type(&self, _: &mut Unifier, _: &PrimitiveStore, str: &str) -> Option<Type> {
self.id_to_type.get(str).cloned()
@ -60,6 +70,12 @@ impl SymbolResolver for Resolver {
indoc! {"
def foo(a: float):
a + 1.0
"},
indoc! {"
class C(B):
def __init__(self):
self.c: int = 4
self.a: bool = True
"}
]
)]