[SwiftSyntax] Publicize DiagnosticEngine.addConsumer and add hasErrors property (#14996)

* [SwiftSyntax] Publicize DiagnosticEngine.addConsumer and add hasErrors property

* [Syntax] Make DiagnosticEngine.hasErrors public
This commit is contained in:
Harlan
2018-03-06 00:40:24 -05:00
committed by GitHub
parent 11e3d16c93
commit d3f6b8743d
2 changed files with 10 additions and 3 deletions

View File

@@ -33,6 +33,7 @@ Diagnostics.test("DiagnosticEmission") {
let fixLoc = loc()
let engine = DiagnosticEngine()
expectFalse(engine.hasErrors)
engine.diagnose(.cannotConvert(fromType: "Int", toType: "Bool"),
location: startLoc) {
@@ -42,10 +43,11 @@ Diagnostics.test("DiagnosticEmission") {
expectEqual(engine.diagnostics.count, 1)
guard let diag = engine.diagnostics.first else { return }
expectEqual(diag.message.text,
expectEqual(diag.message.text,
"cannot convert value of type 'Int' to 'Bool'")
expectEqual(diag.message.severity, .error)
expectEqual(diag.notes.count, 1)
expectTrue(engine.hasErrors)
guard let note = diag.notes.first else { return }
expectEqual(note.message.text, "check for explicit equality to '0'")