From dc7c014b10d39e26be33e19fe4434e5eaacb3ea8 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Tue, 31 Aug 2021 17:40:38 +0800 Subject: [PATCH] nac3core: top level more test --- nac3core/src/toplevel/test.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs index a270eb0b4..3dd260ce8 100644 --- a/nac3core/src/toplevel/test.rs +++ b/nac3core/src/toplevel/test.rs @@ -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, } +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 { 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 "} ] )]