compiler, runtime: Refactor Errors
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -182,5 +182,5 @@ import TreeSitterP4
|
||||
|
||||
let error = try #UseErrorResult(Program.Compile(simple_parser_declaration))
|
||||
|
||||
#expect(error.msg.contains("{29, 12}: Type of expression in return statement (Boolean) is not compatible with function return type (Int)"))
|
||||
#expect(error.msg().contains("{29, 12}: Type of expression in return statement (Boolean) is not compatible with function return type (Int)"))
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ import P4Lang
|
||||
|
||||
let compilation_error = try #UseErrorResult(Program.Compile(simple_parser_declaration))
|
||||
|
||||
#expect(compilation_error.msg.contains("asde"))
|
||||
#expect(compilation_error.msg.contains("asdf"))
|
||||
#expect(compilation_error.msg().contains("asde"))
|
||||
#expect(compilation_error.msg().contains("asdf"))
|
||||
}
|
||||
|
||||
@Test func test_simple_compiler_macro_nodetype_test() async throws {
|
||||
@@ -96,7 +96,7 @@ import P4Lang
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult<(EvaluatableStatement, CompilerContext)>(
|
||||
Error(withMessage: "{2, 154}: Did not find assignment statement"),
|
||||
ErrorWithLocation(sourceLocation: SourceLocation(2, 154), withError: "Did not find assignment statement"),
|
||||
ParserAssignmentStatement.Compile( // Note: Calling ParserAssignmentStatement compilation directly.
|
||||
node: result.rootNode!, withContext: CompilerContext())))
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import TreeSitterP4
|
||||
guard case Result.Error(let e) = err else {
|
||||
assert(false, "Expected an error, but had success")
|
||||
}
|
||||
#expect(e.msg.contains("Failed to parse a statement element: Could not parse a P4 type from \(invalid_type_name)"))
|
||||
#expect(e.format().contains("Failed to parse a statement element: Could not parse a P4 type from \(invalid_type_name)"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user