From 9b3b47ce507fbb0509002ea32c28815b3f1efd75 Mon Sep 17 00:00:00 2001 From: ychenfo Date: Tue, 28 Dec 2021 01:38:16 +0800 Subject: [PATCH] fix broken tests --- nac3ast/src/constant.rs | 2 +- nac3core/src/codegen/test.rs | 6 +- nac3core/src/toplevel/test.rs | 16 +-- .../src/typecheck/type_inferencer/test.rs | 4 +- nac3parser/src/lexer.rs | 2 +- nac3parser/src/parser.rs | 30 ++--- ...s__fstring_parse_selfdocumenting_base.snap | 19 ++- ...tring_parse_selfdocumenting_base_more.snap | 37 +++++- ..._fstring_parse_selfdocumenting_format.snap | 22 +++- ...__fstring__tests__parse_empty_fstring.snap | 7 +- ...parser__fstring__tests__parse_fstring.snap | 22 +++- ..._fstring__tests__parse_fstring_equals.snap | 12 ++ ...ing__tests__parse_fstring_nested_spec.snap | 16 ++- ...ring__tests__parse_fstring_not_equals.snap | 12 ++ ..._tests__parse_fstring_not_nested_spec.snap | 13 +- ...sts__parse_fstring_selfdoc_prec_space.snap | 19 ++- ..._parse_fstring_selfdoc_trailing_space.snap | 19 ++- ...ring__tests__parse_fstring_yield_expr.snap | 10 +- ...ser__parser__tests__comment_ambiguity.snap | 113 +++++++++++++++++- ...c3parser__parser__tests__more_comment.snap | 74 +++++++++++- ...ac3parser__parser__tests__parse_class.snap | 36 +++++- ...rser__tests__parse_dict_comprehension.snap | 19 ++- ...ests__parse_double_list_comprehension.snap | 42 +++++++ ...er__parser__tests__parse_if_elif_else.snap | 30 +++++ ...c3parser__parser__tests__parse_kwargs.snap | 18 +++ ...c3parser__parser__tests__parse_lambda.snap | 22 ++++ ...rser__tests__parse_list_comprehension.snap | 16 ++- ...3parser__parser__tests__parse_print_2.snap | 15 +++ ...ser__parser__tests__parse_print_hello.snap | 13 ++ ...c3parser__parser__tests__parse_tuples.snap | 23 +++- ...parser__parser__tests__sample_comment.snap | 17 ++- 31 files changed, 659 insertions(+), 47 deletions(-) diff --git a/nac3ast/src/constant.rs b/nac3ast/src/constant.rs index b3a7ed586..af8a85175 100644 --- a/nac3ast/src/constant.rs +++ b/nac3ast/src/constant.rs @@ -127,7 +127,7 @@ mod tests { use crate::fold::Fold; use crate::*; - let location = Location::new(0, 0); + let location = Location::new(0, 0, Default::default()); let custom = (); let ast = Located { location, diff --git a/nac3core/src/codegen/test.rs b/nac3core/src/codegen/test.rs index 34fcf3f48..4e63fd300 100644 --- a/nac3core/src/codegen/test.rs +++ b/nac3core/src/codegen/test.rs @@ -74,7 +74,7 @@ fn test_primitives() { d = a if c == 1 else 0 return d "}; - let statements = parse_program(source).unwrap(); + let statements = parse_program(source, Default::default()).unwrap(); let composer: TopLevelComposer = Default::default(); let mut unifier = composer.unifier.clone(); @@ -193,12 +193,12 @@ fn test_simple_call() { a = foo(a) return a * 2 "}; - let statements_1 = parse_program(source_1).unwrap(); + let statements_1 = parse_program(source_1, Default::default()).unwrap(); let source_2 = indoc! { " return a + 1 "}; - let statements_2 = parse_program(source_2).unwrap(); + let statements_2 = parse_program(source_2, Default::default()).unwrap(); let composer: TopLevelComposer = Default::default(); let mut unifier = composer.unifier.clone(); diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs index aa8545791..1aef5771b 100644 --- a/nac3core/src/toplevel/test.rs +++ b/nac3core/src/toplevel/test.rs @@ -103,7 +103,7 @@ fn test_simple_register(source: Vec<&str>) { let mut composer: TopLevelComposer = Default::default(); for s in source { - let ast = parse_program(s).unwrap(); + let ast = parse_program(s, Default::default()).unwrap(); let ast = ast[0].clone(); composer.register_top_level(ast, None, "".into()).unwrap(); @@ -149,7 +149,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s Arc::new(Resolver(internal_resolver.clone())) as Arc; for s in source { - let ast = parse_program(s).unwrap(); + let ast = parse_program(s, Default::default()).unwrap(); let ast = ast[0].clone(); let (id, def_id, ty) = @@ -333,7 +333,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s pass "} ], - vec!["application of type vars to generic class is not currently supported (at line 4 column 24)"]; + vec!["application of type vars to generic class is not currently supported (at unknown: line 4 column 24)"]; "err no type var in generic app" )] #[test_case( @@ -389,7 +389,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s def __init__(): pass "}], - vec!["__init__ method must have a `self` parameter (at line 2 column 5)"]; + vec!["__init__ method must have a `self` parameter (at unknown: line 2 column 5)"]; "err no self_1" )] #[test_case( @@ -411,7 +411,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s "} ], - vec!["a class definition can only have at most one base class declaration and one generic declaration (at line 1 column 24)"]; + vec!["a class definition can only have at most one base class declaration and one generic declaration (at unknown: line 1 column 24)"]; "err multiple inheritance" )] #[test_case( @@ -479,7 +479,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s pass "} ], - vec!["duplicate definition of class `A` ( at line 1 column 1)"]; + vec!["duplicate definition of class `A` (at unknown: line 1 column 1)"]; "class same name" )] fn test_analyze(source: Vec<&str>, res: Vec<&str>) { @@ -499,7 +499,7 @@ fn test_analyze(source: Vec<&str>, res: Vec<&str>) { Arc::new(Resolver(internal_resolver.clone())) as Arc; for s in source { - let ast = parse_program(s).unwrap(); + let ast = parse_program(s, Default::default()).unwrap(); let ast = ast[0].clone(); let (id, def_id, ty) = { @@ -683,7 +683,7 @@ fn test_inference(source: Vec<&str>, res: Vec<&str>) { Arc::new(Resolver(internal_resolver.clone())) as Arc; for s in source { - let ast = parse_program(s).unwrap(); + let ast = parse_program(s, Default::default()).unwrap(); let ast = ast[0].clone(); let (id, def_id, ty) = { diff --git a/nac3core/src/typecheck/type_inferencer/test.rs b/nac3core/src/typecheck/type_inferencer/test.rs index cc209bba2..0d1492ca5 100644 --- a/nac3core/src/typecheck/type_inferencer/test.rs +++ b/nac3core/src/typecheck/type_inferencer/test.rs @@ -461,7 +461,7 @@ fn test_basic(source: &str, mapping: HashMap<&str, &str>, virtuals: &[(&str, &st defined_identifiers.insert("virtual".into()); let mut inferencer = env.get_inferencer(); inferencer.defined_identifiers = defined_identifiers.clone(); - let statements = parse_program(source).unwrap(); + let statements = parse_program(source, Default::default()).unwrap(); let statements = statements .into_iter() .map(|v| inferencer.fold_stmt(v)) @@ -603,7 +603,7 @@ fn test_primitive_magic_methods(source: &str, mapping: HashMap<&str, &str>) { defined_identifiers.insert("virtual".into()); let mut inferencer = env.get_inferencer(); inferencer.defined_identifiers = defined_identifiers.clone(); - let statements = parse_program(source).unwrap(); + let statements = parse_program(source, Default::default()).unwrap(); let statements = statements .into_iter() .map(|v| inferencer.fold_stmt(v)) diff --git a/nac3parser/src/lexer.rs b/nac3parser/src/lexer.rs index 73e18788e..7b04891df 100644 --- a/nac3parser/src/lexer.rs +++ b/nac3parser/src/lexer.rs @@ -1339,7 +1339,7 @@ mod tests { const UNIX_EOL: &str = "\n"; pub fn lex_source(source: &str) -> Vec { - let lexer = make_tokenizer(source); + let lexer = make_tokenizer(source, Default::default()); lexer.map(|x| x.unwrap().1).collect() } diff --git a/nac3parser/src/parser.rs b/nac3parser/src/parser.rs index 4eae0c65e..55da3fad7 100644 --- a/nac3parser/src/parser.rs +++ b/nac3parser/src/parser.rs @@ -37,11 +37,11 @@ pub fn parse_program(source: &str, file: FileName) -> Result Result