This repository has been archived by the owner on Dec 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Procedure.js
47 lines (47 loc) · 1.98 KB
/
Procedure.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
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports", '../../../../../source/System/Collections/Array/Procedure'], factory);
}
})(function (require, exports) {
"use strict";
var ArrayProcedure = require('../../../../../source/System/Collections/Array/Procedure');
var assert = require('../../../../../node_modules/assert/assert');
var minA = -10, maxA = 2000, minB = -Infinity, maxB = Infinity, a = [5, minA, -1, maxA, -2, NaN, 20], b = [5, 2000, maxB, -1, NaN, -10, minB, -2, 20], sum = 5 + minA + (-1) + maxA + (-2) + 20, average = sum / 6, product = 5 * minA * (-1) * maxA * (-2) * 20;
function procedureShouldBe(source, value, p) {
it('should be NaN', function () {
assert.ok(isNaN(p(source, false)));
});
it('should be ' + value, function () {
assert.equal(p(source, true), value);
});
}
describe(".sum(source)", function () {
procedureShouldBe(a, sum, ArrayProcedure.sum);
});
describe(".average(source)", function () {
procedureShouldBe(a, average, ArrayProcedure.average);
});
describe(".product(source)", function () {
procedureShouldBe(a, product, ArrayProcedure.product);
});
describe(".min(source)", function () {
describe("a", function () {
procedureShouldBe(a, minA, ArrayProcedure.min);
});
describe("b", function () {
procedureShouldBe(b, minB, ArrayProcedure.min);
});
});
describe(".max(source)", function () {
describe("a", function () {
procedureShouldBe(a, maxA, ArrayProcedure.max);
});
describe("b", function () {
procedureShouldBe(b, maxB, ArrayProcedure.max);
});
});
});
//# sourceMappingURL=Procedure.js.map