From f5822898cad1fd0f8473cb9449fb04c95b59d73f Mon Sep 17 00:00:00 2001 From: James Westman Date: Thu, 28 Sep 2023 20:12:23 -0500 Subject: [PATCH] fuzz: Test more of the code --- tests/fuzz.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/fuzz.py b/tests/fuzz.py index 81a9058..f1e9e00 100644 --- a/tests/fuzz.py +++ b/tests/fuzz.py @@ -7,15 +7,18 @@ from blueprintcompiler.outputs.xml import XmlOutput sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) -from blueprintcompiler import decompiler, gir, parser, tokenizer, utils +from blueprintcompiler import gir, parser, tokenizer from blueprintcompiler.completions import complete -from blueprintcompiler.errors import ( - CompileError, - CompilerBugError, - MultipleErrors, - PrintableError, -) -from blueprintcompiler.tokenizer import Token, TokenType, tokenize +from blueprintcompiler.errors import CompilerBugError, PrintableError +from blueprintcompiler.lsp import LanguageServer + + +def assert_ast_doesnt_crash(text, tokens, ast): + for i in range(len(text)): + ast.get_docs(i) + for i in range(len(text)): + list(complete(LanguageServer(), ast, tokens, i)) + ast.get_document_symbols() @PythonFuzz @@ -29,6 +32,7 @@ def fuzz(buf): xml = XmlOutput() if errors is None and ast is not None: xml.emit(ast) + assert_ast_doesnt_crash(blueprint, tokens, ast) except CompilerBugError as e: raise e except PrintableError: