diff --git a/client/src/test/1_ide.test.ts b/client/src/test/1_ide.test.ts index 820ba272..ce927752 100644 --- a/client/src/test/1_ide.test.ts +++ b/client/src/test/1_ide.test.ts @@ -1,9 +1,10 @@ import assert from 'assert'; import * as path from 'path'; +import * as vscode from 'vscode'; import { Helper } from '../Helper'; import { Log } from '../Log'; import { Common } from '../ViperProtocol'; -import TestHelper, { EMPTY_TXT, LONG, SETUP_TIMEOUT, SIMPLE } from './TestHelper'; +import TestHelper, { EMPTY_TXT, LONG, SETUP_TIMEOUT, SIMPLE, WARNINGS } from './TestHelper'; suite('ViperIDE Tests', () => { @@ -112,6 +113,16 @@ suite('ViperIDE Tests', () => { await opened; await TestHelper.closeFile(); }); + + test("Test warnings", async function() { + this.timeout(2000); + + const document = await TestHelper.openAndVerify(WARNINGS); + const diagnostics = vscode.languages.getDiagnostics(document.uri); + checkAssert(diagnostics.length, 2, `Amount of diagnostics`); + checkAssert(diagnostics[0].severity, vscode.DiagnosticSeverity.Warning, "First diagnostic"); + checkAssert(diagnostics[1].severity, vscode.DiagnosticSeverity.Warning, "Second diagnostic"); + }); }); function checkAssert(seen: T, expected: T, message: string): void { diff --git a/client/src/test/TestHelper.ts b/client/src/test/TestHelper.ts index 83a16909..6d907275 100644 --- a/client/src/test/TestHelper.ts +++ b/client/src/test/TestHelper.ts @@ -27,6 +27,8 @@ export const SIMPLE = 'simple.sil'; export const EMPTY = 'empty.sil'; export const EMPTY_TXT = 'empty.txt'; export const LONG = 'longDuration.vpr'; +export const WARNINGS = 'warnings.vpr'; + export default class TestHelper { private static callbacks: UnitTestCallbackImpl = null; diff --git a/client/src/test/data/warnings.vpr b/client/src/test/data/warnings.vpr new file mode 100644 index 00000000..4d8cea16 --- /dev/null +++ b/client/src/test/data/warnings.vpr @@ -0,0 +1,15 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/publicdomain/zero/1.0/ + +adt List[T] { + Nil() + Cons(value: T, tail: List[T]) +} + +method test() +{ + // causes a parser warning + var rat: Rational + // causes a type-checker warning: + assert Nil() == Nil() +}