forked from M-Labs/nac3
nac3core: top level more test
This commit is contained in:
parent
1ae6acc061
commit
dc7c014b10
@ -8,8 +8,12 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
use parking_lot::RwLock;
|
||||||
use rustpython_parser::{ast::fold::Fold, parser::parse_program};
|
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 test_case::test_case;
|
||||||
|
|
||||||
use super::TopLevelComposer;
|
use super::TopLevelComposer;
|
||||||
@ -20,6 +24,12 @@ struct Resolver {
|
|||||||
class_names: HashMap<String, Type>,
|
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 {
|
impl SymbolResolver for Resolver {
|
||||||
fn get_symbol_type(&self, _: &mut Unifier, _: &PrimitiveStore, str: &str) -> Option<Type> {
|
fn get_symbol_type(&self, _: &mut Unifier, _: &PrimitiveStore, str: &str) -> Option<Type> {
|
||||||
self.id_to_type.get(str).cloned()
|
self.id_to_type.get(str).cloned()
|
||||||
@ -60,6 +70,12 @@ impl SymbolResolver for Resolver {
|
|||||||
indoc! {"
|
indoc! {"
|
||||||
def foo(a: float):
|
def foo(a: float):
|
||||||
a + 1.0
|
a + 1.0
|
||||||
|
"},
|
||||||
|
indoc! {"
|
||||||
|
class C(B):
|
||||||
|
def __init__(self):
|
||||||
|
self.c: int = 4
|
||||||
|
self.a: bool = True
|
||||||
"}
|
"}
|
||||||
]
|
]
|
||||||
)]
|
)]
|
||||||
|
Loading…
Reference in New Issue
Block a user