/
extension_symb.test.ts
executable file
·85 lines (83 loc) · 4.19 KB
/
extension_symb.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Tests of the extension
//
// The module 'chai' provides assertion methods from node
import { expect } from 'chai';
import * as vscode from 'vscode';
import { Position, Range, Location } from 'vscode';
import * as Path from 'path';
describe("Global Extension Tests", function () {
context("Symbols commands", function () {
let document: vscode.TextDocument;
// Creating the relative path to find the test file
const testFilesPath = Path.join(__dirname, "..", "..", "test_files", "sources");
// Simple test file
const uri = vscode.Uri.file(Path.join(testFilesPath, "tutorial.s"));
before(async () => {
// activate the extension
let ext = vscode.extensions.getExtension('prb28.amiga-assembly');
if (ext) {
await ext.activate();
}
// Read the file
document = await vscode.workspace.openTextDocument(uri);
// tslint:disable-next-line:no-unused-expression
expect(document).to.not.be.undefined;
});
it("Should find a symbol definition", async () => {
let locations = await vscode.commands.executeCommand('vscode.executeDefinitionProvider', uri, new Position(343, 33));
// tslint:disable-next-line:no-unused-expression
expect(locations).to.not.be.undefined;
if (locations) {
let l = locations as Array<Location>;
expect(l.length).to.be.equal(1);
expect(l[0].range).to.be.eql(new Range(new Position(25, 0), new Position(25, 11)));
expect(l[0].uri.fsPath).to.be.eql(uri.fsPath);
}
});
it("Should find all the symbol references", async () => {
let locations = await vscode.commands.executeCommand('vscode.executeReferenceProvider', uri, new Position(343, 33));
// tslint:disable-next-line:no-unused-expression
expect(locations).to.not.be.undefined;
if (locations) {
let l = locations as Array<Location>;
expect(l.length).to.be.equal(12);
expect(l[0].range).to.be.eql(new Range(new Position(343, 28), new Position(343, 39)));
expect(l[0].uri.fsPath).to.be.eql(uri.fsPath);
}
});
it("Should find all the symbol references for symbol in calculus", async () => {
let locations = await vscode.commands.executeCommand('vscode.executeReferenceProvider', uri, new Position(302, 41));
// tslint:disable-next-line:no-unused-expression
expect(locations).to.not.be.undefined;
if (locations) {
let l = locations as Array<Location>;
expect(l.length).to.be.equal(2);
expect(l[1].range).to.be.eql(new Range(new Position(302, 34), new Position(302, 44)));
expect(l[1].uri.fsPath).to.be.eql(uri.fsPath);
}
});
it("Should find all the symbol references for a dot label", async () => {
let locations = await vscode.commands.executeCommand('vscode.executeReferenceProvider', uri, new Position(119, 5));
// tslint:disable-next-line:no-unused-expression
expect(locations).to.not.be.undefined;
if (locations) {
let l = locations as Array<Location>;
expect(l.length).to.be.equal(1);
expect(l[0].range).to.be.eql(new Range(new Position(115, 25), new Position(115, 34)));
expect(l[0].uri.fsPath).to.be.eql(uri.fsPath);
}
});
it("Should find all the symbol references for a strange label", async () => {
let locations = await vscode.commands.executeCommand('vscode.executeReferenceProvider', uri, new Position(216, 5));
// tslint:disable-next-line:no-unused-expression
expect(locations).to.not.be.undefined;
if (locations) {
let l = locations as Array<Location>;
expect(l.length).to.be.equal(1);
expect(l[0].range).to.be.eql(new Range(new Position(156, 22), new Position(156, 30)));
expect(l[0].uri.fsPath).to.be.eql(uri.fsPath);
}
});
});
});