Skip to content

Commit

Permalink
examples into tests
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jul 25, 2013
1 parent c55c2e3 commit 0164011
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
File renamed without changes.
14 changes: 14 additions & 0 deletions test/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var copy = require('../');
var test = require('tape');

test('array', function (t) {
t.plan(2);

var xs = [ 3, 4, 5, { f: 6, g: 7 } ];
var dup = copy(xs);
dup.unshift(1, 2);
dup[5].g += 100;

t.deepEqual(xs, [ 3, 4, 5, { f: 6, g: 107 } ]);
t.deepEqual(dup, [ 1, 2, 3, 4, 5, { f: 6, g: 107 } ]);
});
14 changes: 14 additions & 0 deletions test/object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var copy = require('../');
var test = require('tape');

test('object', function (t) {
t.plan(2);

var obj = { a: 3, b: 4, c: [5,6] };
var dup = copy(obj);
dup.b *= 111;
dup.c.push(7);

t.deepEqual(obj, { a: 3, b: 4, c: [ 5, 6, 7 ] });
t.deepEqual(dup, { a: 3, b: 444, c: [ 5, 6, 7 ] });
});

0 comments on commit 0164011

Please sign in to comment.