beautify_js

This commit is contained in:
Ilya Kantor 2015-03-09 18:48:58 +03:00
parent 0febe4f5fd
commit 5c2f32e184
208 changed files with 3891 additions and 1474 deletions

View file

@ -1,7 +1,7 @@
function Calculator() {
this.read = function() {
this.a = +prompt('a?', 0);
this.a = +prompt('a?', 0);
this.b = +prompt('b?', 0);
};

View file

@ -11,11 +11,11 @@ describe("calculator", function() {
});
it("при вводе 2 и 3 сумма равна 5", function() {
assert.equal( calculator.sum(), 5 );
assert.equal(calculator.sum(), 5);
});
it("при вводе 2 и 3 произведение равно 6", function() {
assert.equal( calculator.mul(), 6 );
assert.equal(calculator.mul(), 6);
});
});

View file

@ -5,4 +5,4 @@ function Accumulator(startingValue) {
this.value += +prompt('Сколько добавлять будем?', 0);
};
}
}

View file

@ -13,25 +13,25 @@ describe("Accumulator(1)", function() {
});
it("начальное значение 1", function() {
assert.equal( accumulator.value, 1 );
assert.equal(accumulator.value, 1);
});
it("после ввода 0 значение 1", function() {
prompt.returns("0");
accumulator.read();
assert.equal( accumulator.value, 1 );
assert.equal(accumulator.value, 1);
});
it("после ввода 1 значение 2", function() {
prompt.returns("1");
accumulator.read();
assert.equal( accumulator.value, 2 );
assert.equal(accumulator.value, 2);
});
it("после ввода 2 значение 4", function() {
prompt.returns("2");
accumulator.read();
assert.equal( accumulator.value, 4 );
assert.equal(accumulator.value, 4);
});
});

View file

@ -16,7 +16,7 @@ function Calculator() {
op = split[1],
b = +split[2]
if(!methods[op] || isNaN(a) || isNaN(b)) {
if (!methods[op] || isNaN(a) || isNaN(b)) {
return NaN;
}
@ -26,4 +26,4 @@ function Calculator() {
this.addMethod = function(name, func) {
methods[name] = func;
};
}
}

View file

@ -4,23 +4,23 @@ before(function() {
});
it("calculate(12 + 34) = 46", function() {
assert.equal( calculator.calculate("12 + 34"), 46 );
assert.equal(calculator.calculate("12 + 34"), 46);
});
it("calculate(34 - 12) = 22", function() {
assert.equal( calculator.calculate("34 - 12"), 22 );
assert.equal(calculator.calculate("34 - 12"), 22);
});
it("добавили умножение: calculate(2 * 3) = 6", function() {
calculator.addMethod("*", function(a, b) {
return a * b;
});
assert.equal( calculator.calculate("2 * 3"), 6 );
assert.equal(calculator.calculate("2 * 3"), 6);
});
it("добавили возведение в степень: calculate(2 ** 3) = 8", function() {
calculator.addMethod("**", function(a, b) {
return Math.pow(a, b);
});
assert.equal( calculator.calculate("2 ** 3"), 8 );
});
assert.equal(calculator.calculate("2 ** 3"), 8);
});