Skip to content

Commit

Permalink
#27 Semantic highlighting test added
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoFernandes1410 committed Dec 2, 2022
1 parent 2209487 commit 1fe7ce2
Show file tree
Hide file tree
Showing 10 changed files with 1,223 additions and 52 deletions.
50 changes: 0 additions & 50 deletions client/src/test/completion.test.ts

This file was deleted.

39 changes: 39 additions & 0 deletions client/src/test/semanticHighlighting.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as vscode from "vscode";
import * as assert from "assert";
import * as fs from 'fs';
import { getDocUri, getDocPath, activate } from "./helper";

suite("Semantic Highlighting", () => {
const docUri = getDocUri("semanticHighlighting.eo");

test("Performs semantic highlighting in document", async () => {
const targetTokens = fs.readFileSync(getDocPath("semanticHighlightingTarget.txt"),"utf8");
const targetTokensArray = targetTokens.split("\n");

await testSemanticHighlight(docUri, targetTokensArray);
});
});

/**
* Checks if the semantic tokens returned by the Semantic Tokens Provider
* are exactly the same as expected
* @param docUri
* @param expectedCompletionList
*/
async function testSemanticHighlight(
docUri: vscode.Uri,
expectedSemanticTokens: string[]
) {
await activate(docUri);

const actualSemanticTokens = (await vscode.commands.executeCommand(
"vscode.provideDocumentSemanticTokens",
docUri
)) as vscode.SemanticTokens;

assert.ok(actualSemanticTokens.data.length >= 2);
expectedSemanticTokens.forEach((expectedItem, i) => {
const actualItem = actualSemanticTokens.data[i].toString();
assert.equal(expectedItem, actualItem);
});
}
Empty file removed client/testFixture/completion.txt
Empty file.
17 changes: 17 additions & 0 deletions client/testFixture/semanticHighlighting.eo
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[args...] > app
memory 0 > x
seq > @
x.write 2
while.
x.lt 6
[i]
seq > @
QQ.io.stdout
QQ.txt.sprintf
"%d x %d = %d\n"
x
x
x.times x
x.write
x.plus 1
TRUE
Loading

0 comments on commit 1fe7ce2

Please sign in to comment.