Skip to content

Fix colorization unittest #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Jakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var servicesDirectory = "src/services/";
var harnessDirectory = "src/harness/";
var libraryDirectory = "src/lib/";
var scriptsDirectory = "scripts/";
var unittestsDirectory = "tests/cases/unittests/";
var docDirectory = "doc/";

var builtDirectory = "built/";
Expand Down Expand Up @@ -74,13 +75,17 @@ var harnessSources = [
"typeWriter.ts",
"fourslashRunner.ts",
"projectsRunner.ts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this file? also can we remove references to "unittests" in the case in runner.ts

"unittestrunner.ts",
"loggedIO.ts",
"rwcRunner.ts",
"runner.ts"
].map(function (f) {
return path.join(harnessDirectory, f);
});
}).concat([
"services/colorization.ts",
"services/documentRegistry.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
}));

var librarySourceMap = [
{ target: "lib.core.d.ts", sources: ["core.d.ts"] },
Expand Down
7 changes: 0 additions & 7 deletions src/harness/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// ///<reference path='fourslashRunner.ts' />
/// <reference path='projectsRunner.ts' />
/// <reference path='rwcRunner.ts' />
/// <reference path='unittestrunner.ts' />

function runTests(runners: RunnerBase[]) {
if (reverse) {
Expand Down Expand Up @@ -67,9 +66,6 @@ if (testConfigFile !== '') {
case 'fourslash-generated':
runners.push(new GeneratedFourslashRunner());
break;
case 'unittests':
runners.push(new UnitTestRunner());
break;
case 'rwc':
runners.push(new RWCRunner());
break;
Expand All @@ -93,9 +89,6 @@ if (runners.length === 0) {
// language services
runners.push(new FourslashRunner());
//runners.push(new GeneratedFourslashRunner());

// unittests
runners.push(new UnitTestRunner());
}

sys.newLine = '\r\n';
Expand Down
73 changes: 0 additions & 73 deletions src/harness/unittestrunner.ts

This file was deleted.

13 changes: 8 additions & 5 deletions tests/cases/unittests/services/colorization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
interface Classification {
/// <reference path="..\..\..\..\src\harness\external\mocha.d.ts" />
/// <reference path="..\..\..\..\src\harness\harnessLanguageService.ts" />

interface Classification {
position: number;
length: number;
class: ts.TokenClass;
Expand Down Expand Up @@ -66,7 +69,7 @@ describe('Colorization', function () {
function numberLiteral(text: string) { return { value: text, class: ts.TokenClass.NumberLiteral }; }
function stringLiteral(text: string) { return { value: text, class: ts.TokenClass.StringLiteral }; }
function regExpLiteral(text: string) { return { value: text, class: ts.TokenClass.RegExpLiteral }; }
function finalEndOfLineState(value: number) { return { value: value, class: undefined }; }
function finalEndOfLineState(value: number) { return { value: value, class: <ts.TokenClass>undefined }; }

function test(text: string, initialEndOfLineState: ts.EndOfLineState, ...expectedEntries: ClassificationEntry[]): void {
var result = getClassifications(text, initialEndOfLineState);
Expand Down Expand Up @@ -253,7 +256,7 @@ describe('Colorization', function () {
identifier("Foo"),
operator("<"),
identifier("Foo"),
punctuation(","),
operator(","),
identifier("Foo"),
operator("<"),
identifier("number"),
Expand All @@ -265,8 +268,8 @@ describe('Colorization', function () {
identifier("Foo"),
operator("<"),
identifier("Foo"),
operator(">"
identifier("keyword"),
operator(">"),
keyword("number"),
finalEndOfLineState(ts.EndOfLineState.Start));
});
});
Expand Down
12 changes: 6 additions & 6 deletions tests/cases/unittests/services/documentRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ describe("DocumentRegistry", () => {
var documentRegistry = ts.createDocumentRegistry();
var defaultCompilerOptions = ts.getDefaultCompilerOptions();

var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), 1, false);
var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), 1, false);
var f1 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), "1", false);
var f2 = documentRegistry.acquireDocument("file1.ts", defaultCompilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), "1", false);

assert(f1 === f2, "DocumentRegistry should return the same document for the same name");
});
Expand All @@ -17,21 +17,21 @@ describe("DocumentRegistry", () => {

// change compilation setting that doesn't affect parsing - should have the same document
compilerOptions.declaration = true;
var f1 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), 1, false);
var f1 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), "1", false);
compilerOptions.declaration = false;
var f2 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), 1, false);
var f2 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), "1", false);

assert(f1 === f2, "Expected to have the same document instance");


// change value of compilation setting that is used during production of AST - new document is required
compilerOptions.target = ts.ScriptTarget.ES3;
var f3 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), 1, false);
var f3 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), "1", false);

assert(f1 !== f3, "Changed target: Expected to have different instances of document");

compilerOptions.module = ts.ModuleKind.CommonJS;
var f4 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), 1, false);
var f4 = documentRegistry.acquireDocument("file1.ts", compilerOptions, TypeScript.ScriptSnapshot.fromString("var x = 1;"), "1", false);

assert(f1 !== f4, "Changed module: Expected to have different instances of document");
});
Expand Down