@jdeighan/coffee-utils 4.1.4 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/coffee_utils.coffee +36 -2
- package/src/coffee_utils.js +39 -2
- package/src/fs_utils.coffee +8 -2
- package/src/fs_utils.js +9 -3
- package/temp.js +26 -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/src/private_env.coffee +0 -52
- package/src/private_env.js +0 -63
package/.save/privenv.test.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
// ----------------------------------------------------------------------------
|
package/.save/temp.coffee
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# temp.coffee
|
|
2
|
-
|
|
3
|
-
import {log} from '@jdeighan/coffee-utils/log'
|
|
4
|
-
import {mydir, forEachFile} from '@jdeighan/coffee-utils/fs'
|
|
5
|
-
import {
|
|
6
|
-
debug, setDebugging, checkTraceFile,
|
|
7
|
-
} from '@jdeighan/coffee-utils/debug'
|
|
8
|
-
|
|
9
|
-
testDir = mydir(`import.meta.url`)
|
|
10
|
-
|
|
11
|
-
# ---------------------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
main = () ->
|
|
14
|
-
|
|
15
|
-
checkTraceFile "c:/Users/johnd/coffee-utils/test/temp.txt"
|
|
16
|
-
|
|
17
|
-
# ---------------------------------------------------------------------------
|
|
18
|
-
|
|
19
|
-
main()
|
package/.save/temp.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
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();
|
package/.save/tester.test.coffee
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
# test.coffee
|
|
2
|
-
|
|
3
|
-
import {pass} from '@jdeighan/coffee-utils'
|
|
4
|
-
import {UnitTester} from '@jdeighan/coffee-utils/test'
|
|
5
|
-
|
|
6
|
-
tester = new UnitTester
|
|
7
|
-
|
|
8
|
-
tester.equal 7, 'abc', 'abc'
|
|
9
|
-
tester.equal 8, ['a','b'], [ 'a', 'b', ]
|
|
10
|
-
tester.truthy 9, 42
|
|
11
|
-
tester.falsy 10, null
|
|
12
|
-
tester.notequal 11, 'abc', 'def'
|
|
13
|
-
tester.fails 12, () -> throw new Error("bad")
|
|
14
|
-
tester.different 13, ['a'], ['a']
|
|
15
|
-
|
|
16
|
-
lItems = ['a', 'b', 'c']
|
|
17
|
-
tester.same 16, lItems, lItems
|
|
18
|
-
|
|
19
|
-
# --- Duplicate line # should not be an error
|
|
20
|
-
tester.notequal 11, 'xxx', 'xxxx'
|
|
21
|
-
|
|
22
|
-
# ---------------------------------------------------------------------------
|
|
23
|
-
# --- Test creating custom tester
|
|
24
|
-
|
|
25
|
-
class CapTester extends UnitTester
|
|
26
|
-
|
|
27
|
-
transformValue: (input) ->
|
|
28
|
-
return input.toUpperCase()
|
|
29
|
-
|
|
30
|
-
capTester = new CapTester()
|
|
31
|
-
|
|
32
|
-
capTester.equal 26, 'abc', 'ABC'
|
|
33
|
-
capTester.equal 27, 'ABC', 'ABC'
|
|
34
|
-
capTester.notequal 28, 'abc', 'abc'
|
|
35
|
-
|
|
36
|
-
# ---------------------------------------------------------------------------
|
|
37
|
-
# --- Test string normalization
|
|
38
|
-
|
|
39
|
-
tester.equal 31, """
|
|
40
|
-
line 1
|
|
41
|
-
|
|
42
|
-
line 2
|
|
43
|
-
|
|
44
|
-
line 3
|
|
45
|
-
""", """
|
|
46
|
-
line 1
|
|
47
|
-
line 2
|
|
48
|
-
line 3
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
# ---------------------------------------------------------------------------
|
|
52
|
-
# --- Test same_list
|
|
53
|
-
|
|
54
|
-
tester.same_list 54, [1,2,3], [1,2,3]
|
|
55
|
-
tester.same_list 55, [2,1,3], [1,2,3]
|
|
56
|
-
tester.same_list 56, ['a','b','c'], ['a','b','c']
|
|
57
|
-
tester.same_list 57, ['b','a','c'], ['a','b','c']
|
|
58
|
-
|
|
59
|
-
# ---------------------------------------------------------------------------
|
|
60
|
-
# --- Test not_same_list
|
|
61
|
-
|
|
62
|
-
tester.not_same_list 62, [1,2,3], [1,2]
|
|
63
|
-
tester.not_same_list 63, [2,1,3], [1,2]
|
|
64
|
-
tester.not_same_list 64, ['a','b','c'], ['a','b']
|
|
65
|
-
tester.not_same_list 65, ['b','a','c'], ['a','b']
|
|
66
|
-
|
|
67
|
-
# ---------------------------------------------------------------------------
|
|
68
|
-
# Test if negative line numbers generate error if env var FINALTEST is set
|
|
69
|
-
|
|
70
|
-
process.env.FINALTEST = 'yes'
|
|
71
|
-
|
|
72
|
-
tester.fails 72, () ->
|
|
73
|
-
tester.equal -99, 2, 2
|
|
74
|
-
|
|
75
|
-
delete process.env.FINALTEST
|
package/.save/tester.test.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
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;
|
package/.save/utils.test.coffee
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
# utils.test.coffee
|
|
2
|
-
|
|
3
|
-
import {UnitTester} from '@jdeighan/coffee-utils/test'
|
|
4
|
-
import {
|
|
5
|
-
say, undef, error, warn, isString, isObject, isArray, isHash,
|
|
6
|
-
isEmpty, nonEmpty, isComment, getClassName, isNumber,
|
|
7
|
-
isFunction, isInteger, rtrim,
|
|
8
|
-
ltrunc, rtrunc, extractMatches,
|
|
9
|
-
words, escapeStr, titleLine,
|
|
10
|
-
removeCR, CWS, isArrayOfHashes,
|
|
11
|
-
oneline, croak, isRegExp,
|
|
12
|
-
} from '@jdeighan/coffee-utils'
|
|
13
|
-
import {setLogger} from '@jdeighan/coffee-utils/log'
|
|
14
|
-
import {setDebugging} from '@jdeighan/coffee-utils/debug'
|
|
15
|
-
import {arrayToBlock} from '@jdeighan/coffee-utils/block'
|
|
16
|
-
|
|
17
|
-
simple = new UnitTester()
|
|
18
|
-
|
|
19
|
-
# ---------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
simple.truthy 19, isEmpty('')
|
|
22
|
-
simple.truthy 20, isEmpty(' \t\t')
|
|
23
|
-
simple.truthy 21, isEmpty([])
|
|
24
|
-
simple.truthy 22, isEmpty({})
|
|
25
|
-
|
|
26
|
-
simple.truthy 24, nonEmpty('a')
|
|
27
|
-
simple.truthy 25, nonEmpty('.')
|
|
28
|
-
simple.truthy 26, nonEmpty([2])
|
|
29
|
-
simple.truthy 27, nonEmpty({width: 2})
|
|
30
|
-
|
|
31
|
-
simple.truthy 29, isComment("# a comment")
|
|
32
|
-
simple.truthy 30, isComment("### a comment")
|
|
33
|
-
simple.truthy 31, isComment("#\ta comment")
|
|
34
|
-
simple.truthy 32, isComment("###\ta comment")
|
|
35
|
-
simple.truthy 33, isComment(" # a comment")
|
|
36
|
-
simple.truthy 34, isComment(" ### a comment")
|
|
37
|
-
simple.falsy 35, isComment("not much")
|
|
38
|
-
simple.falsy 36, isComment("#foreach x in lItems")
|
|
39
|
-
simple.truthy 37, isComment('#')
|
|
40
|
-
simple.truthy 38, isComment(' #')
|
|
41
|
-
simple.truthy 39, isComment(' ###')
|
|
42
|
-
simple.falsy 40, isComment('#for')
|
|
43
|
-
simple.falsy 41, isComment(' #for')
|
|
44
|
-
simple.falsy 42, isComment('#for line in lLines')
|
|
45
|
-
|
|
46
|
-
simple.equal 44, titleLine('a thing').length, 42
|
|
47
|
-
simple.equal 45, titleLine('a thing','-',5,90).length, 90
|
|
48
|
-
|
|
49
|
-
# ---------------------------------------------------------------------------
|
|
50
|
-
|
|
51
|
-
simple.equal 80, rtrim("abc"), "abc"
|
|
52
|
-
simple.equal 81, rtrim(" abc"), " abc"
|
|
53
|
-
simple.equal 82, rtrim("abc "), "abc"
|
|
54
|
-
simple.equal 83, rtrim(" abc "), " abc"
|
|
55
|
-
|
|
56
|
-
# ---------------------------------------------------------------------------
|
|
57
|
-
|
|
58
|
-
simple.equal 87, words('a b c'), ['a', 'b', 'c']
|
|
59
|
-
simple.equal 88, words(' a b c '), ['a', 'b', 'c']
|
|
60
|
-
|
|
61
|
-
# ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
simple.equal 92, escapeStr("\t\tXXX\n"), "\\t\\tXXX\\n"
|
|
64
|
-
hEsc = {
|
|
65
|
-
"\n": "\\n"
|
|
66
|
-
"\t": "\\t"
|
|
67
|
-
"\"": "\\\""
|
|
68
|
-
}
|
|
69
|
-
simple.equal 64, escapeStr("\thas quote: \"\nnext line", hEsc), \
|
|
70
|
-
"\\thas quote: \\\"\\nnext line"
|
|
71
|
-
|
|
72
|
-
# ---------------------------------------------------------------------------
|
|
73
|
-
|
|
74
|
-
simple.equal 130, rtrunc('/user/lib/.env', 5), '/user/lib'
|
|
75
|
-
simple.equal 131, ltrunc('abcdefg', 3), 'defg'
|
|
76
|
-
|
|
77
|
-
simple.equal 133, removeCR("abc\r\ndef\r\n"), "abc\ndef\n"
|
|
78
|
-
simple.equal 139, CWS("""
|
|
79
|
-
abc
|
|
80
|
-
def
|
|
81
|
-
ghi
|
|
82
|
-
"""), "abc def ghi"
|
|
83
|
-
|
|
84
|
-
# ---------------------------------------------------------------------------
|
|
85
|
-
|
|
86
|
-
simple.truthy 147, isArrayOfHashes([])
|
|
87
|
-
simple.truthy 148, isArrayOfHashes([{}, {}])
|
|
88
|
-
simple.truthy 149, isArrayOfHashes([{a: 1, b:2}, {}])
|
|
89
|
-
simple.truthy 150, isArrayOfHashes([{a: 1, b:2, c: [1,2,3]}, {}])
|
|
90
|
-
|
|
91
|
-
simple.falsy 152, isArrayOfHashes({})
|
|
92
|
-
simple.falsy 153, isArrayOfHashes([1,2,3])
|
|
93
|
-
simple.falsy 154, isArrayOfHashes([{a: 1, b:2, c: [1,2,3]}, 4])
|
|
94
|
-
simple.falsy 155, isArrayOfHashes([{a: 1, b:2, c: [1,2,3]}, {}, [1,2]])
|
|
95
|
-
|
|
96
|
-
# ---------------------------------------------------------------------------
|
|
97
|
-
|
|
98
|
-
(() ->
|
|
99
|
-
class NewClass
|
|
100
|
-
|
|
101
|
-
h = {a:1, b:2}
|
|
102
|
-
l = [1,2,2]
|
|
103
|
-
o = new NewClass()
|
|
104
|
-
n = 42
|
|
105
|
-
n2 = new Number(42)
|
|
106
|
-
s = 'simple'
|
|
107
|
-
s2 = new String('abc')
|
|
108
|
-
|
|
109
|
-
simple.truthy 170, isHash(h)
|
|
110
|
-
simple.falsy 171, isHash(l)
|
|
111
|
-
simple.falsy 172, isHash(o)
|
|
112
|
-
simple.falsy 173, isHash(n)
|
|
113
|
-
simple.falsy 174, isHash(n2)
|
|
114
|
-
simple.falsy 175, isHash(s)
|
|
115
|
-
simple.falsy 176, isHash(s2)
|
|
116
|
-
|
|
117
|
-
simple.falsy 178, isArray(h)
|
|
118
|
-
simple.truthy 179, isArray(l)
|
|
119
|
-
simple.falsy 180, isArray(o)
|
|
120
|
-
simple.falsy 181, isArray(n)
|
|
121
|
-
simple.falsy 182, isArray(n2)
|
|
122
|
-
simple.falsy 183, isArray(s)
|
|
123
|
-
simple.falsy 184, isArray(s2)
|
|
124
|
-
|
|
125
|
-
simple.falsy 186, isString(h)
|
|
126
|
-
simple.falsy 187, isString(l)
|
|
127
|
-
simple.falsy 188, isString(o)
|
|
128
|
-
simple.falsy 189, isString(n)
|
|
129
|
-
simple.falsy 190, isString(n2)
|
|
130
|
-
simple.truthy 191, isString(s)
|
|
131
|
-
simple.truthy 192, isString(s2)
|
|
132
|
-
|
|
133
|
-
simple.falsy 194, isObject(h)
|
|
134
|
-
simple.falsy 195, isObject(l)
|
|
135
|
-
simple.truthy 196, isObject(o)
|
|
136
|
-
simple.falsy 197, isObject(n)
|
|
137
|
-
simple.falsy 198, isObject(n2)
|
|
138
|
-
simple.falsy 199, isObject(s)
|
|
139
|
-
simple.falsy 200, isObject(s2)
|
|
140
|
-
|
|
141
|
-
simple.falsy 202, isNumber(h)
|
|
142
|
-
simple.falsy 203, isNumber(l)
|
|
143
|
-
simple.falsy 204, isNumber(o)
|
|
144
|
-
simple.truthy 205, isNumber(n)
|
|
145
|
-
simple.truthy 206, isNumber(n2)
|
|
146
|
-
simple.falsy 207, isNumber(s)
|
|
147
|
-
simple.falsy 208, isNumber(s2)
|
|
148
|
-
|
|
149
|
-
)()
|
|
150
|
-
|
|
151
|
-
# ---------------------------------------------------------------------------
|
|
152
|
-
|
|
153
|
-
simple.truthy 214, isFunction(() -> pass)
|
|
154
|
-
simple.falsy 215, isFunction(23)
|
|
155
|
-
|
|
156
|
-
simple.truthy 217, isInteger(42)
|
|
157
|
-
simple.truthy 218, isInteger(new Number(42))
|
|
158
|
-
simple.falsy 219, isInteger('abc')
|
|
159
|
-
simple.falsy 220, isInteger({})
|
|
160
|
-
simple.falsy 221, isInteger([])
|
|
161
|
-
|
|
162
|
-
# ---------------------------------------------------------------------------
|
|
163
|
-
|
|
164
|
-
simple.equal 233, oneline(undef), "undef"
|
|
165
|
-
simple.equal 234, oneline("\t\tabc\nxyz"), "'\\t\\tabc\\nxyz'"
|
|
166
|
-
simple.equal 235, oneline({a:1, b:'xyz'}), '{"a":1,"b":"xyz"}'
|
|
167
|
-
|
|
168
|
-
# ---------------------------------------------------------------------------
|
|
169
|
-
|
|
170
|
-
simple.equal 239, CWS("""
|
|
171
|
-
a simple
|
|
172
|
-
error message
|
|
173
|
-
"""), "a simple error message"
|
|
174
|
-
|
|
175
|
-
# ---------------------------------------------------------------------------
|
|
176
|
-
# test croak()
|
|
177
|
-
|
|
178
|
-
(() ->
|
|
179
|
-
lLines = []
|
|
180
|
-
setLogger (line) -> lLines.push(line)
|
|
181
|
-
|
|
182
|
-
obj = {a:1, b:2}
|
|
183
|
-
try
|
|
184
|
-
croak "bad stuff", "An Object", obj
|
|
185
|
-
simple.equal 255, arrayToBlock(lLines), """
|
|
186
|
-
ERROR: bad stuff
|
|
187
|
-
An Object = {"a":1,"b":2}
|
|
188
|
-
"""
|
|
189
|
-
setLogger()
|
|
190
|
-
)()
|
|
191
|
-
|
|
192
|
-
# ---------------------------------------------------------------------------
|
|
193
|
-
# test isRegExp()
|
|
194
|
-
|
|
195
|
-
simple.truthy 265, isRegExp(/^abc$/)
|
|
196
|
-
simple.truthy 266, isRegExp(///^
|
|
197
|
-
\s*
|
|
198
|
-
where
|
|
199
|
-
\s+
|
|
200
|
-
areyou
|
|
201
|
-
$///)
|
|
202
|
-
simple.falsy 272, isRegExp(42)
|
|
203
|
-
simple.falsy 272, isRegExp('abc')
|
|
204
|
-
simple.falsy 272, isRegExp([1,'a'])
|
|
205
|
-
simple.falsy 272, isRegExp({a:1, b:'ccc'})
|
|
206
|
-
simple.falsy 272, isRegExp(undef)
|
|
207
|
-
|
|
208
|
-
simple.truthy 278, isRegExp(/\.coffee/)
|
|
209
|
-
|
|
210
|
-
# ---------------------------------------------------------------------------
|
|
211
|
-
|
|
212
|
-
simple.equal 212, extractMatches("..3 and 4 plus 5", /\d+/g, parseInt),
|
|
213
|
-
[3, 4, 5]
|
|
214
|
-
simple.equal 214, extractMatches("And This Is A String", /A/g), ['A','A']
|