Skip to content

Commit

Permalink
adds a test case to check that parser and type-check warnings are rep…
Browse files Browse the repository at this point in the history
…orted
  • Loading branch information
ArquintL committed Jul 17, 2023
1 parent 0016f69 commit 4ab28c1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
13 changes: 12 additions & 1 deletion client/src/test/1_ide.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {

Expand Down Expand Up @@ -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<T>(seen: T, expected: T, message: string): void {
Expand Down
2 changes: 2 additions & 0 deletions client/src/test/TestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions client/src/test/data/warnings.vpr
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit 4ab28c1

Please sign in to comment.