Add lab 10 content
This commit is contained in:
31
labs/L10/spec/arrays.spec.js
Normal file
31
labs/L10/spec/arrays.spec.js
Normal file
@ -0,0 +1,31 @@
|
||||
let array=require("../arrays.js");
|
||||
|
||||
describe("range", function () {
|
||||
it("empty", function () {
|
||||
expect(array.range(2,1)).toEqual([]);
|
||||
});
|
||||
it("single", function () {
|
||||
expect(array.range(2,2)).toEqual([2]);
|
||||
});
|
||||
it("multiple", function () {
|
||||
expect(array.range(42,50)).toEqual([42,43,44,45,46,47,48,49,50]);
|
||||
});
|
||||
it("step", function() {
|
||||
expect(array.range(2,10,2)).toEqual([2,4,6,8,10]);
|
||||
})
|
||||
});
|
||||
|
||||
describe("sum", function () {
|
||||
it("empty", function () {
|
||||
expect(array.sum([])).toBe(0);
|
||||
});
|
||||
it("single", function () {
|
||||
expect(array.sum([2])).toBe(2);
|
||||
});
|
||||
it("multiple", function () {
|
||||
expect(array.sum(array.range(1,10))).toBe(55);
|
||||
})
|
||||
it("stepped", function() {
|
||||
expect(array.sum(array.range(2,10,2))).toBe(30)
|
||||
});
|
||||
});
|
30
labs/L10/spec/rec_arith.spec.js
Normal file
30
labs/L10/spec/rec_arith.spec.js
Normal file
@ -0,0 +1,30 @@
|
||||
let arith=require ("../rec-arith.js");
|
||||
|
||||
describe("plus",
|
||||
function() {
|
||||
it("1 + 1 = 2",
|
||||
function() {
|
||||
expect(arith.plus(1, 1)).toBe(2);
|
||||
});
|
||||
it("0 + x = x",
|
||||
function() {
|
||||
expect(arith.plus(0, 1)).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("mult",
|
||||
function() {
|
||||
it("0 * 2 = 0",
|
||||
function() {
|
||||
expect(arith.mult(0, 2)).toBe(0);
|
||||
});
|
||||
|
||||
it("1 * 2 = 2",
|
||||
function() {
|
||||
expect(arith.mult(1,2)).toBe(2);
|
||||
});
|
||||
it("2 * 2 = 4",
|
||||
function() {
|
||||
expect(arith.mult(2, 2)).toBe(4);
|
||||
});
|
||||
});
|
31
labs/L10/spec/rec_vs_loop.spec.js
Normal file
31
labs/L10/spec/rec_vs_loop.spec.js
Normal file
@ -0,0 +1,31 @@
|
||||
let loop_arith=require ("../loop-arith.js");
|
||||
let rec_arith=require ("../rec-arith.js");
|
||||
|
||||
describe("plus",
|
||||
function() {
|
||||
it("1 + 1 = 2",
|
||||
function() {
|
||||
expect(loop_arith.plus(1, 1)).toBe(rec_arith.plus(1, 1));
|
||||
});
|
||||
it("0 + x = x",
|
||||
function() {
|
||||
expect(loop_arith.plus(0, 1)).toBe(rec_arith.plus(0, 1));
|
||||
});
|
||||
});
|
||||
|
||||
describe("mult",
|
||||
function() {
|
||||
it("0 * 2 = 0",
|
||||
function() {
|
||||
expect(loop_arith.mult(0, 2)).toBe(rec_arith.mult(0, 2));
|
||||
});
|
||||
|
||||
it("1 * 2 = 2",
|
||||
function() {
|
||||
expect(loop_arith.mult(1, 2)).toBe(rec_arith.mult(1, 2));
|
||||
});
|
||||
it("2 * 2 = 4",
|
||||
function() {
|
||||
expect(loop_arith.mult(2, 2)).toBe(rec_arith.mult(2, 2));
|
||||
});
|
||||
});
|
13
labs/L10/spec/support/jasmine.json
Normal file
13
labs/L10/spec/support/jasmine.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*[sS]pec.?(m)js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.?(m)js"
|
||||
],
|
||||
"env": {
|
||||
"stopSpecOnExpectationFailure": false,
|
||||
"random": true
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user