Skip to content

Commit

Permalink
Merge pull request #2 from k--kato/add/test
Browse files Browse the repository at this point in the history
add test template
  • Loading branch information
Keisuke KATO committed Jan 14, 2016
2 parents d4592a9 + 06a2c17 commit 4bbf4eb
Show file tree
Hide file tree
Showing 12 changed files with 277 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
out
node_modules
*.vsix
*.vsix
coverage
.vscode-test
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ before_install:
fi

install:
- npm install mocha
- npm install
- npm run vscode:prepublish

script:
- npm test --silent
- npm run-script coverage
- npm run-script coverage_travis
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
58 changes: 45 additions & 13 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,55 @@

// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
"version": "0.1.0",

// we want to run npm
"command": "npm",
// we want to run npm
"command": "npm",

// the command is a shell script
"isShellCommand": true,
// the command is a shell script
"isShellCommand": true,

// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// show the output window only if unrecognized errors occur.
"showOutput": "always",

// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],
"args": ["run"],

"tasks": [
{
"taskName": "npm"
},
{
"taskName": "build",
"suppressTaskName": true,

// The tsc compiler is started in watching mode
"isWatching": true,
// we run the custom script "compile" as defined in package.json
"args": ["compile"],

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
// The tsc compiler is started in watching mode
"isWatching": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc"
},
{
"taskName": "watch",
"suppressTaskName": true,

// we run the custom script "watch" as defined in package.json
"args": ["watch", "--loglevel", "silent"],

// The tsc compiler is started in watching mode
"isWatching": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
},
{
"taskName": "test",
"suppressTaskName": true,

// we run the custom script "coverage" as defined in package.json
"args": ["coverage"]
}
]
}
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ vsc-extension-quickstart.md
tslint.json
misc/**
.travis.yml
coverage/**
.vscode-test/**
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docomment",
"version": "0.0.1",
"version": "0.0.2",
"publisher": "k--kato",
"engines": {
"vscode": "^0.10.6"
Expand Down Expand Up @@ -32,16 +32,19 @@
"tslint": "^3.2.1",
"istanbul": "^0.4.2",
"coveralls": "^2.11.6",
"mocha": "^2.3.4",
"mocha-lcov-reporter": "^1.0.0"
},
"extensionDependencies": [
],
"isAMD": false,
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
"compile": "node ./node_modules/vscode/bin/compile -p ./",
"watch": "node ./node_modules/vscode/bin/compile -watch -p ./",
"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"
"coverage_travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec --ui tdd ./out/test/**/*.js",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec --ui tdd ./out/test/**/*.js"
},
"icon": "images/docomment.png",
"license": "MIT",
Expand Down
13 changes: 13 additions & 0 deletions src/SyntacticAnalysis/SyntacticAnalysisCSharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,58 @@ export class SyntacticAnalysisCSharp {
* Public Method
*-----------------------------------------------------------------------*/
public static IsNamespace(code: string): boolean {
if (code === null) return false;
return code.match(/\bnamespace\b/) !== null;
}

public static IsClass(code: string): boolean {
if (code === null) return false;
return code.match(/\bclass\b/) !== null;
}

public static IsInterface(code: string): boolean {
if (code === null) return false;
return code.match(/\binterface\b/) !== null;
}

public static IsStruct(code: string): boolean {
if (code === null) return false;
return code.match(/\bstruct\b/) !== null;
}

public static IsEnum(code: string): boolean {
if (code === null) return false;
return code.match(/\benum\b/) !== null;
}

public static IsDelegate(code: string): boolean {
if (code === null) return false;
return code.match(/\bdelegate\b/) !== null;
}

public static IsEvent(code: string): boolean {
if (code === null) return false;
return code.match(/\bevent\b/) !== null;
}

public static IsProperty(code: string): boolean {
if (code === null) return false;
return code.match(/[\w\S]+[^)]?\b\s*{/) !== null;
}

public static IsField(code: string): boolean {
if (code === null) return false;
return code.match(/;[ \t]*$/) !== null;
}

public static IsMethod(code: string): boolean {
if (code === null) return false;
return code.match(/[\w\S]\s+[\w\S]+\s*\(.*\)/) !== null;
}


public static GetMethodParamNameList(code: string): Array<string> {
if (code === null) return null;
const params: RegExpMatchArray = code.match(/[\w\S]\s+[\w\S]+\s*\((.*)\)/);

const isMatched = (params === null || params.length !== 2);
Expand All @@ -69,6 +80,7 @@ export class SyntacticAnalysisCSharp {
}

public static HasMethodReturn(code: string): boolean {
if (code === null) return false;
const returns: RegExpMatchArray = code.match(/([\w\S]+)\s+[\w\S]+\s*\(.*\)/);

const isMatched = (returns === null || returns.length !== 2);
Expand All @@ -78,6 +90,7 @@ export class SyntacticAnalysisCSharp {
}

public static HasPropertyReturn(code: string): boolean {
if (code === null) return false;
const returns: RegExpMatchArray = code.match(/([\w\S]+)\s+[\w\S]+\s*\{/);

const isMatched = (returns === null || returns.length !== 2);
Expand Down
3 changes: 3 additions & 0 deletions test/Api/VSCodeApi.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
suite('Api.VSCodeApi Tests', () => {
// NOP
});
3 changes: 3 additions & 0 deletions test/Controller/DocommentController.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
suite('Controller.DocommentController Tests', () => {
// NOP
});
3 changes: 3 additions & 0 deletions test/Controller/Lang/DocommentControllerCSharp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
suite('Controller.Lang.DocommentControllerCSharp Tests', () => {
// NOP
});
3 changes: 3 additions & 0 deletions test/Domain/DocommentDomain.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
suite('Domain.DocommentDomain Tests', () => {
// NOP
});
3 changes: 3 additions & 0 deletions test/Domain/Lang/DocommentDomainCSharp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
suite('Domain.DocommentDomainCSharp Tests', () => {
// NOP
});
Loading

0 comments on commit 4bbf4eb

Please sign in to comment.