up
This commit is contained in:
parent
d7d25f4d8b
commit
20784e7f26
48 changed files with 302 additions and 397 deletions
|
@ -1,26 +1,25 @@
|
|||
var calculator;
|
||||
before(function() {
|
||||
calculator = new Calculator;
|
||||
});
|
||||
describe("Calculator", function() {
|
||||
let calculator;
|
||||
|
||||
it("calculate(12 + 34) = 46", function() {
|
||||
assert.equal(calculator.calculate("12 + 34"), 46);
|
||||
});
|
||||
|
||||
it("calculate(34 - 12) = 22", function() {
|
||||
assert.equal(calculator.calculate("34 - 12"), 22);
|
||||
});
|
||||
|
||||
it("добавили умножение: calculate(2 * 3) = 6", function() {
|
||||
calculator.addMethod("*", function(a, b) {
|
||||
return a * b;
|
||||
before(function() {
|
||||
calculator = new Calculator;
|
||||
});
|
||||
assert.equal(calculator.calculate("2 * 3"), 6);
|
||||
});
|
||||
|
||||
it("добавили возведение в степень: calculate(2 ** 3) = 8", function() {
|
||||
calculator.addMethod("**", function(a, b) {
|
||||
return Math.pow(a, b);
|
||||
it("calculate(12 + 34) = 46", function() {
|
||||
assert.equal(calculator.calculate("12 + 34"), 46);
|
||||
});
|
||||
assert.equal(calculator.calculate("2 ** 3"), 8);
|
||||
});
|
||||
|
||||
it("calculate(34 - 12) = 22", function() {
|
||||
assert.equal(calculator.calculate("34 - 12"), 22);
|
||||
});
|
||||
|
||||
it("add multiplication: calculate(2 * 3) = 6", function() {
|
||||
calculator.addMethod("*", (a, b) => a * b);
|
||||
assert.equal(calculator.calculate("2 * 3"), 6);
|
||||
});
|
||||
|
||||
it("add power: calculate(2 ** 3) = 8", function() {
|
||||
calculator.addMethod("**", (a, b) => a ** b);
|
||||
assert.equal(calculator.calculate("2 ** 3"), 8);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue