From 3ef2167caf0233c45764d08d598334fd474b4f03 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Tue, 16 Oct 2018 13:44:50 -0700 Subject: [PATCH] Revert "Fix test errors" This reverts commit e277a138baf6d505508a25dcd0235cfb25636860. --- test/go.test.ts | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/test/go.test.ts b/test/go.test.ts index bc2d5093d..2f5f3c68e 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -15,6 +15,7 @@ import { getWorkspaceSymbols } from '../src/goSymbol'; import { check } from '../src/goCheck'; import cp = require('child_process'); import { getEditsFromUnifiedDiffStr, getEdits } from '../src/diffUtils'; +import jsDiff = require('diff'); import { testCurrentFile } from '../src/goTest'; import { getBinPath, getGoVersion, isVendorSupported } from '../src/util'; import { documentSymbols, GoDocumentSymbolProvider, GoOutlineImportsOptions } from '../src/goOutline'; @@ -23,7 +24,9 @@ import { generateTestCurrentFile, generateTestCurrentFunction, generateTestCurre import { getAllPackages } from '../src/goPackages'; import { getImportPath } from '../src/util'; import { goPlay } from '../src/goPlayground'; +import { goLint } from '../src/goLint'; import { runFillStruct } from '../src/goFillStruct'; +import { print } from 'util'; suite('Go Extension Tests', () => { let gopath = process.env['GOPATH']; @@ -800,8 +803,7 @@ It returns the number of bytes written and any write error encountered. vscode.workspace.openTextDocument(uri).then((textDocument) => { return vscode.window.showTextDocument(textDocument).then(editor => { let promises = testCases.map(([position, expected]) => - provider.provideCompletionItems(editor.document, position, null).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + provider.provideCompletionItems(editor.document, position, null).then(items => { let labels = items.map(x => x.label); for (let entry of expected) { if (labels.indexOf(entry) < 0) { @@ -830,45 +832,38 @@ It returns the number of bytes written and any write error encountered. vscode.workspace.openTextDocument(uri).then((textDocument) => { return vscode.window.showTextDocument(textDocument).then(editor => { - let noFunctionSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(9, 6), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: false } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let noFunctionSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(9, 6), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: false } })).then(items => { let item = items.find(x => x.label === 'Print'); assert.equal(!item.insertText, true); }); - let withFunctionSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(9, 6), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let withFunctionSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(9, 6), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(items => { let item = items.find(x => x.label === 'Print'); assert.equal((item.insertText).value, 'Print(${1:a ...interface{\\}})'); }); - let withFunctionSnippetNotype = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(9, 6), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggestWithoutType': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let withFunctionSnippetNotype = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(9, 6), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggestWithoutType': { value: true } })).then(items => { let item = items.find(x => x.label === 'Print'); assert.equal((item.insertText).value, 'Print(${1:a})'); }); - let noFunctionAsVarSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(11, 3), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: false } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let noFunctionAsVarSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(11, 3), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: false } })).then(items => { let item = items.find(x => x.label === 'funcAsVariable'); assert.equal(!item.insertText, true); }); - let withFunctionAsVarSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(11, 3), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let withFunctionAsVarSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(11, 3), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(items => { let item = items.find(x => x.label === 'funcAsVariable'); assert.equal((item.insertText).value, 'funcAsVariable(${1:k string})'); }); - let withFunctionAsVarSnippetNoType = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(11, 3), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggestWithoutType': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let withFunctionAsVarSnippetNoType = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(11, 3), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggestWithoutType': { value: true } })).then(items => { let item = items.find(x => x.label === 'funcAsVariable'); assert.equal((item.insertText).value, 'funcAsVariable(${1:k})'); }); - let noFunctionAsTypeSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(14, 0), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: false } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let noFunctionAsTypeSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(14, 0), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: false } })).then(items => { let item1 = items.find(x => x.label === 'HandlerFunc'); let item2 = items.find(x => x.label === 'HandlerFuncWithArgNames'); let item3 = items.find(x => x.label === 'HandlerFuncNoReturnType'); @@ -877,8 +872,7 @@ It returns the number of bytes written and any write error encountered. assert.equal(!item3.insertText, true); }); - let withFunctionAsTypeSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(14, 0), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let withFunctionAsTypeSnippet = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(14, 0), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(items => { let item1 = items.find(x => x.label === 'HandlerFunc'); let item2 = items.find(x => x.label === 'HandlerFuncWithArgNames'); let item3 = items.find(x => x.label === 'HandlerFuncNoReturnType'); @@ -904,20 +898,17 @@ It returns the number of bytes written and any write error encountered. vscode.workspace.openTextDocument(uri).then((textDocument) => { return vscode.window.showTextDocument(textDocument).then(editor => { - let symbolFollowedByBrackets = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(5, 10), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let symbolFollowedByBrackets = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(5, 10), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(items => { let item = items.find(x => x.label === 'Print'); assert.equal(!item.insertText, true, 'Unexpected snippet when symbol is followed by ().'); }); - let symbolAsLastParameter = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(7, 13), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let symbolAsLastParameter = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(7, 13), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(items => { let item = items.find(x => x.label === 'funcAsVariable'); assert.equal(!item.insertText, true, 'Unexpected snippet when symbol is a parameter inside func call'); }); - let symbolsAsNonLastParameter = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(8, 11), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + let symbolsAsNonLastParameter = provider.provideCompletionItemsInternal(editor.document, new vscode.Position(8, 11), null, Object.create(baseConfig, { 'useCodeSnippetsOnFunctionSuggest': { value: true } })).then(items => { let item = items.find(x => x.label === 'funcAsVariable'); assert.equal(!item.insertText, true, 'Unexpected snippet when symbol is one of the parameters inside func call.'); }); @@ -944,8 +935,7 @@ It returns the number of bytes written and any write error encountered. vscode.workspace.openTextDocument(uri).then((textDocument) => { return vscode.window.showTextDocument(textDocument).then(editor => { let promises = testCases.map(([position, expected]) => - provider.provideCompletionItemsInternal(editor.document, position, null, config).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + provider.provideCompletionItemsInternal(editor.document, position, null, config).then(items => { let labels = items.map(x => x.label); for (let entry of expected) { assert.equal(labels.indexOf(entry) > -1, true, `missing expected item in completion list: ${entry} Actual: ${labels}`); @@ -976,8 +966,7 @@ It returns the number of bytes written and any write error encountered. let uri = vscode.Uri.file(path.join(fixturePath, 'completions', 'unimportedMultiplePkgs.go')); vscode.workspace.openTextDocument(uri).then((textDocument) => { return vscode.window.showTextDocument(textDocument).then(editor => { - return provider.provideCompletionItemsInternal(editor.document, position, null, config).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + return provider.provideCompletionItemsInternal(editor.document, position, null, config).then(items => { let labels = items.map(x => x.label); expectedItems.forEach(expectedItem => { const actualItem: vscode.CompletionItem = items.filter(item => item.label === expectedItem.label)[0]; @@ -1013,8 +1002,7 @@ It returns the number of bytes written and any write error encountered. vscode.workspace.openTextDocument(uri).then((textDocument) => { return vscode.window.showTextDocument(textDocument).then(editor => { let promises = testCases.map(([position, expected]) => - provider.provideCompletionItems(editor.document, position, null).then(result => { - const items: vscode.CompletionItem[] = Array.isArray(result) ? result : result.items; + provider.provideCompletionItems(editor.document, position, null).then(items => { let labels = items.map(x => x.label); assert.equal(expected.length, labels.length, `expected number of completions: ${expected.length} Actual: ${labels.length} at position(${position.line},${position.character}) ${labels}`); expected.forEach((entry, index) => {