aboutsummaryrefslogtreecommitdiff
path: root/node_modules/flatten/test.js
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/flatten/test.js
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/flatten/test.js')
-rw-r--r--node_modules/flatten/test.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/node_modules/flatten/test.js b/node_modules/flatten/test.js
new file mode 100644
index 00000000..385c27fa
--- /dev/null
+++ b/node_modules/flatten/test.js
@@ -0,0 +1,25 @@
+var flatten = require('./index'),
+ util = require('util'),
+ assert = require('assert');
+
+[
+ [ [1, [ 2, 3]], [1, [2, 3]], 0],
+ [ [1, 2, 3 ], [1, 2, 3] ],
+ [ ['a', ['b', ['c']]], ['a', 'b', 'c'] ],
+ [ [2, [4, 6], 8, [[10]]], [2, 4, 6, 8, 10] ],
+ [ [1, [2, [3, [4, [5]]]]], [1, 2, 3, [4, [5]]], 2 ] // depth of 2
+].forEach(function (t) {
+ assert.deepEqual(flatten(t[0], t[2]), t[1],
+ util.format('☠☠☠☠☠☠☠☠☠ %s ☠☠☠☠☠☠☠☠☠', formatCall(t))
+ );
+ console.log('✓ %s', formatCall(t));
+});
+
+function formatCall(t) {
+ if (typeof t[2] === 'undefined') {
+ return util.format('`flatten(%j) == %j`', t[0], t[1]);
+ }
+ else {
+ return util.format('`flatten(%j, %j) == %j`', t[0], t[2], t[1]);
+ }
+}