From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/flatten/test.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 node_modules/flatten/test.js (limited to 'node_modules/flatten/test.js') 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]); + } +} -- cgit v1.2.3