forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintersection.js
34 lines (27 loc) · 1.1 KB
/
intersection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
var {Just} = require('./shared/Maybe.js');
describe('intersection', function() {
var M = [1, 2, 3, 4];
var M2 = [1, 2, 3, 4, 1, 2, 3, 4];
var N = [3, 4, 5, 6];
var N2 = [3, 3, 4, 4, 5, 5, 6, 6];
it('combines two lists into the set of common elements', function() {
eq(R.intersection(M, N), [3, 4]);
});
it('does not allow duplicates in the output even if the input lists had duplicates', function() {
eq(R.intersection(M2, N2), [3, 4]);
});
it('does not allow duplicates in the output even if the first list is bigger and has duplicates', function() {
eq(R.intersection(M2, N), [3, 4]);
});
it('does not allow duplicates in the output even if the second list is bigger and has duplicates', function() {
eq(R.intersection(M, N2), [3, 4]);
});
it('has R.equals semantics', function() {
eq(R.intersection([0], [-0]).length, 0);
eq(R.intersection([-0], [0]).length, 0);
eq(R.intersection([NaN], [NaN]).length, 1);
eq(R.intersection([new Just([42])], [new Just([42])]).length, 1);
});
});