@jdeighan/coffee-utils 4.0.23 → 4.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.save/{block.test.cielo → block.test.coffee} +0 -0
- package/.save/block.test.js +129 -0
- package/.save/{block2.test.cielo → block2.test.coffee} +0 -0
- package/.save/block2.test.js +64 -0
- package/.save/{debug.test.cielo → debug.test.coffee} +4 -2
- package/.save/debug.test.js +242 -0
- package/.save/{fs.test.cielo → fs.test.coffee} +18 -2
- package/.save/fs.test.js +191 -0
- package/.save/{indent.test.cielo → indent.test.coffee} +0 -0
- package/.save/indent.test.js +136 -0
- package/.save/{log.test.cielo → log.test.coffee} +10 -6
- package/.save/log.test.js +336 -0
- package/.save/{privenv.test.cielo → privenv.test.coffee} +0 -0
- package/.save/privenv.test.js +54 -0
- package/.save/{temp.cielo → temp.coffee} +0 -0
- package/.save/temp.js +28 -0
- package/.save/{tester.test.cielo → tester.test.coffee} +0 -0
- package/.save/tester.test.js +93 -0
- package/.save/{utils.test.cielo → utils.test.coffee} +0 -0
- package/.save/utils.test.js +319 -0
- package/package.json +6 -5
- package/src/UnitTester.coffee +10 -6
- package/src/UnitTester.js +7 -1
- package/src/coffee_utils.coffee +5 -3
- package/src/coffee_utils.js +7 -3
- package/src/debug_utils.coffee +28 -7
- package/src/debug_utils.js +28 -8
- package/src/log_utils.coffee +28 -12
- package/src/log_utils.js +31 -13
- package/.save/bs.test.cielo +0 -6
@@ -0,0 +1,136 @@
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
2
|
+
// indent.test.coffee
|
3
|
+
var simple;
|
4
|
+
|
5
|
+
import assert from 'assert';
|
6
|
+
|
7
|
+
import {
|
8
|
+
UnitTester
|
9
|
+
} from '@jdeighan/coffee-utils/test';
|
10
|
+
|
11
|
+
import {
|
12
|
+
isInteger
|
13
|
+
} from '@jdeighan/coffee-utils';
|
14
|
+
|
15
|
+
import {
|
16
|
+
indentLevel,
|
17
|
+
indentation,
|
18
|
+
undented,
|
19
|
+
splitLine,
|
20
|
+
indented,
|
21
|
+
tabify,
|
22
|
+
untabify
|
23
|
+
} from '@jdeighan/coffee-utils/indent';
|
24
|
+
|
25
|
+
simple = new UnitTester();
|
26
|
+
|
27
|
+
// ---------------------------------------------------------------------------
|
28
|
+
simple.equal(16, indentLevel("abc"), 0);
|
29
|
+
|
30
|
+
simple.equal(17, indentLevel("\tabc"), 1);
|
31
|
+
|
32
|
+
simple.equal(18, indentLevel("\t\tabc"), 2);
|
33
|
+
|
34
|
+
// ---------------------------------------------------------------------------
|
35
|
+
simple.equal(22, indentation(0), '');
|
36
|
+
|
37
|
+
simple.equal(23, indentation(1), "\t");
|
38
|
+
|
39
|
+
simple.equal(24, indentation(2), "\t\t");
|
40
|
+
|
41
|
+
// ---------------------------------------------------------------------------
|
42
|
+
simple.equal(28, undented("abc"), "abc");
|
43
|
+
|
44
|
+
simple.equal(29, undented("\tabc"), "abc");
|
45
|
+
|
46
|
+
simple.equal(30, undented("\t\tabc"), "abc");
|
47
|
+
|
48
|
+
simple.equal(31, undented("\t\tabc", 0), "\t\tabc");
|
49
|
+
|
50
|
+
simple.equal(32, undented("\t\tabc", 1), "\tabc");
|
51
|
+
|
52
|
+
simple.equal(33, undented("\t\tabc", 2), "abc");
|
53
|
+
|
54
|
+
// ---------------------------------------------------------------------------
|
55
|
+
simple.equal(37, undented("\t\tfirst\n\t\tsecond\n\t\t\tthird\n"), "first\nsecond\n\tthird\n");
|
56
|
+
|
57
|
+
// ---------------------------------------------------------------------------
|
58
|
+
simple.equal(42, splitLine("abc"), [0, "abc"]);
|
59
|
+
|
60
|
+
simple.equal(43, splitLine("\tabc"), [1, "abc"]);
|
61
|
+
|
62
|
+
simple.equal(44, splitLine("\t\tabc"), [2, "abc"]);
|
63
|
+
|
64
|
+
simple.equal(45, splitLine("\t\t\t"), [0, ""]);
|
65
|
+
|
66
|
+
// ---------------------------------------------------------------------------
|
67
|
+
simple.equal(49, indented("abc", 0), "abc");
|
68
|
+
|
69
|
+
simple.equal(50, indented("abc", 1), "\tabc");
|
70
|
+
|
71
|
+
simple.equal(51, indented("abc", 2), "\t\tabc");
|
72
|
+
|
73
|
+
// --- empty lines, indented, should just be empty lines
|
74
|
+
simple.equal(54, indented("abc\n\ndef", 2), "\t\tabc\n\n\t\tdef");
|
75
|
+
|
76
|
+
(function() {
|
77
|
+
var exp, str;
|
78
|
+
str = "main\n\toverflow: auto\n\nnav\n\toverflow: auto";
|
79
|
+
exp = "\tmain\n\t\toverflow: auto\n\n\tnav\n\t\toverflow: auto";
|
80
|
+
return simple.equal(59, indented(str, 1), exp);
|
81
|
+
})();
|
82
|
+
|
83
|
+
// --- indented also handles arrays, so test them, too
|
84
|
+
|
85
|
+
// --- empty lines, indented, should just be empty lines
|
86
|
+
simple.equal(65, indented(['abc', '', 'def'], 2), '\t\tabc\n\n\t\tdef');
|
87
|
+
|
88
|
+
(function() {
|
89
|
+
var lExp, lLines;
|
90
|
+
lLines = ['main', '\toverflow: auto', '', 'nav', '\toverflow: auto'];
|
91
|
+
lExp = '\tmain\n\t\toverflow: auto\n\n\tnav\n\t\toverflow: auto';
|
92
|
+
return simple.equal(70, indented(lLines, 1), lExp);
|
93
|
+
})();
|
94
|
+
|
95
|
+
// ---------------------------------------------------------------------------
|
96
|
+
(function() {
|
97
|
+
var prefix;
|
98
|
+
prefix = ' '; // 3 spaces
|
99
|
+
return simple.equal(78, tabify(`first line
|
100
|
+
${prefix}second line
|
101
|
+
${prefix}${prefix}third line`, 3), `first line
|
102
|
+
\tsecond line
|
103
|
+
\t\tthird line`);
|
104
|
+
})();
|
105
|
+
|
106
|
+
// ---------------------------------------------------------------------------
|
107
|
+
// you don't need to tell it number of spaces
|
108
|
+
(function() {
|
109
|
+
var prefix;
|
110
|
+
prefix = ' '; // 3 spaces
|
111
|
+
return simple.equal(95, tabify(`first line
|
112
|
+
${prefix}second line
|
113
|
+
${prefix}${prefix}third line`), `first line
|
114
|
+
\tsecond line
|
115
|
+
\t\tthird line`);
|
116
|
+
})();
|
117
|
+
|
118
|
+
// ---------------------------------------------------------------------------
|
119
|
+
(function() {
|
120
|
+
var prefix;
|
121
|
+
prefix = ' '; // 3 spaces
|
122
|
+
return simple.equal(111, untabify(`first line
|
123
|
+
\tsecond line
|
124
|
+
\t\tthird line`, 3), `first line
|
125
|
+
${prefix}second line
|
126
|
+
${prefix}${prefix}third line`);
|
127
|
+
})();
|
128
|
+
|
129
|
+
// ---------------------------------------------------------------------------
|
130
|
+
simple.equal(124, indented("export name = undef", 1), "\texport name = undef");
|
131
|
+
|
132
|
+
simple.equal(125, indented("export name = undef", 2), "\t\texport name = undef");
|
133
|
+
|
134
|
+
// ---------------------------------------------------------------------------
|
135
|
+
// make sure indentLevel() works for blocks
|
136
|
+
simple.equal(130, indentLevel("\t\tabc\n\t\tdef\n\t\t\tghi"), 2);
|
@@ -116,9 +116,11 @@ setLogger (str) -> lLines.push(str)
|
|
116
116
|
tester.equal 116, lLines, """
|
117
117
|
abc
|
118
118
|
name:
|
119
|
-
|
120
|
-
|
121
|
-
|
119
|
+
==========================================
|
120
|
+
This is a rather long bit of
|
121
|
+
text which changes
|
122
|
+
how it's displayed
|
123
|
+
==========================================
|
122
124
|
"""
|
123
125
|
)()
|
124
126
|
|
@@ -214,9 +216,11 @@ setLogger (str) -> lLines.push(str)
|
|
214
216
|
""", {prefix: '<-->', logItem: true}
|
215
217
|
tester.equal 215, lLines, """
|
216
218
|
<-->name:
|
217
|
-
|
218
|
-
|
219
|
-
|
219
|
+
==========================================
|
220
|
+
This is a rather long bit of
|
221
|
+
text which changes
|
222
|
+
how it's displayed
|
223
|
+
==========================================
|
220
224
|
"""
|
221
225
|
)()
|
222
226
|
|
@@ -0,0 +1,336 @@
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
2
|
+
// log.test.coffee
|
3
|
+
var LogTester, lLines, simple, tester;
|
4
|
+
|
5
|
+
import {
|
6
|
+
undef
|
7
|
+
} from '@jdeighan/coffee-utils';
|
8
|
+
|
9
|
+
import {
|
10
|
+
arrayToBlock
|
11
|
+
} from '@jdeighan/coffee-utils/block';
|
12
|
+
|
13
|
+
import {
|
14
|
+
UnitTester
|
15
|
+
} from '@jdeighan/coffee-utils/test';
|
16
|
+
|
17
|
+
import {
|
18
|
+
stringify,
|
19
|
+
setStringifier,
|
20
|
+
log,
|
21
|
+
setLogger,
|
22
|
+
tamlStringify
|
23
|
+
} from '@jdeighan/coffee-utils/log';
|
24
|
+
|
25
|
+
simple = new UnitTester();
|
26
|
+
|
27
|
+
// ---------------------------------------------------------------------------
|
28
|
+
LogTester = class LogTester extends UnitTester {
|
29
|
+
transformValue(lLines) {
|
30
|
+
return arrayToBlock(lLines);
|
31
|
+
}
|
32
|
+
|
33
|
+
normalize(text) {
|
34
|
+
return text;
|
35
|
+
}
|
36
|
+
|
37
|
+
};
|
38
|
+
|
39
|
+
tester = new LogTester();
|
40
|
+
|
41
|
+
// ---------------------------------------------------------------------------
|
42
|
+
lLines = undef;
|
43
|
+
|
44
|
+
setLogger(function(str) {
|
45
|
+
return lLines.push(str);
|
46
|
+
});
|
47
|
+
|
48
|
+
// ---------------------------------------------------------------------------
|
49
|
+
(function() {
|
50
|
+
lLines = [];
|
51
|
+
log('enter myfunc');
|
52
|
+
return tester.equal(33, lLines, `enter myfunc`);
|
53
|
+
})();
|
54
|
+
|
55
|
+
// ---------------------------------------------------------------------------
|
56
|
+
(function() {
|
57
|
+
lLines = [];
|
58
|
+
log('abc');
|
59
|
+
log('def');
|
60
|
+
log('ghi');
|
61
|
+
return tester.equal(45, lLines, `abc
|
62
|
+
def
|
63
|
+
ghi`);
|
64
|
+
})();
|
65
|
+
|
66
|
+
// ---------------------------------------------------------------------------
|
67
|
+
// test logging various small objects
|
68
|
+
(function() {
|
69
|
+
lLines = [];
|
70
|
+
log('abc');
|
71
|
+
log('name', undef);
|
72
|
+
return tester.equal(59, lLines, `abc
|
73
|
+
name = undef`);
|
74
|
+
})();
|
75
|
+
|
76
|
+
(function() {
|
77
|
+
lLines = [];
|
78
|
+
log('abc');
|
79
|
+
log('name', 42);
|
80
|
+
return tester.equal(68, lLines, `abc
|
81
|
+
name = 42`);
|
82
|
+
})();
|
83
|
+
|
84
|
+
(function() {
|
85
|
+
lLines = [];
|
86
|
+
log('abc');
|
87
|
+
log('name', 'John');
|
88
|
+
return tester.equal(79, lLines, `abc
|
89
|
+
name = 'John'`);
|
90
|
+
})();
|
91
|
+
|
92
|
+
(function() {
|
93
|
+
lLines = [];
|
94
|
+
log('abc');
|
95
|
+
log('name', {
|
96
|
+
a: 1,
|
97
|
+
b: 'xyz'
|
98
|
+
});
|
99
|
+
return tester.equal(89, lLines, `abc
|
100
|
+
name = {"a":1,"b":"xyz"}`);
|
101
|
+
})();
|
102
|
+
|
103
|
+
(function() {
|
104
|
+
lLines = [];
|
105
|
+
log('abc');
|
106
|
+
log('name', ['a', 42, [1, 2]]);
|
107
|
+
return tester.equal(99, lLines, `abc
|
108
|
+
name = ["a",42,[1,2]]`);
|
109
|
+
})();
|
110
|
+
|
111
|
+
// ---------------------------------------------------------------------------
|
112
|
+
// test logging various large objects
|
113
|
+
(function() {
|
114
|
+
lLines = [];
|
115
|
+
log('abc');
|
116
|
+
log('name', `This is a rather long bit of
|
117
|
+
text which changes
|
118
|
+
how it's displayed`);
|
119
|
+
return tester.equal(116, lLines, `abc
|
120
|
+
name:
|
121
|
+
==========================================
|
122
|
+
This is a rather long bit of
|
123
|
+
text which changes
|
124
|
+
how it's displayed
|
125
|
+
==========================================`);
|
126
|
+
})();
|
127
|
+
|
128
|
+
(function() {
|
129
|
+
lLines = [];
|
130
|
+
log('abc');
|
131
|
+
log('name', {
|
132
|
+
fname: 'John',
|
133
|
+
lname: 'Deighan',
|
134
|
+
age: 68,
|
135
|
+
home: 'Blacksburg, VA'
|
136
|
+
});
|
137
|
+
return tester.equal(134, lLines, `abc
|
138
|
+
name:
|
139
|
+
---
|
140
|
+
fname: John
|
141
|
+
lname: Deighan
|
142
|
+
age: 68
|
143
|
+
home: Blacksburg, VA`);
|
144
|
+
})();
|
145
|
+
|
146
|
+
(function() {
|
147
|
+
lLines = [];
|
148
|
+
log('abc');
|
149
|
+
log('name', [
|
150
|
+
68,
|
151
|
+
'a rather long string of text',
|
152
|
+
{
|
153
|
+
a: 1,
|
154
|
+
b: 2
|
155
|
+
}
|
156
|
+
]);
|
157
|
+
return tester.equal(153, lLines, `abc
|
158
|
+
name:
|
159
|
+
---
|
160
|
+
- 68
|
161
|
+
- a rather long string of text
|
162
|
+
-
|
163
|
+
a: 1
|
164
|
+
b: 2`);
|
165
|
+
})();
|
166
|
+
|
167
|
+
// ---------------------------------------------------------------------------
|
168
|
+
// test providing a prefix
|
169
|
+
(function() {
|
170
|
+
lLines = [];
|
171
|
+
log('name', undef, {
|
172
|
+
prefix: '<-->',
|
173
|
+
logItem: true
|
174
|
+
});
|
175
|
+
return tester.equal(171, lLines, `<-->name = undef`);
|
176
|
+
})();
|
177
|
+
|
178
|
+
(function() {
|
179
|
+
lLines = [];
|
180
|
+
log('name', 42, {
|
181
|
+
prefix: '<-->',
|
182
|
+
logItem: true
|
183
|
+
});
|
184
|
+
return tester.equal(179, lLines, `<-->name = 42`);
|
185
|
+
})();
|
186
|
+
|
187
|
+
(function() {
|
188
|
+
lLines = [];
|
189
|
+
log('name', 'John', {
|
190
|
+
prefix: '<-->',
|
191
|
+
logItem: true
|
192
|
+
});
|
193
|
+
return tester.equal(187, lLines, `<-->name = 'John'`);
|
194
|
+
})();
|
195
|
+
|
196
|
+
(function() {
|
197
|
+
lLines = [];
|
198
|
+
log('name', {
|
199
|
+
a: 1,
|
200
|
+
b: 'xyz'
|
201
|
+
}, {
|
202
|
+
prefix: '<-->',
|
203
|
+
logItem: true
|
204
|
+
});
|
205
|
+
return tester.equal(195, lLines, `<-->name = {"a":1,"b":"xyz"}`);
|
206
|
+
})();
|
207
|
+
|
208
|
+
(function() {
|
209
|
+
lLines = [];
|
210
|
+
log('name', ['a', 42, [1, 2]], {
|
211
|
+
prefix: '<-->',
|
212
|
+
logItem: true
|
213
|
+
});
|
214
|
+
return tester.equal(203, lLines, `<-->name = ["a",42,[1,2]]`);
|
215
|
+
})();
|
216
|
+
|
217
|
+
(function() {
|
218
|
+
lLines = [];
|
219
|
+
log('name', `This is a rather long bit of
|
220
|
+
text which changes
|
221
|
+
how it's displayed`, {
|
222
|
+
prefix: '<-->',
|
223
|
+
logItem: true
|
224
|
+
});
|
225
|
+
return tester.equal(215, lLines, `<-->name:
|
226
|
+
==========================================
|
227
|
+
This is a rather long bit of
|
228
|
+
text which changes
|
229
|
+
how it's displayed
|
230
|
+
==========================================`);
|
231
|
+
})();
|
232
|
+
|
233
|
+
(function() {
|
234
|
+
lLines = [];
|
235
|
+
log('name', {
|
236
|
+
fname: 'John',
|
237
|
+
lname: 'Deighan',
|
238
|
+
age: 68,
|
239
|
+
home: 'Blacksburg, VA'
|
240
|
+
}, {
|
241
|
+
prefix: '<-->',
|
242
|
+
logItem: true
|
243
|
+
});
|
244
|
+
return tester.equal(231, lLines, `<-->name:
|
245
|
+
---
|
246
|
+
fname: John
|
247
|
+
lname: Deighan
|
248
|
+
age: 68
|
249
|
+
home: Blacksburg, VA`);
|
250
|
+
})();
|
251
|
+
|
252
|
+
(function() {
|
253
|
+
lLines = [];
|
254
|
+
log('name', [
|
255
|
+
68,
|
256
|
+
'a rather long string of text',
|
257
|
+
{
|
258
|
+
a: 1,
|
259
|
+
b: 2
|
260
|
+
}
|
261
|
+
], {
|
262
|
+
prefix: '<-->',
|
263
|
+
logItem: true
|
264
|
+
});
|
265
|
+
return tester.equal(248, lLines, `<-->name:
|
266
|
+
---
|
267
|
+
- 68
|
268
|
+
- a rather long string of text
|
269
|
+
-
|
270
|
+
a: 1
|
271
|
+
b: 2`);
|
272
|
+
})();
|
273
|
+
|
274
|
+
// ---------------------------------------------------------------------------
|
275
|
+
simple.equal(261, tamlStringify({
|
276
|
+
a: "word",
|
277
|
+
b: "blind"
|
278
|
+
}), `---
|
279
|
+
a: word
|
280
|
+
b: blind`);
|
281
|
+
|
282
|
+
simple.equal(266, stringify({
|
283
|
+
a: "word",
|
284
|
+
b: "blind"
|
285
|
+
}), `---
|
286
|
+
a: word
|
287
|
+
b: blind`);
|
288
|
+
|
289
|
+
setStringifier(JSON.stringify);
|
290
|
+
|
291
|
+
simple.equal(274, stringify({
|
292
|
+
a: "word",
|
293
|
+
b: "blind"
|
294
|
+
}), '{"a":"word","b":"blind"}');
|
295
|
+
|
296
|
+
setStringifier(tamlStringify);
|
297
|
+
|
298
|
+
simple.equal(279, stringify({
|
299
|
+
a: "word",
|
300
|
+
b: "blind"
|
301
|
+
}), `---
|
302
|
+
a: word
|
303
|
+
b: blind`);
|
304
|
+
|
305
|
+
// ---------------------------------------------------------------------------
|
306
|
+
(function() {
|
307
|
+
var lItems;
|
308
|
+
lItems = [];
|
309
|
+
setLogger(function(item) {
|
310
|
+
return lItems.push(item);
|
311
|
+
});
|
312
|
+
log('a');
|
313
|
+
log('b');
|
314
|
+
log('c');
|
315
|
+
setLogger(); // reset
|
316
|
+
return simple.equal(295, lItems, ['a', 'b', 'c']);
|
317
|
+
})();
|
318
|
+
|
319
|
+
(function() {
|
320
|
+
var lItems;
|
321
|
+
lItems = [];
|
322
|
+
setLogger(function(item) {
|
323
|
+
return lItems.push(item);
|
324
|
+
});
|
325
|
+
log('a');
|
326
|
+
log('b');
|
327
|
+
log('c');
|
328
|
+
setLogger(); // reset
|
329
|
+
return simple.equal(306, lItems, ['a', 'b', 'c']);
|
330
|
+
})();
|
331
|
+
|
332
|
+
simple.fails(309, function() {
|
333
|
+
return error("an error message");
|
334
|
+
});
|
335
|
+
|
336
|
+
// ---------------------------------------------------------------------------
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
2
|
+
// privenv.test.coffee
|
3
|
+
var simple;
|
4
|
+
|
5
|
+
import assert from 'assert';
|
6
|
+
|
7
|
+
import test from 'ava';
|
8
|
+
|
9
|
+
import {
|
10
|
+
undef,
|
11
|
+
pass,
|
12
|
+
isString,
|
13
|
+
isHash,
|
14
|
+
isEmpty,
|
15
|
+
nonEmpty
|
16
|
+
} from '@jdeighan/coffee-utils';
|
17
|
+
|
18
|
+
import {
|
19
|
+
log,
|
20
|
+
setLogger
|
21
|
+
} from '@jdeighan/coffee-utils/log';
|
22
|
+
|
23
|
+
import {
|
24
|
+
UnitTester
|
25
|
+
} from '@jdeighan/coffee-utils/test';
|
26
|
+
|
27
|
+
import {
|
28
|
+
hPrivEnv,
|
29
|
+
resetPrivEnv,
|
30
|
+
setPrivEnvVar,
|
31
|
+
logPrivEnv
|
32
|
+
} from '@jdeighan/coffee-utils/privenv';
|
33
|
+
|
34
|
+
simple = new UnitTester();
|
35
|
+
|
36
|
+
// ----------------------------------------------------------------------------
|
37
|
+
(function() {
|
38
|
+
var strLogs;
|
39
|
+
resetPrivEnv();
|
40
|
+
setPrivEnvVar('DIR_ROOT', '/usr/johnd');
|
41
|
+
setPrivEnvVar('DIR_COMPONENTS', '/usr/johnd/components');
|
42
|
+
simple.equal(24, hPrivEnv['DIR_ROOT'], '/usr/johnd');
|
43
|
+
strLogs = '';
|
44
|
+
setLogger(function(line) {
|
45
|
+
return strLogs += `${line}\n`;
|
46
|
+
});
|
47
|
+
logPrivEnv();
|
48
|
+
return simple.equal(30, strLogs, `PRIVATE ENVIRONMENT:
|
49
|
+
DIR_ROOT = '/usr/johnd'
|
50
|
+
DIR_COMPONENTS = '/usr/johnd/components'
|
51
|
+
----------------------------------------`);
|
52
|
+
})();
|
53
|
+
|
54
|
+
// ----------------------------------------------------------------------------
|
File without changes
|
package/.save/temp.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
2
|
+
// temp.coffee
|
3
|
+
var main, testDir;
|
4
|
+
|
5
|
+
import {
|
6
|
+
log
|
7
|
+
} from '@jdeighan/coffee-utils/log';
|
8
|
+
|
9
|
+
import {
|
10
|
+
mydir,
|
11
|
+
forEachFile
|
12
|
+
} from '@jdeighan/coffee-utils/fs';
|
13
|
+
|
14
|
+
import {
|
15
|
+
debug,
|
16
|
+
setDebugging,
|
17
|
+
checkTraceFile
|
18
|
+
} from '@jdeighan/coffee-utils/debug';
|
19
|
+
|
20
|
+
testDir = mydir(import.meta.url);
|
21
|
+
|
22
|
+
// ---------------------------------------------------------------------------
|
23
|
+
main = function() {
|
24
|
+
return checkTraceFile("c:/Users/johnd/coffee-utils/test/temp.txt");
|
25
|
+
};
|
26
|
+
|
27
|
+
// ---------------------------------------------------------------------------
|
28
|
+
main();
|
File without changes
|
@@ -0,0 +1,93 @@
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
2
|
+
// test.coffee
|
3
|
+
var CapTester, capTester, lItems, tester;
|
4
|
+
|
5
|
+
import {
|
6
|
+
pass
|
7
|
+
} from '@jdeighan/coffee-utils';
|
8
|
+
|
9
|
+
import {
|
10
|
+
UnitTester
|
11
|
+
} from '@jdeighan/coffee-utils/test';
|
12
|
+
|
13
|
+
tester = new UnitTester();
|
14
|
+
|
15
|
+
tester.equal(7, 'abc', 'abc');
|
16
|
+
|
17
|
+
tester.equal(8, ['a', 'b'], ['a', 'b']);
|
18
|
+
|
19
|
+
tester.truthy(9, 42);
|
20
|
+
|
21
|
+
tester.falsy(10, null);
|
22
|
+
|
23
|
+
tester.notequal(11, 'abc', 'def');
|
24
|
+
|
25
|
+
tester.fails(12, function() {
|
26
|
+
throw new Error("bad");
|
27
|
+
});
|
28
|
+
|
29
|
+
tester.different(13, ['a'], ['a']);
|
30
|
+
|
31
|
+
lItems = ['a', 'b', 'c'];
|
32
|
+
|
33
|
+
tester.same(16, lItems, lItems);
|
34
|
+
|
35
|
+
// --- Duplicate line # should not be an error
|
36
|
+
tester.notequal(11, 'xxx', 'xxxx');
|
37
|
+
|
38
|
+
// ---------------------------------------------------------------------------
|
39
|
+
// --- Test creating custom tester
|
40
|
+
CapTester = class CapTester extends UnitTester {
|
41
|
+
transformValue(input) {
|
42
|
+
return input.toUpperCase();
|
43
|
+
}
|
44
|
+
|
45
|
+
};
|
46
|
+
|
47
|
+
capTester = new CapTester();
|
48
|
+
|
49
|
+
capTester.equal(26, 'abc', 'ABC');
|
50
|
+
|
51
|
+
capTester.equal(27, 'ABC', 'ABC');
|
52
|
+
|
53
|
+
capTester.notequal(28, 'abc', 'abc');
|
54
|
+
|
55
|
+
// ---------------------------------------------------------------------------
|
56
|
+
// --- Test string normalization
|
57
|
+
tester.equal(31, `line 1
|
58
|
+
|
59
|
+
line 2
|
60
|
+
|
61
|
+
line 3`, `line 1
|
62
|
+
line 2
|
63
|
+
line 3`);
|
64
|
+
|
65
|
+
// ---------------------------------------------------------------------------
|
66
|
+
// --- Test same_list
|
67
|
+
tester.same_list(54, [1, 2, 3], [1, 2, 3]);
|
68
|
+
|
69
|
+
tester.same_list(55, [2, 1, 3], [1, 2, 3]);
|
70
|
+
|
71
|
+
tester.same_list(56, ['a', 'b', 'c'], ['a', 'b', 'c']);
|
72
|
+
|
73
|
+
tester.same_list(57, ['b', 'a', 'c'], ['a', 'b', 'c']);
|
74
|
+
|
75
|
+
// ---------------------------------------------------------------------------
|
76
|
+
// --- Test not_same_list
|
77
|
+
tester.not_same_list(62, [1, 2, 3], [1, 2]);
|
78
|
+
|
79
|
+
tester.not_same_list(63, [2, 1, 3], [1, 2]);
|
80
|
+
|
81
|
+
tester.not_same_list(64, ['a', 'b', 'c'], ['a', 'b']);
|
82
|
+
|
83
|
+
tester.not_same_list(65, ['b', 'a', 'c'], ['a', 'b']);
|
84
|
+
|
85
|
+
// ---------------------------------------------------------------------------
|
86
|
+
// Test if negative line numbers generate error if env var FINALTEST is set
|
87
|
+
process.env.FINALTEST = 'yes';
|
88
|
+
|
89
|
+
tester.fails(72, function() {
|
90
|
+
return tester.equal(-99, 2, 2);
|
91
|
+
});
|
92
|
+
|
93
|
+
delete process.env.FINALTEST;
|
File without changes
|