1 | var test = require('tape');
|
2 | var quote = require('../').quote;
|
3 |
|
4 | test('quote', function (t) {
|
5 | t.equal(quote([ 'a', 'b', 'c d' ]), 'a b \'c d\'');
|
6 | t.equal(
|
7 | quote([ 'a', 'b', "it's a \"neat thing\"" ]),
|
8 | 'a b "it\'s a \\"neat thing\\""'
|
9 | );
|
10 | t.equal(
|
11 | quote([ '$', '`', '\'' ]),
|
12 | '\\$ \\` "\'"'
|
13 | );
|
14 | t.equal(quote([]), '');
|
15 | t.equal(quote(["a\nb"]), "'a\nb'");
|
16 | t.equal(quote([' #(){}*|][!']), "' #(){}*|][!'");
|
17 | t.equal(quote(["'#(){}*|][!"]), '"\'#(){}*|][\\!"');
|
18 | t.equal(quote(["X#(){}*|][!"]), "X\\#\\(\\){}\\*\\|][\\!");
|
19 | t.equal(quote(["a\n#\nb"]), "'a\n#\nb'");
|
20 | t.equal(quote([ 'a', 1, true, false ]), 'a 1 true false');
|
21 | t.equal(quote([ 'a', 1, null, undefined ]), 'a 1 null undefined');
|
22 | t.end();
|
23 | });
|
24 |
|
25 | test('quote ops', function (t) {
|
26 | t.equal(quote([ 'a', { op: '|' }, 'b' ]), 'a \\| b');
|
27 | t.equal(
|
28 | quote([ 'a', { op: '&&' }, 'b', { op: ';' }, 'c' ]),
|
29 | 'a \\&\\& b \\; c'
|
30 | );
|
31 | t.end();
|
32 | });
|