Skip to content

Commit 8dfc898

Browse files
committed
rename to 'examplejs'
1 parent 7f1574b commit 8dfc898

10 files changed

+125
-125
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jtests",
3-
"version": "0.0.5",
3+
"version": "0.0.7",
44
"homepage": "https://github.com/zswang/jtests",
55
"authors": {
66
"name": "zswang",

jtests.js renamed to examplejs.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,63 @@
22
/* global exports */
33
var exports = exports || {};
44
/**
5-
* @file jtests
5+
* @file examplejs
66
*
77
* test case builder
88
* @author
99
* zswang (http://weibo.com/zswang)
10-
* @version 0.0.5
10+
* @version 0.0.7
1111
* @date 2016-05-16
1212
*/
1313
/**
1414
* @example build():content empty
1515
```js
16-
var text = jtests.build('');
16+
var text = examplejs.build('');
1717
console.log(text.length);
1818
// > 0
1919
```
2020
* @example build():example empty
2121
```js
22-
var text = jtests.build('space', {});
22+
var text = examplejs.build('space', {});
2323
console.log(text.length);
2424
// > 0
2525
```
2626
* @example build():console.log(1)
2727
```js
28-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`');
29-
console.log(/jtests_print\(1\);/.test(text));
28+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`');
29+
console.log(/examplejs_print\(1\);/.test(text));
3030
// > true
3131
```
3232
* @example build():options.timeout
3333
```js
34-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`', {
34+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`', {
3535
timeout: 1234
3636
});
3737
console.log(/this.timeout\(1234\);/.test(text));
3838
// > true
3939
```
4040
* @example build():done
4141
```js
42-
var text = jtests.build('@example\n\`\`\`js\nsetTimeout(function() {console.log(1);\n// > 1\n// \* done\n},500)\`\`\`');
42+
var text = examplejs.build('@example\n\`\`\`js\nsetTimeout(function() {console.log(1);\n// > 1\n// \* done\n},500)\`\`\`');
4343
console.log(/\(done\)/.test(text));
4444
// > true
4545
```
4646
* @example build():throw
4747
```js
48-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`');
48+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`');
4949
console.log(/throw\(\);/.test(text));
5050
// > true
5151
```
5252
* @example build():options.header
5353
```js
54-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`', {
54+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`', {
5555
header: 'var url = require(\'url\');'
5656
});
5757
console.log(text.indexOf('var url = require(\'url\');'));
5858
// > 0
5959
```
6060
*/
61-
function jtests_build(content, options) {
61+
function examplejs_build(content, options) {
6262
if (!content) {
6363
return content;
6464
}
@@ -70,14 +70,14 @@
7070
var hasThrows = code.indexOf('// * throw') >= 0;
7171
it = it || 'none';
7272
exampleCode += '\n it(' + JSON.stringify(it) + ', function(' + (hasDone ? 'done' : '') + ') {';
73-
exampleCode += '\n jtests_printLines = [];\n';
73+
exampleCode += '\n examplejs_printLines = [];\n';
7474
code = code.replace(/^(\s*\/\/ > .*\n??)+/mg,
7575
function(all) {
7676
var space = all.match(/^(\s*)\/\/ > /)[1];
7777
var output = all.replace(/^\s*\/\/ > /mg, '');
78-
return space + 'assert.equal(jtests_printLines.join("\\n"), ' + JSON.stringify(output) + '); jtests_printLines = [];';
78+
return space + 'assert.equal(examplejs_printLines.join("\\n"), ' + JSON.stringify(output) + '); examplejs_printLines = [];';
7979
}
80-
).replace(/console\.log/g, 'jtests_print');
80+
).replace(/console\.log/g, 'examplejs_print');
8181
if (hasDone) {
8282
code = code.replace('// * done', 'done();');
8383
}
@@ -100,9 +100,9 @@
100100
'describe("' + (options.desc || 'none') + '", function () {',
101101
' var assert = require(\'should\');',
102102
' var util = require(\'util\');',
103-
' var jtests_printLines;',
104-
' function jtests_print() {',
105-
' jtests_printLines.push(util.format.apply(util, arguments));',
103+
' var examplejs_printLines;',
104+
' function examplejs_print() {',
105+
' examplejs_printLines.push(util.format.apply(util, arguments));',
106106
' }'
107107
);
108108
if (options.timeout) {
@@ -112,7 +112,7 @@
112112
lines.push('});');
113113
return lines.join('\n');
114114
}
115-
exports.build = jtests_build;
115+
exports.build = examplejs_build;
116116
if (typeof define === 'function') {
117117
if (define.amd) {
118118
define(function() {
@@ -124,4 +124,4 @@
124124
} else {
125125
window[exportName] = exports;
126126
}
127-
})('jtests');
127+
})('examplejs');

examplejs.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var jtests = require('../');
1+
var examplejs = require('../');

jtests.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "jtests",
3-
"version": "0.0.5",
2+
"name": "examplejs",
3+
"version": "0.0.7",
44
"description": "test case builder",
5-
"main": "jtests.js",
5+
"main": "examplejs.js",
66
"scripts": {
77
"_update_version": "jdists version.jdists",
8-
"_dist": "jdists src/jtests.js -o jtests.js -r debug,test,remove,safe",
9-
"_compress": "uglifyjs jtests.js -o jtests.min.js -p 5 -c -m",
10-
"example": "node cli README.md -o test/readme.js -t 3000 && node cli src/jtests.js -o test/jtests.js -h head.js",
8+
"_dist": "jdists src/examplejs.js -o examplejs.js -r debug,test,remove,safe",
9+
"_compress": "uglifyjs examplejs.js -o examplejs.min.js -p 5 -c -m",
10+
"example": "node cli README.md -o test/readme.js -t 3000 && node cli src/examplejs.js -o test/examplejs.js -h head.js",
1111
"test": "istanbul cover --hook-run-in-context node_modules/mocha/bin/_mocha -- -R spec",
1212
"mocha": "npm run example && mocha",
1313
"dist": "npm run _update_version && npm run example && npm run _dist && npm run _compress && npm run test",
1414
"lint": "jshint src/*.js *.json"
1515
},
16-
"homepage": "https://github.com/zswang/jtests",
16+
"homepage": "https://github.com/zswang/examplejs",
1717
"author": {
1818
"name": "zswang",
1919
"url": "http://weibo.com/zswang"
2020
},
21-
"repository": "https://github.com/zswang/jtests.git",
21+
"repository": "https://github.com/zswang/examplejs.git",
2222
"license": "MIT",
2323
"dependencies": {
2424
"mkdirp": "^0.5.0",
@@ -34,6 +34,6 @@
3434
"jshint": "^2.5.8"
3535
},
3636
"bin": {
37-
"jtests": "cli.js"
37+
"examplejs": "cli.js"
3838
}
3939
}

src/jtests.js renamed to src/examplejs.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,53 +29,53 @@
2929
/**
3030
* @example build():content empty
3131
```js
32-
var text = jtests.build('');
32+
var text = examplejs.build('');
3333
console.log(text.length);
3434
// > 0
3535
```
3636
* @example build():example empty
3737
```js
38-
var text = jtests.build('space', {});
38+
var text = examplejs.build('space', {});
3939
console.log(text.length);
4040
// > 0
4141
```
4242
* @example build():console.log(1)
4343
```js
44-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`');
45-
console.log(/jtests_print\(1\);/.test(text));
44+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`');
45+
console.log(/examplejs_print\(1\);/.test(text));
4646
// > true
4747
```
4848
* @example build():options.timeout
4949
```js
50-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`', {
50+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(1);\n// > 1\n\`\`\`', {
5151
timeout: 1234
5252
});
5353
console.log(/this.timeout\(1234\);/.test(text));
5454
// > true
5555
```
5656
* @example build():done
5757
```js
58-
var text = jtests.build('@example\n\`\`\`js\nsetTimeout(function() {console.log(1);\n// > 1\n// \* done\n},500)\`\`\`');
58+
var text = examplejs.build('@example\n\`\`\`js\nsetTimeout(function() {console.log(1);\n// > 1\n// \* done\n},500)\`\`\`');
5959
console.log(/\(done\)/.test(text));
6060
// > true
6161
```
6262
* @example build():throw
6363
```js
64-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`');
64+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`');
6565
console.log(/throw\(\);/.test(text));
6666
// > true
6767
```
6868
* @example build():options.header
6969
```js
70-
var text = jtests.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`', {
70+
var text = examplejs.build('@example\n\`\`\`js\nconsole.log(xyz);\n// \* throw\n\`\`\`', {
7171
header: 'var url = require(\'url\');'
7272
});
7373
console.log(text.indexOf('var url = require(\'url\');'));
7474
// > 0
7575
```
7676
*/
7777

78-
function jtests_build(content, options) {
78+
function examplejs_build(content, options) {
7979
if (!content) {
8080
return content;
8181
}
@@ -88,15 +88,15 @@
8888
var hasThrows = code.indexOf('// * throw') >= 0;
8989
it = it || 'none';
9090
exampleCode += '\n it(' + JSON.stringify(it) + ', function(' + (hasDone ? 'done' : '') + ') {';
91-
exampleCode += '\n jtests_printLines = [];\n';
91+
exampleCode += '\n examplejs_printLines = [];\n';
9292

9393
code = code.replace(/^(\s*\/\/ > .*\n??)+/mg,
9494
function(all) {
9595
var space = all.match(/^(\s*)\/\/ > /)[1];
9696
var output = all.replace(/^\s*\/\/ > /mg, '');
97-
return space + 'assert.equal(jtests_printLines.join("\\n"), ' + JSON.stringify(output) + '); jtests_printLines = [];';
97+
return space + 'assert.equal(examplejs_printLines.join("\\n"), ' + JSON.stringify(output) + '); examplejs_printLines = [];';
9898
}
99-
).replace(/console\.log/g, 'jtests_print');
99+
).replace(/console\.log/g, 'examplejs_print');
100100

101101
if (hasDone) {
102102
code = code.replace('// * done', 'done();');
@@ -121,9 +121,9 @@
121121
'describe("' + (options.desc || 'none') + '", function () {',
122122
' var assert = require(\'should\');',
123123
' var util = require(\'util\');',
124-
' var jtests_printLines;',
125-
' function jtests_print() {',
126-
' jtests_printLines.push(util.format.apply(util, arguments));',
124+
' var examplejs_printLines;',
125+
' function examplejs_print() {',
126+
' examplejs_printLines.push(util.format.apply(util, arguments));',
127127
' }'
128128
);
129129
if (options.timeout) {
@@ -133,7 +133,7 @@
133133
lines.push('});');
134134
return lines.join('\n');
135135
}
136-
exports.build = jtests_build;
136+
exports.build = examplejs_build;
137137

138138
if (typeof define === 'function') {
139139
if (define.amd) {
@@ -146,4 +146,4 @@
146146
} else {
147147
window[exportName] = exports;
148148
}
149-
})('jtests');
149+
})('examplejs');

test/examplejs.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
var examplejs = require('../');
2+
describe("src/examplejs.js", function () {
3+
var assert = require('should');
4+
var util = require('util');
5+
var examplejs_printLines;
6+
function examplejs_print() {
7+
examplejs_printLines.push(util.format.apply(util, arguments));
8+
}
9+
10+
it("build():content empty", function() {
11+
examplejs_printLines = [];
12+
var text = examplejs.build('');
13+
examplejs_print(text.length);
14+
assert.equal(examplejs_printLines.join("\n"), "0"); examplejs_printLines = [];
15+
});
16+
it("build():example empty", function() {
17+
examplejs_printLines = [];
18+
var text = examplejs.build('space', {});
19+
examplejs_print(text.length);
20+
assert.equal(examplejs_printLines.join("\n"), "0"); examplejs_printLines = [];
21+
});
22+
it("build():console.log(1)", function() {
23+
examplejs_printLines = [];
24+
var text = examplejs.build('@example\n\`\`\`js\nexamplejs_print(1);\n// > 1\n\`\`\`');
25+
examplejs_print(/examplejs_print\(1\);/.test(text));
26+
assert.equal(examplejs_printLines.join("\n"), "true"); examplejs_printLines = [];
27+
});
28+
it("build():options.timeout", function() {
29+
examplejs_printLines = [];
30+
var text = examplejs.build('@example\n\`\`\`js\nexamplejs_print(1);\n// > 1\n\`\`\`', {
31+
timeout: 1234
32+
});
33+
examplejs_print(/this.timeout\(1234\);/.test(text));
34+
assert.equal(examplejs_printLines.join("\n"), "true"); examplejs_printLines = [];
35+
});
36+
it("build():done", function() {
37+
examplejs_printLines = [];
38+
var text = examplejs.build('@example\n\`\`\`js\nsetTimeout(function() {examplejs_print(1);\n// > 1\n// \* done\n},500)\`\`\`');
39+
examplejs_print(/\(done\)/.test(text));
40+
assert.equal(examplejs_printLines.join("\n"), "true"); examplejs_printLines = [];
41+
});
42+
it("build():throw", function() {
43+
examplejs_printLines = [];
44+
var text = examplejs.build('@example\n\`\`\`js\nexamplejs_print(xyz);\n// \* throw\n\`\`\`');
45+
examplejs_print(/throw\(\);/.test(text));
46+
assert.equal(examplejs_printLines.join("\n"), "true"); examplejs_printLines = [];
47+
});
48+
it("build():options.header", function() {
49+
examplejs_printLines = [];
50+
var text = examplejs.build('@example\n\`\`\`js\nexamplejs_print(xyz);\n// \* throw\n\`\`\`', {
51+
header: 'var url = require(\'url\');'
52+
});
53+
examplejs_print(text.indexOf('var url = require(\'url\');'));
54+
assert.equal(examplejs_printLines.join("\n"), "0"); examplejs_printLines = [];
55+
});
56+
});
57+
58+

0 commit comments

Comments
 (0)