diff --git a/.travis.yml b/.travis.yml index fe032c8..237649d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,20 @@ sudo: false os: - osx - linux - + before_install: - if [ $TRAVIS_OS_NAME == "linux" ]; then export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0; sh -e /etc/init.d/xvfb start; sleep 3; fi - + install: + - npm install mocha - npm install - npm run vscode:prepublish - + script: - npm test --silent + - npm run-script coverage +after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" diff --git a/.vscodeignore b/.vscodeignore index 91cb33b..58979d6 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -9,3 +9,4 @@ tsconfig.json vsc-extension-quickstart.md tslint.json misc/** +.travis.yml diff --git a/README.md b/README.md index e45fc34..99b65e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # XML Documentation Comments Support for Visual Studio Code [![Build Status](https://travis-ci.org/k--kato/docomment.svg?branch=master)](https://travis-ci.org/k--kato/docomment) +[![Coverage Status](https://coveralls.io/repos/k--kato/docomment/badge.svg?branch=master&service=github)](https://coveralls.io/github/k--kato/docomment?branch=master) [![License: MIT](http://img.shields.io/badge/license-MIT-orange.svg)](LICENSE) Generate XML documentation comments for Visual Studio Code. @@ -29,7 +30,7 @@ public int bb(string s, ref int y, void * z) ## Installation -1. Install Visual Studio Code 0.10.1 or higher +1. Install Visual Studio Code 0.10.6 or higher 1. Launch Code 1. From the command palette `Ctrl`-`Shift`-`P` (Windows, Linux) or `Cmd`-`Shift`-`P` (OSX) 1. Select `Install Extension` diff --git a/package.json b/package.json index 3772e23..2d61c23 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,10 @@ "devDependencies": { "typescript": "^1.6.2", "vscode": "0.10.x", - "tslint": "^3.2.1" + "tslint": "^3.2.1", + "istanbul": "^0.4.2", + "coveralls": "^2.11.6", + "mocha-lcov-reporter": "^1.0.0" }, "extensionDependencies": [ ], @@ -37,7 +40,8 @@ "scripts": { "vscode:prepublish": "node ./node_modules/vscode/bin/compile", "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", - "test": "node ./node_modules/vscode/bin/test" + "test": "node ./node_modules/vscode/bin/test", + "coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec --ui tdd ./out/test/**/*.js" }, "icon": "images/docomment.png", "license": "MIT", diff --git a/src/Controller/DocomentController.ts b/src/Controller/DocommentController.ts similarity index 96% rename from src/Controller/DocomentController.ts rename to src/Controller/DocommentController.ts index d5b693b..be8b7a9 100644 --- a/src/Controller/DocomentController.ts +++ b/src/Controller/DocommentController.ts @@ -2,7 +2,7 @@ import {window, workspace, Disposable, TextEditor, TextDocumentContentChangeEven import {IDocommentDomain} from '../Domain/IDocommentDomain'; import {IDocommentController} from './IDocommentController'; -export class DocomentController implements IDocommentController { +export class DocommentController implements IDocommentController { /*------------------------------------------------------------------------- * Field diff --git a/src/Controller/Lang/DocomentControllerCSharp.ts b/src/Controller/Lang/DocommentControllerCSharp.ts similarity index 65% rename from src/Controller/Lang/DocomentControllerCSharp.ts rename to src/Controller/Lang/DocommentControllerCSharp.ts index 791bca6..52b4c28 100644 --- a/src/Controller/Lang/DocomentControllerCSharp.ts +++ b/src/Controller/Lang/DocommentControllerCSharp.ts @@ -1,6 +1,6 @@ -import {DocomentController} from '../DocomentController'; +import {DocommentController} from '../DocommentController'; -export class DocomentControllerCSharp extends DocomentController { +export class DocommentControllerCSharp extends DocommentController { /*------------------------------------------------------------------------- * Field diff --git a/src/Utility/StringUtil.ts b/src/Utility/StringUtil.ts index 9388dd2..556f287 100644 --- a/src/Utility/StringUtil.ts +++ b/src/Utility/StringUtil.ts @@ -14,7 +14,7 @@ export class StringUtil { public static RemoveComment(line: string): string { if (line === null) return null; - return line.replace(/\/\/.*/, '').replace(/\/\*.*/, ''); + return line.replace(/\/\/.*/, '').replace(/\/\*.*\*\//, ''); } public static GetIndent(line: string): string { diff --git a/src/extension.ts b/src/extension.ts index 947a302..955dc42 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,11 +1,11 @@ import {ExtensionContext} from 'vscode'; import {DocommentDomainCSharp} from './Domain/Lang/DocommentDomainCSharp'; -import {DocomentControllerCSharp} from './Controller/Lang/DocomentControllerCSharp'; +import {DocommentControllerCSharp} from './Controller/Lang/DocommentControllerCSharp'; export function activate(context: ExtensionContext) { const domainCSharp = new DocommentDomainCSharp(); - const controllerCSharp = new DocomentControllerCSharp(domainCSharp); + const controllerCSharp = new DocommentControllerCSharp(domainCSharp); context.subscriptions.push(controllerCSharp); context.subscriptions.push(domainCSharp); diff --git a/test/Utility/StringUtil.test.ts b/test/Utility/StringUtil.test.ts new file mode 100644 index 0000000..0a85f9b --- /dev/null +++ b/test/Utility/StringUtil.test.ts @@ -0,0 +1,381 @@ +import * as assert from 'assert'; +import {StringUtil} from '../../src/Utility/StringUtil'; + +suite('Utility.StringUtil.IsNullOrWhiteSpace Tests', () => { + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsNullOrWhiteSpace + STATE : - + IN : null + OUT : true + `, () => { + // arrange + const code: string = null; + + // act + const actual: boolean = StringUtil.IsNullOrWhiteSpace(code); + + // assert + assert.equal(actual, true); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsNullOrWhiteSpace + STATE : - + IN : '' + OUT : true + `, () => { + // arrange + const code = ''; + + // act + const actual: boolean = StringUtil.IsNullOrWhiteSpace(code); + + // assert + assert.equal(actual, true); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsNullOrWhiteSpace + STATE : - + IN : ' ' + OUT : false + `, () => { + // arrange + const code = ' '; + + // act + const actual: boolean = StringUtil.IsNullOrWhiteSpace(code); + + // assert + assert.equal(actual, true); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsNullOrWhiteSpace + STATE : - + IN : 'foo' + OUT : false + `, () => { + // arrange + const code = 'foo'; + + // act + const actual: boolean = StringUtil.IsNullOrWhiteSpace(code); + + // assert + assert.equal(actual, false); + }); +}); + + + +suite('Utility.StringUtil.IsCodeBlockStart Tests', () => { + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsCodeBlockStart + STATE : - + IN : null + OUT : false + `, () => { + // arrange + const code: string = null; + + // act + const actual: boolean = StringUtil.IsCodeBlockStart(code); + + // assert + assert.equal(actual, false); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsCodeBlockStart + STATE : - + IN : '' + OUT : false + `, () => { + // arrange + const code = ''; + + // act + const actual: boolean = StringUtil.IsCodeBlockStart(code); + + // assert + assert.equal(actual, false); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsCodeBlockStart + STATE : - + IN : '{' + OUT : true + `, () => { + // arrange + const code = '{'; + + // act + const actual: boolean = StringUtil.IsCodeBlockStart(code); + + // assert + assert.equal(actual, true); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : IsCodeBlockStart + STATE : - + IN : ';' + OUT : true + `, () => { + // arrange + const code = ';'; + + // act + const actual: boolean = StringUtil.IsCodeBlockStart(code); + + // assert + assert.equal(actual, true); + }); +}); + + + +suite('Utility.StringUtil.RemoveComment Tests', () => { + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : null + OUT : null + `, () => { + // arrange + const code: string = null; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, null); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : '' + OUT : '' + `, () => { + // arrange + const code = ''; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, ''); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : '/*foo*/' + OUT : '' + `, () => { + // arrange + const code = '/*foo*/'; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, ''); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : 'bar/*foo*/fuga' + OUT : 'barfuga' + `, () => { + // arrange + const code = 'bar/*foo*/fuga'; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, 'barfuga'); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : '/*foo' + OUT : '/*foo' + `, () => { + // arrange + const code = '/*foo'; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, '/*foo'); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : '//foo' + OUT : '' + `, () => { + // arrange + const code = '//foo'; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, ''); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : 'bar//foo' + OUT : '' + `, () => { + // arrange + const code = 'bar//foo'; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, 'bar'); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : RemoveComment + STATE : - + IN : '/*bar*/ //foo' + OUT : ' ' + `, () => { + // arrange + const code = '/*bar*/ //foo'; + + // act + const actual: string = StringUtil.RemoveComment(code); + + // assert + assert.equal(actual, ' '); + }); +}); + + + +suite('Utility.StringUtil.GetIndent Tests', () => { + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : GetIndent + STATE : - + IN : null + OUT : null + `, () => { + // arrange + const code: string = null; + + // act + const actual: string = StringUtil.GetIndent(code); + + // assert + assert.equal(actual, null); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : GetIndent + STATE : - + IN : '' + OUT : '' + `, () => { + // arrange + const code = ''; + + // act + const actual: string = StringUtil.GetIndent(code); + + // assert + assert.equal(actual, ''); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : GetIndent + STATE : - + IN : ' foo ' + OUT : ' ' + `, () => { + // arrange + const code = ' foo '; + + // act + const actual: string = StringUtil.GetIndent(code); + + // assert + assert.equal(actual, ' '); + }); + + test(` + Category: Black-box testing + Class : Utility.StringUtil + Method : GetIndent + STATE : - + IN : ' foo ' + OUT : ' ' + `, () => { + // arrange + const code = ' foo '; + + // act + const actual: string = StringUtil.GetIndent(code); + + // assert + assert.equal(actual, ' '); + }); + +}); diff --git a/test/extension.test.ts b/test/extension.test.ts deleted file mode 100644 index cf47b2c..0000000 --- a/test/extension.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -// -// Note: This example test is leveraging the Mocha test framework. -// Please refer to their documentation on https://mochajs.org/ for help. -// - -// The module 'assert' provides assertion methods from node -import * as assert from 'assert'; - -// You can import and use all API from the 'vscode' module -// as well as import your extension to test it -import * as vscode from 'vscode'; -import * as myExtension from '../src/extension'; - -// Defines a Mocha test suite to group tests of similar kind together -suite("Extension Tests", () => { - - // Defines a Mocha unit test - test("Something 1", () => { - assert.equal(-1, [1, 2, 3].indexOf(5)); - assert.equal(-1, [1, 2, 3].indexOf(0)); - }); -}); \ No newline at end of file diff --git a/test/tslint.json b/test/tslint.json new file mode 100644 index 0000000..4dc6555 --- /dev/null +++ b/test/tslint.json @@ -0,0 +1,71 @@ +{ + "rules": { + "class-name": true, + "comment-format": [true, "check-space"], + "curly": false, + "eofline": true, + "forin": true, + "indent": [true, "spaces"], + "label-position": true, + "label-undefined": true, + "max-line-length": [true, 200], + "member-access": true, + "member-ordering": [true, + "public-before-private", + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-key": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-inferrable-types": true, + "no-shadowed-variable": true, + "no-string-literal": true, + "no-switch-case-fall-through": true, + "no-trailing-comma": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-unreachable": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": true, + "one-line": [true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [true, "single"], + "radix": true, + "semicolon": true, + "triple-equals": [true, "allow-null-check"], + "typedef-whitespace": [true, { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }], + "variable-name": false, + "whitespace": [true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} \ No newline at end of file