Skip to content

Commit

Permalink
✨ 【第7章 疑念をテストに翻訳する】Money から派生した Franc と Dollar は同じはずなのでそれの比較を追加する
Browse files Browse the repository at this point in the history
・Franc と Dollar を比較し同じことだという疑念をはらす
・Money クラスで equals は amount の比較を行っているが TypeScript が Cast を行ってくれているため、動作するようになっている(Javaだと落ちる
  • Loading branch information
dodonki1223 committed Dec 12, 2021
1 parent e8384a9 commit 870259b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
- [ ] Dollar と Franc の重複
- [x] equalsの一般化
- [ ] timesの一般化
- [x] FrancとDollarの比較
8 changes: 8 additions & 0 deletions src/__tests__/money.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Dollar } from '../dollar';
import { Franc } from '../franc';
import { Money } from '../money';

test('equals', () => {
Expand All @@ -10,3 +12,9 @@ test('null equals', () => {

expect(five.equals(null)).toBeFalsy();
});

test('equals Franc = Dollar', () => {
expect(new Franc(5).equals(new Dollar(5))).toBeTruthy();
expect(new Franc(5).equals(new Dollar(6))).toBeFalsy();
});

0 comments on commit 870259b

Please sign in to comment.