deno.land / x / rambda@v9.1.1 / source / constructN.spec.js

constructN.spec.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { constructN } from './constructN'import { constructN as constructNRamda } from 'ramda'
test('happy', () => { const result = constructN() console.log(result)})
/*var assert = require('assert');
var R = require('../source/index.js');var eq = require('./shared/eq.js');

describe('constructN', function() { var Circle = function(r) { this.r = r; this.colors = Array.prototype.slice.call(arguments, 1); }; Circle.prototype.area = function() {return Math.PI * Math.pow(this.r, 2);};
it('turns a constructor function into a function with n arguments', function() { var circle = R.constructN(2, Circle); var c1 = circle(1, 'red'); eq(c1.constructor, Circle); eq(c1.r, 1); eq(c1.area(), Math.PI); eq(c1.colors, ['red']);
var regex = R.constructN(1, RegExp); var pattern = regex('[a-z]'); eq(pattern.constructor, RegExp); eq(pattern.source, '[a-z]'); });
it('can be used to create Date object', function() { var date = R.constructN(3, Date)(1984, 3, 26); eq(date.constructor, Date); eq(date.getFullYear(), 1984); });
it('supports constructors with no arguments', function() { function Foo() {} var foo = R.constructN(0, Foo)(); eq(foo.constructor, Foo); });
it('does not support constructor with greater than ten arguments', function() { assert.throws(function() { function Foo($0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) { this.eleventh = $10; } R.constructN(11, Foo); }, function(err) { return (err instanceof Error && err.message === 'Constructor with greater than ten arguments'); }); });
});
*/
rambda

Version Info

Tagged at
2 months ago