@jdeighan/coffee-utils 4.1.7 → 4.1.8
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/coffee_utils.coffee +18 -0
- package/src/coffee_utils.js +22 -0
- package/.save/block.test.coffee +0 -185
- package/.save/block.test.js +0 -129
- package/.save/block2.test.coffee +0 -47
- package/.save/block2.test.js +0 -64
- package/.save/debug.test.coffee +0 -290
- package/.save/debug.test.js +0 -242
- package/.save/fs.test.coffee +0 -148
- package/.save/fs.test.js +0 -191
- package/.save/indent.test.coffee +0 -130
- package/.save/indent.test.js +0 -136
- package/.save/log.test.coffee +0 -315
- package/.save/log.test.js +0 -336
- package/.save/privenv.test.coffee +0 -38
- package/.save/privenv.test.js +0 -54
- package/.save/temp.coffee +0 -19
- package/.save/temp.js +0 -28
- package/.save/tester.test.coffee +0 -75
- package/.save/tester.test.js +0 -93
- package/.save/utils.test.coffee +0 -214
- package/.save/utils.test.js +0 -319
package/.save/debug.test.coffee
DELETED
@@ -1,290 +0,0 @@
|
|
1
|
-
# debug.test.coffee
|
2
|
-
|
3
|
-
import {undef, OL} from '@jdeighan/coffee-utils'
|
4
|
-
import {blockToArray, arrayToBlock} from '@jdeighan/coffee-utils/block'
|
5
|
-
import {log, setLogger} from '@jdeighan/coffee-utils/log'
|
6
|
-
import {
|
7
|
-
setDebugging, debug, resetDebugging, funcMatch,
|
8
|
-
} from '@jdeighan/coffee-utils/debug'
|
9
|
-
import {UnitTester} from '@jdeighan/coffee-utils/test'
|
10
|
-
|
11
|
-
simple = new UnitTester()
|
12
|
-
|
13
|
-
# ---------------------------------------------------------------------------
|
14
|
-
|
15
|
-
lLines = undef
|
16
|
-
setLogger (str) -> lLines.push(str)
|
17
|
-
setDebugging true
|
18
|
-
|
19
|
-
# ---------------------------------------------------------------------------
|
20
|
-
|
21
|
-
(() ->
|
22
|
-
lLines = []
|
23
|
-
debug 'abc'
|
24
|
-
simple.equal 24, lLines, ['abc']
|
25
|
-
)()
|
26
|
-
|
27
|
-
# ---------------------------------------------------------------------------
|
28
|
-
|
29
|
-
class TraceTester extends UnitTester
|
30
|
-
|
31
|
-
initialize: () ->
|
32
|
-
lLines = []
|
33
|
-
|
34
|
-
transformValue: (block) ->
|
35
|
-
|
36
|
-
for line in blockToArray(block)
|
37
|
-
debug line
|
38
|
-
return arrayToBlock(lLines)
|
39
|
-
|
40
|
-
normalize: (text) ->
|
41
|
-
return text
|
42
|
-
|
43
|
-
tester = new TraceTester()
|
44
|
-
|
45
|
-
# ---------------------------------------------------------------------------
|
46
|
-
|
47
|
-
(() ->
|
48
|
-
lLines = []
|
49
|
-
debug 'enter myfunc'
|
50
|
-
debug 'something'
|
51
|
-
debug 'more'
|
52
|
-
debug 'return 42 from myfunc'
|
53
|
-
debug "Answer is 42"
|
54
|
-
simple.equal 54, lLines, [
|
55
|
-
"enter myfunc"
|
56
|
-
"│ something"
|
57
|
-
"│ more"
|
58
|
-
"└─> return 42 from myfunc"
|
59
|
-
"Answer is 42"
|
60
|
-
]
|
61
|
-
)()
|
62
|
-
|
63
|
-
# ---------------------------------------------------------------------------
|
64
|
-
|
65
|
-
(() ->
|
66
|
-
lLines = []
|
67
|
-
debug 'enter myfunc'
|
68
|
-
debug 'something'
|
69
|
-
debug 'enter newfunc'
|
70
|
-
debug 'something else'
|
71
|
-
debug 'return abc from newfunc'
|
72
|
-
debug 'return 42 from myfunc'
|
73
|
-
simple.equal 73, lLines, [
|
74
|
-
"enter myfunc"
|
75
|
-
"│ something"
|
76
|
-
"│ enter newfunc"
|
77
|
-
"│ │ something else"
|
78
|
-
"│ └─> return abc from newfunc"
|
79
|
-
"└─> return 42 from myfunc"
|
80
|
-
]
|
81
|
-
)()
|
82
|
-
|
83
|
-
# ---------------------------------------------------------------------------
|
84
|
-
|
85
|
-
(() ->
|
86
|
-
lLines = []
|
87
|
-
obj = {
|
88
|
-
first: 1
|
89
|
-
second: 2
|
90
|
-
}
|
91
|
-
debug 'enter myfunc'
|
92
|
-
debug 'something'
|
93
|
-
debug 'obj', obj
|
94
|
-
debug 'return 42 from myfunc'
|
95
|
-
simple.equal 95, lLines, [
|
96
|
-
"enter myfunc"
|
97
|
-
"│ something"
|
98
|
-
'│ obj = {"first":1,"second":2}'
|
99
|
-
"└─> return 42 from myfunc"
|
100
|
-
]
|
101
|
-
)()
|
102
|
-
|
103
|
-
# ---------------------------------------------------------------------------
|
104
|
-
|
105
|
-
(() ->
|
106
|
-
lLines = []
|
107
|
-
obj = {
|
108
|
-
first: "this is the first item in the hash"
|
109
|
-
second: "this is the second item in the hash"
|
110
|
-
}
|
111
|
-
debug 'enter myfunc'
|
112
|
-
debug 'something'
|
113
|
-
debug 'obj', obj
|
114
|
-
debug 'return 42 from myfunc'
|
115
|
-
simple.equal 115, lLines, [
|
116
|
-
"enter myfunc"
|
117
|
-
"│ something"
|
118
|
-
"│ obj:"
|
119
|
-
"│ ---"
|
120
|
-
"│ first: this is the first item in the hash"
|
121
|
-
"│ second: this is the second item in the hash"
|
122
|
-
"└─> return 42 from myfunc"
|
123
|
-
]
|
124
|
-
)()
|
125
|
-
|
126
|
-
# ---------------------------------------------------------------------------
|
127
|
-
# --- Test ability to debug only a particular function
|
128
|
-
|
129
|
-
(() ->
|
130
|
-
lLines = []
|
131
|
-
resetDebugging()
|
132
|
-
setDebugging 'innerFunc'
|
133
|
-
|
134
|
-
debug "enter myfunc"
|
135
|
-
debug "something"
|
136
|
-
debug "enter innerFunc"
|
137
|
-
debug "something else"
|
138
|
-
debug "return nothing from innerFunc"
|
139
|
-
debug "this should not appear"
|
140
|
-
debug "return 42 from myfunc"
|
141
|
-
simple.equal 141, lLines, [
|
142
|
-
"enter innerFunc"
|
143
|
-
"│ something else"
|
144
|
-
"└─> return nothing from innerFunc"
|
145
|
-
]
|
146
|
-
setDebugging false
|
147
|
-
)()
|
148
|
-
|
149
|
-
# ---------------------------------------------------------------------------
|
150
|
-
# --- Test ability to debug only a particular function
|
151
|
-
# using actual functions!
|
152
|
-
|
153
|
-
(() ->
|
154
|
-
lLines = []
|
155
|
-
resetDebugging()
|
156
|
-
setDebugging 'innerFunc'
|
157
|
-
|
158
|
-
innerFunc = () ->
|
159
|
-
|
160
|
-
debug "enter innerFunc()"
|
161
|
-
debug "answer is 42"
|
162
|
-
x = 42
|
163
|
-
debug "return from innerFunc()"
|
164
|
-
return
|
165
|
-
|
166
|
-
outerFunc = () ->
|
167
|
-
|
168
|
-
debug "enter outerFunc()"
|
169
|
-
innerFunc()
|
170
|
-
debug "return from outerFunc()"
|
171
|
-
return
|
172
|
-
|
173
|
-
outerFunc()
|
174
|
-
|
175
|
-
simple.equal 175, lLines, [
|
176
|
-
"enter innerFunc()"
|
177
|
-
"│ answer is 42"
|
178
|
-
"└─> return from innerFunc()"
|
179
|
-
]
|
180
|
-
setDebugging false
|
181
|
-
)()
|
182
|
-
|
183
|
-
# ---------------------------------------------------------------------------
|
184
|
-
|
185
|
-
(() ->
|
186
|
-
setDebugging 'get'
|
187
|
-
|
188
|
-
simple.truthy 188, funcMatch('get')
|
189
|
-
simple.truthy 189, funcMatch('StringInput.get')
|
190
|
-
setDebugging false
|
191
|
-
)()
|
192
|
-
|
193
|
-
# ---------------------------------------------------------------------------
|
194
|
-
|
195
|
-
(() ->
|
196
|
-
resetDebugging()
|
197
|
-
setDebugging true
|
198
|
-
lLines = []
|
199
|
-
|
200
|
-
line = 'first line'
|
201
|
-
debug "line is #{OL(line)}"
|
202
|
-
|
203
|
-
simple.equal 203, lLines.length, 1
|
204
|
-
simple.equal 204, lLines, [
|
205
|
-
"line is 'first line'"
|
206
|
-
]
|
207
|
-
setDebugging false
|
208
|
-
)()
|
209
|
-
|
210
|
-
# ---------------------------------------------------------------------------
|
211
|
-
|
212
|
-
(() ->
|
213
|
-
resetDebugging()
|
214
|
-
setDebugging true
|
215
|
-
lLines = []
|
216
|
-
|
217
|
-
obj = {
|
218
|
-
first: "this is the first item in the hash"
|
219
|
-
second: "this is the second item in the hash"
|
220
|
-
}
|
221
|
-
|
222
|
-
debug 'enter myfunc'
|
223
|
-
debug 'return from myfunc', obj
|
224
|
-
debug "Answer is 42"
|
225
|
-
simple.equal 225, lLines, [
|
226
|
-
"enter myfunc"
|
227
|
-
"└─> return from myfunc:"
|
228
|
-
" ---"
|
229
|
-
" first: this is the first item in the hash"
|
230
|
-
" second: this is the second item in the hash"
|
231
|
-
"Answer is 42"
|
232
|
-
]
|
233
|
-
)()
|
234
|
-
|
235
|
-
# ---------------------------------------------------------------------------
|
236
|
-
|
237
|
-
(() ->
|
238
|
-
resetDebugging()
|
239
|
-
setDebugging true
|
240
|
-
lLines = []
|
241
|
-
|
242
|
-
longBlock = """
|
243
|
-
this is one very long line
|
244
|
-
this is another very long line
|
245
|
-
"""
|
246
|
-
|
247
|
-
debug 'enter myfunc'
|
248
|
-
debug 'return from myfunc', longBlock
|
249
|
-
debug "Answer is 42"
|
250
|
-
simple.equal 250, lLines, [
|
251
|
-
"enter myfunc"
|
252
|
-
"└─> return from myfunc:"
|
253
|
-
" =========================================="
|
254
|
-
" this is one very long line"
|
255
|
-
" this is another very long line"
|
256
|
-
" =========================================="
|
257
|
-
"Answer is 42"
|
258
|
-
]
|
259
|
-
)()
|
260
|
-
|
261
|
-
# ---------------------------------------------------------------------------
|
262
|
-
|
263
|
-
(() ->
|
264
|
-
resetDebugging()
|
265
|
-
setDebugging 'get'
|
266
|
-
|
267
|
-
block = """
|
268
|
-
enter myfunc
|
269
|
-
enter get
|
270
|
-
enter fetch
|
271
|
-
return from fetch
|
272
|
-
return from get
|
273
|
-
enter nofunc
|
274
|
-
return from nofunc
|
275
|
-
enter get
|
276
|
-
something
|
277
|
-
return from get
|
278
|
-
return from myfunc
|
279
|
-
"""
|
280
|
-
|
281
|
-
tester.equal 279, block, """
|
282
|
-
enter get
|
283
|
-
│ enter fetch
|
284
|
-
│ └─> return from fetch
|
285
|
-
└─> return from get
|
286
|
-
enter get
|
287
|
-
│ something
|
288
|
-
└─> return from get
|
289
|
-
"""
|
290
|
-
)()
|
package/.save/debug.test.js
DELETED
@@ -1,242 +0,0 @@
|
|
1
|
-
// Generated by CoffeeScript 2.6.1
|
2
|
-
// debug.test.coffee
|
3
|
-
var TraceTester, lLines, simple, tester;
|
4
|
-
|
5
|
-
import {
|
6
|
-
undef,
|
7
|
-
OL
|
8
|
-
} from '@jdeighan/coffee-utils';
|
9
|
-
|
10
|
-
import {
|
11
|
-
blockToArray,
|
12
|
-
arrayToBlock
|
13
|
-
} from '@jdeighan/coffee-utils/block';
|
14
|
-
|
15
|
-
import {
|
16
|
-
log,
|
17
|
-
setLogger
|
18
|
-
} from '@jdeighan/coffee-utils/log';
|
19
|
-
|
20
|
-
import {
|
21
|
-
setDebugging,
|
22
|
-
debug,
|
23
|
-
resetDebugging,
|
24
|
-
funcMatch
|
25
|
-
} from '@jdeighan/coffee-utils/debug';
|
26
|
-
|
27
|
-
import {
|
28
|
-
UnitTester
|
29
|
-
} from '@jdeighan/coffee-utils/test';
|
30
|
-
|
31
|
-
simple = new UnitTester();
|
32
|
-
|
33
|
-
// ---------------------------------------------------------------------------
|
34
|
-
lLines = undef;
|
35
|
-
|
36
|
-
setLogger(function(str) {
|
37
|
-
return lLines.push(str);
|
38
|
-
});
|
39
|
-
|
40
|
-
setDebugging(true);
|
41
|
-
|
42
|
-
// ---------------------------------------------------------------------------
|
43
|
-
(function() {
|
44
|
-
lLines = [];
|
45
|
-
debug('abc');
|
46
|
-
return simple.equal(24, lLines, ['abc']);
|
47
|
-
})();
|
48
|
-
|
49
|
-
// ---------------------------------------------------------------------------
|
50
|
-
TraceTester = class TraceTester extends UnitTester {
|
51
|
-
initialize() {
|
52
|
-
return lLines = [];
|
53
|
-
}
|
54
|
-
|
55
|
-
transformValue(block) {
|
56
|
-
var i, len, line, ref;
|
57
|
-
ref = blockToArray(block);
|
58
|
-
for (i = 0, len = ref.length; i < len; i++) {
|
59
|
-
line = ref[i];
|
60
|
-
debug(line);
|
61
|
-
}
|
62
|
-
return arrayToBlock(lLines);
|
63
|
-
}
|
64
|
-
|
65
|
-
normalize(text) {
|
66
|
-
return text;
|
67
|
-
}
|
68
|
-
|
69
|
-
};
|
70
|
-
|
71
|
-
tester = new TraceTester();
|
72
|
-
|
73
|
-
// ---------------------------------------------------------------------------
|
74
|
-
(function() {
|
75
|
-
lLines = [];
|
76
|
-
debug('enter myfunc');
|
77
|
-
debug('something');
|
78
|
-
debug('more');
|
79
|
-
debug('return 42 from myfunc');
|
80
|
-
debug("Answer is 42");
|
81
|
-
return simple.equal(54, lLines, ["enter myfunc", "│ something", "│ more", "└─> return 42 from myfunc", "Answer is 42"]);
|
82
|
-
})();
|
83
|
-
|
84
|
-
// ---------------------------------------------------------------------------
|
85
|
-
(function() {
|
86
|
-
lLines = [];
|
87
|
-
debug('enter myfunc');
|
88
|
-
debug('something');
|
89
|
-
debug('enter newfunc');
|
90
|
-
debug('something else');
|
91
|
-
debug('return abc from newfunc');
|
92
|
-
debug('return 42 from myfunc');
|
93
|
-
return simple.equal(73, lLines, ["enter myfunc", "│ something", "│ enter newfunc", "│ │ something else", "│ └─> return abc from newfunc", "└─> return 42 from myfunc"]);
|
94
|
-
})();
|
95
|
-
|
96
|
-
// ---------------------------------------------------------------------------
|
97
|
-
(function() {
|
98
|
-
var obj;
|
99
|
-
lLines = [];
|
100
|
-
obj = {
|
101
|
-
first: 1,
|
102
|
-
second: 2
|
103
|
-
};
|
104
|
-
debug('enter myfunc');
|
105
|
-
debug('something');
|
106
|
-
debug('obj', obj);
|
107
|
-
debug('return 42 from myfunc');
|
108
|
-
return simple.equal(95, lLines, ["enter myfunc", "│ something", '│ obj = {"first":1,"second":2}', "└─> return 42 from myfunc"]);
|
109
|
-
})();
|
110
|
-
|
111
|
-
// ---------------------------------------------------------------------------
|
112
|
-
(function() {
|
113
|
-
var obj;
|
114
|
-
lLines = [];
|
115
|
-
obj = {
|
116
|
-
first: "this is the first item in the hash",
|
117
|
-
second: "this is the second item in the hash"
|
118
|
-
};
|
119
|
-
debug('enter myfunc');
|
120
|
-
debug('something');
|
121
|
-
debug('obj', obj);
|
122
|
-
debug('return 42 from myfunc');
|
123
|
-
return simple.equal(115, lLines, ["enter myfunc", "│ something", "│ obj:", "│ ---", "│ first: this is the first item in the hash", "│ second: this is the second item in the hash", "└─> return 42 from myfunc"]);
|
124
|
-
})();
|
125
|
-
|
126
|
-
// ---------------------------------------------------------------------------
|
127
|
-
// --- Test ability to debug only a particular function
|
128
|
-
(function() {
|
129
|
-
lLines = [];
|
130
|
-
resetDebugging();
|
131
|
-
setDebugging('innerFunc');
|
132
|
-
debug("enter myfunc");
|
133
|
-
debug("something");
|
134
|
-
debug("enter innerFunc");
|
135
|
-
debug("something else");
|
136
|
-
debug("return nothing from innerFunc");
|
137
|
-
debug("this should not appear");
|
138
|
-
debug("return 42 from myfunc");
|
139
|
-
simple.equal(141, lLines, ["enter innerFunc", "│ something else", "└─> return nothing from innerFunc"]);
|
140
|
-
return setDebugging(false);
|
141
|
-
})();
|
142
|
-
|
143
|
-
// ---------------------------------------------------------------------------
|
144
|
-
// --- Test ability to debug only a particular function
|
145
|
-
// using actual functions!
|
146
|
-
(function() {
|
147
|
-
var innerFunc, outerFunc;
|
148
|
-
lLines = [];
|
149
|
-
resetDebugging();
|
150
|
-
setDebugging('innerFunc');
|
151
|
-
innerFunc = function() {
|
152
|
-
var x;
|
153
|
-
debug("enter innerFunc()");
|
154
|
-
debug("answer is 42");
|
155
|
-
x = 42;
|
156
|
-
debug("return from innerFunc()");
|
157
|
-
};
|
158
|
-
outerFunc = function() {
|
159
|
-
debug("enter outerFunc()");
|
160
|
-
innerFunc();
|
161
|
-
debug("return from outerFunc()");
|
162
|
-
};
|
163
|
-
outerFunc();
|
164
|
-
simple.equal(175, lLines, ["enter innerFunc()", "│ answer is 42", "└─> return from innerFunc()"]);
|
165
|
-
return setDebugging(false);
|
166
|
-
})();
|
167
|
-
|
168
|
-
// ---------------------------------------------------------------------------
|
169
|
-
(function() {
|
170
|
-
setDebugging('get');
|
171
|
-
simple.truthy(188, funcMatch('get'));
|
172
|
-
simple.truthy(189, funcMatch('StringInput.get'));
|
173
|
-
return setDebugging(false);
|
174
|
-
})();
|
175
|
-
|
176
|
-
// ---------------------------------------------------------------------------
|
177
|
-
(function() {
|
178
|
-
var line;
|
179
|
-
resetDebugging();
|
180
|
-
setDebugging(true);
|
181
|
-
lLines = [];
|
182
|
-
line = 'first line';
|
183
|
-
debug(`line is ${OL(line)}`);
|
184
|
-
simple.equal(203, lLines.length, 1);
|
185
|
-
simple.equal(204, lLines, ["line is 'first line'"]);
|
186
|
-
return setDebugging(false);
|
187
|
-
})();
|
188
|
-
|
189
|
-
// ---------------------------------------------------------------------------
|
190
|
-
(function() {
|
191
|
-
var obj;
|
192
|
-
resetDebugging();
|
193
|
-
setDebugging(true);
|
194
|
-
lLines = [];
|
195
|
-
obj = {
|
196
|
-
first: "this is the first item in the hash",
|
197
|
-
second: "this is the second item in the hash"
|
198
|
-
};
|
199
|
-
debug('enter myfunc');
|
200
|
-
debug('return from myfunc', obj);
|
201
|
-
debug("Answer is 42");
|
202
|
-
return simple.equal(225, lLines, ["enter myfunc", "└─> return from myfunc:", " ---", " first: this is the first item in the hash", " second: this is the second item in the hash", "Answer is 42"]);
|
203
|
-
})();
|
204
|
-
|
205
|
-
// ---------------------------------------------------------------------------
|
206
|
-
(function() {
|
207
|
-
var longBlock;
|
208
|
-
resetDebugging();
|
209
|
-
setDebugging(true);
|
210
|
-
lLines = [];
|
211
|
-
longBlock = `this is one very long line
|
212
|
-
this is another very long line`;
|
213
|
-
debug('enter myfunc');
|
214
|
-
debug('return from myfunc', longBlock);
|
215
|
-
debug("Answer is 42");
|
216
|
-
return simple.equal(250, lLines, ["enter myfunc", "└─> return from myfunc:", " ==========================================", " this is one very long line", " this is another very long line", " ==========================================", "Answer is 42"]);
|
217
|
-
})();
|
218
|
-
|
219
|
-
// ---------------------------------------------------------------------------
|
220
|
-
(function() {
|
221
|
-
var block;
|
222
|
-
resetDebugging();
|
223
|
-
setDebugging('get');
|
224
|
-
block = `enter myfunc
|
225
|
-
enter get
|
226
|
-
enter fetch
|
227
|
-
return from fetch
|
228
|
-
return from get
|
229
|
-
enter nofunc
|
230
|
-
return from nofunc
|
231
|
-
enter get
|
232
|
-
something
|
233
|
-
return from get
|
234
|
-
return from myfunc`;
|
235
|
-
return tester.equal(279, block, `enter get
|
236
|
-
│ enter fetch
|
237
|
-
│ └─> return from fetch
|
238
|
-
└─> return from get
|
239
|
-
enter get
|
240
|
-
│ something
|
241
|
-
└─> return from get`);
|
242
|
-
})();
|
package/.save/fs.test.coffee
DELETED
@@ -1,148 +0,0 @@
|
|
1
|
-
# fs.test.coffee
|
2
|
-
|
3
|
-
import assert from 'assert'
|
4
|
-
import {dirname, resolve} from 'path'
|
5
|
-
import {fileURLToPath} from 'url'
|
6
|
-
import {
|
7
|
-
existsSync, copyFileSync, readFileSync, writeFileSync,
|
8
|
-
} from 'fs'
|
9
|
-
|
10
|
-
import {UnitTester} from '@jdeighan/coffee-utils/test'
|
11
|
-
import {say, undef} from '@jdeighan/coffee-utils'
|
12
|
-
import {debug} from '@jdeighan/coffee-utils/debug'
|
13
|
-
import {
|
14
|
-
mydir, mkpath, isFile, isDir, isSimpleFileName,
|
15
|
-
getSubDirs, pathTo, getFullPath, parseSource, fileExt,
|
16
|
-
withExt, withUnderScore,
|
17
|
-
} from '@jdeighan/coffee-utils/fs'
|
18
|
-
|
19
|
-
simple = new UnitTester()
|
20
|
-
|
21
|
-
dir = mydir(`import.meta.url`)
|
22
|
-
assert existsSync(dir)
|
23
|
-
|
24
|
-
# ---------------------------------------------------------------------------
|
25
|
-
|
26
|
-
hOpt = {removeLeadingUnderScore: true}
|
27
|
-
|
28
|
-
simple.equal 21, withExt('file.py', 'svelte'), 'file.svelte'
|
29
|
-
simple.equal 21, withExt('file.py', 'svelte', hOpt), 'file.svelte'
|
30
|
-
simple.equal 21, withExt('_file.py', 'svelte', hOpt), 'file.svelte'
|
31
|
-
|
32
|
-
simple.equal 21, withExt('/bin/file.py', 'svelte'), '/bin/file.svelte'
|
33
|
-
simple.equal 21, withExt('/bin/file.py', 'svelte', hOpt), '/bin/file.svelte'
|
34
|
-
simple.equal 21, withExt('/bin/_file.py', 'svelte', hOpt), '/bin/file.svelte'
|
35
|
-
|
36
|
-
simple.equal 21, withUnderScore('file.py', 'svelte'), '_file.py'
|
37
|
-
simple.equal 21, withUnderScore('_file.py', 'svelte'), '__file.py'
|
38
|
-
|
39
|
-
simple.equal 21, withUnderScore('/bin/file.py', 'svelte'), '/bin/_file.py'
|
40
|
-
simple.equal 21, withUnderScore('/bin/_file.py', 'svelte'), '/bin/__file.py'
|
41
|
-
|
42
|
-
# ---------------------------------------------------------------------------
|
43
|
-
|
44
|
-
(() ->
|
45
|
-
fname = 'debug.test.coffee'
|
46
|
-
|
47
|
-
simple.truthy 29, existsSync("#{dir}/#{fname}")
|
48
|
-
simple.falsy 30, existsSync("#{dir}/nosuchfile.test.coffee")
|
49
|
-
simple.equal 31, pathTo("#{fname}", dir), "#{dir}/#{fname}"
|
50
|
-
)()
|
51
|
-
|
52
|
-
# ---------------------------------------------------------------------------
|
53
|
-
|
54
|
-
# --- dirs are returned in alphabetical order
|
55
|
-
simple.equal 37, getSubDirs(dir), ['data','markdown','subdirectory']
|
56
|
-
|
57
|
-
simple.equal 39, pathTo('test.txt', dir), \
|
58
|
-
"#{dir}/subdirectory/test.txt"
|
59
|
-
|
60
|
-
# ---------------------------------------------------------------------------
|
61
|
-
|
62
|
-
simple.equal 44, mkpath('/usr/lib', 'johnd'), '/usr/lib/johnd'
|
63
|
-
simple.equal 48, mkpath('', '/usr/lib', undef, 'johnd'), '/usr/lib/johnd'
|
64
|
-
simple.equal 45, mkpath("c:", 'local/user'), 'c:/local/user'
|
65
|
-
simple.equal 46, mkpath('/usr', 'lib', 'local', 'johnd'),
|
66
|
-
'/usr/lib/local/johnd'
|
67
|
-
|
68
|
-
simple.equal 48, mkpath('\\usr\\lib', 'johnd'), '/usr/lib/johnd'
|
69
|
-
simple.equal 49, mkpath("c:", 'local\\user'), 'c:/local/user'
|
70
|
-
simple.equal 50, mkpath('\\usr', 'lib', 'local', 'johnd'),
|
71
|
-
'/usr/lib/local/johnd'
|
72
|
-
|
73
|
-
simple.equal 55, mkpath('C:\\Users\\johnd', 'cielo'), 'c:/Users/johnd/cielo'
|
74
|
-
|
75
|
-
# ---------------------------------------------------------------------------
|
76
|
-
# test getFullPath()
|
77
|
-
|
78
|
-
# --- current working directory is the root dir, i.e. parent of this directory
|
79
|
-
wd = mkpath(process.cwd())
|
80
|
-
|
81
|
-
myfname = 'fs.test.coffee'
|
82
|
-
mypath = mkpath(dir, myfname)
|
83
|
-
rootdir = mkpath(resolve(dir, '..'))
|
84
|
-
assert rootdir == wd, "#{rootdir} should equal #{wd}"
|
85
|
-
|
86
|
-
debug "Current Working Directory = '#{wd}'"
|
87
|
-
debug "dir = '#{dir}'"
|
88
|
-
debug "myfname = '#{myfname}'"
|
89
|
-
debug "mypath = '#{mypath}'"
|
90
|
-
debug "rootdir = '#{rootdir}'"
|
91
|
-
|
92
|
-
# --- given a full path, only change \ to /
|
93
|
-
simple.equal 72, getFullPath(mypath), mypath
|
94
|
-
|
95
|
-
# --- given a simple file name, prepend the current working directory
|
96
|
-
simple.equal 75, getFullPath(myfname), mkpath(rootdir, myfname)
|
97
|
-
|
98
|
-
# --- leading . should be resolved
|
99
|
-
simple.equal 78, getFullPath("./#{myfname}"), mkpath(rootdir, myfname)
|
100
|
-
|
101
|
-
# --- leading .. should be resolved
|
102
|
-
simple.equal 81, getFullPath("./test/../#{myfname}"), mkpath(rootdir, myfname)
|
103
|
-
|
104
|
-
simple.equal 86, parseSource('unit test'), {
|
105
|
-
filename: 'unit test'
|
106
|
-
stub: 'unit test'
|
107
|
-
}
|
108
|
-
|
109
|
-
simple.equal 91, parseSource("c:/Users/johnd/oz/src/test.js"), {
|
110
|
-
dir: 'c:/Users/johnd/oz/src'
|
111
|
-
fullpath: 'c:/Users/johnd/oz/src/test.js'
|
112
|
-
filename: 'test.js'
|
113
|
-
stub: 'test'
|
114
|
-
ext: '.js'
|
115
|
-
}
|
116
|
-
|
117
|
-
simple.equal 91, parseSource("c:\\Users\\johnd\\oz\\src\\test.js"), {
|
118
|
-
dir: 'c:/Users/johnd/oz/src'
|
119
|
-
fullpath: 'c:/Users/johnd/oz/src/test.js'
|
120
|
-
filename: 'test.js'
|
121
|
-
stub: 'test'
|
122
|
-
ext: '.js'
|
123
|
-
}
|
124
|
-
|
125
|
-
if process.platform == 'win32'
|
126
|
-
simple.truthy 108, isDir('c:/Users')
|
127
|
-
simple.truthy 109, isDir('c:/Program Files')
|
128
|
-
simple.falsy 110, isFile('c:/Users')
|
129
|
-
simple.falsy 111, isFile('c:/Program Files')
|
130
|
-
|
131
|
-
simple.falsy 113, isDir('c:/Windows/notepad.exe')
|
132
|
-
simple.falsy 114, isDir(
|
133
|
-
'c:/Program Files/Windows Media Player/wmplayer.exe'
|
134
|
-
)
|
135
|
-
simple.truthy 115, isFile('c:/Windows/notepad.exe')
|
136
|
-
simple.truthy 116, isFile(
|
137
|
-
'c:/Program Files/Windows Media Player/wmplayer.exe'
|
138
|
-
)
|
139
|
-
|
140
|
-
simple.truthy 118, isSimpleFileName('notepad.exe')
|
141
|
-
simple.falsy 119, isSimpleFileName(
|
142
|
-
'c:/Program Files/Windows Media Player/wmplayer.exe'
|
143
|
-
)
|
144
|
-
|
145
|
-
simple.equal 121, fileExt('file.txt'), '.txt'
|
146
|
-
simple.equal 122, fileExt('file.'), ''
|
147
|
-
simple.equal 123, fileExt('file.99'), '.99'
|
148
|
-
simple.equal 124, fileExt('file._txt'), '._txt'
|