Skip to content

Commit

Permalink
feat(calculator.ts): add cos method
Browse files Browse the repository at this point in the history
  • Loading branch information
gfmio committed Mar 7, 2019
1 parent 625d369 commit fafa42c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ export default class Calculator {
this.current = Math.sin(this.current);
return this;
}

public cos() {
this.current = Math.cos(this.current);
return this;
}
}
1 change: 1 addition & 0 deletions tests/Calculator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe("Calculator", () => {

it("can clear", () => expect(calculator.clear().value()).equal(0));
it("can sin", () => expect(calculator.sin().value()).equal(0));
it("can cos", () => expect(calculator.cos().value()).equal(1));

it("has the correct initial value when no argument is supplied", () => expect(new Calculator().value()).equal(0));
it("has the correct initial value when an argument is supplied", () => expect(new Calculator(3).value()).equal(3));
Expand Down

0 comments on commit fafa42c

Please sign in to comment.