Skip to content

Commit 4bbf4eb

Browse files
author
Keisuke KATO
committed
Merge pull request #2 from k--kato/add/test
add test template
2 parents d4592a9 + 06a2c17 commit 4bbf4eb

File tree

12 files changed

+277
-19
lines changed

12 files changed

+277
-19
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
out
22
node_modules
3-
*.vsix
3+
*.vsix
4+
coverage
5+
.vscode-test

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ before_install:
1212
fi
1313

1414
install:
15-
- npm install mocha
1615
- npm install
1716
- npm run vscode:prepublish
1817

1918
script:
2019
- npm test --silent
21-
- npm run-script coverage
20+
- npm run-script coverage_travis
2221
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"

.vscode/tasks.json

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,55 @@
88

99
// A task runner that calls a custom npm script that compiles the extension.
1010
{
11-
"version": "0.1.0",
11+
"version": "0.1.0",
1212

13-
// we want to run npm
14-
"command": "npm",
13+
// we want to run npm
14+
"command": "npm",
1515

16-
// the command is a shell script
17-
"isShellCommand": true,
16+
// the command is a shell script
17+
"isShellCommand": true,
1818

19-
// show the output window only if unrecognized errors occur.
20-
"showOutput": "silent",
19+
// show the output window only if unrecognized errors occur.
20+
"showOutput": "always",
2121

22-
// we run the custom script "compile" as defined in package.json
23-
"args": ["run", "compile", "--loglevel", "silent"],
22+
"args": ["run"],
23+
24+
"tasks": [
25+
{
26+
"taskName": "npm"
27+
},
28+
{
29+
"taskName": "build",
30+
"suppressTaskName": true,
2431

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

28-
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
29-
"problemMatcher": "$tsc-watch"
35+
// The tsc compiler is started in watching mode
36+
"isWatching": true,
37+
38+
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
39+
"problemMatcher": "$tsc"
40+
},
41+
{
42+
"taskName": "watch",
43+
"suppressTaskName": true,
44+
45+
// we run the custom script "watch" as defined in package.json
46+
"args": ["watch", "--loglevel", "silent"],
47+
48+
// The tsc compiler is started in watching mode
49+
"isWatching": true,
50+
51+
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
52+
"problemMatcher": "$tsc-watch"
53+
},
54+
{
55+
"taskName": "test",
56+
"suppressTaskName": true,
57+
58+
// we run the custom script "coverage" as defined in package.json
59+
"args": ["coverage"]
60+
}
61+
]
3062
}

.vscodeignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ vsc-extension-quickstart.md
1010
tslint.json
1111
misc/**
1212
.travis.yml
13+
coverage/**
14+
.vscode-test/**

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docomment",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"publisher": "k--kato",
55
"engines": {
66
"vscode": "^0.10.6"
@@ -32,16 +32,19 @@
3232
"tslint": "^3.2.1",
3333
"istanbul": "^0.4.2",
3434
"coveralls": "^2.11.6",
35+
"mocha": "^2.3.4",
3536
"mocha-lcov-reporter": "^1.0.0"
3637
},
3738
"extensionDependencies": [
3839
],
3940
"isAMD": false,
4041
"scripts": {
4142
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
42-
"compile": "node ./node_modules/vscode/bin/compile -watch -p ./",
43+
"compile": "node ./node_modules/vscode/bin/compile -p ./",
44+
"watch": "node ./node_modules/vscode/bin/compile -watch -p ./",
4345
"test": "node ./node_modules/vscode/bin/test",
44-
"coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec --ui tdd ./out/test/**/*.js"
46+
"coverage_travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec --ui tdd ./out/test/**/*.js",
47+
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec --ui tdd ./out/test/**/*.js"
4548
},
4649
"icon": "images/docomment.png",
4750
"license": "MIT",

src/SyntacticAnalysis/SyntacticAnalysisCSharp.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,58 @@ export class SyntacticAnalysisCSharp {
1111
* Public Method
1212
*-----------------------------------------------------------------------*/
1313
public static IsNamespace(code: string): boolean {
14+
if (code === null) return false;
1415
return code.match(/\bnamespace\b/) !== null;
1516
}
1617

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

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

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

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

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

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

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

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

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

5363

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

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

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

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

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

8396
const isMatched = (returns === null || returns.length !== 2);

test/Api/VSCodeApi.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
suite('Api.VSCodeApi Tests', () => {
2+
// NOP
3+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
suite('Controller.DocommentController Tests', () => {
2+
// NOP
3+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
suite('Controller.Lang.DocommentControllerCSharp Tests', () => {
2+
// NOP
3+
});

test/Domain/DocommentDomain.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
suite('Domain.DocommentDomain Tests', () => {
2+
// NOP
3+
});

0 commit comments

Comments
 (0)