This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Combined toI, toS and regexp method into a single object so that mistakes a more obv since related methods are closer together. This also enabled us to extract more complex formatters into single files which might be neccessary for mod_value_to_item_class
- Loading branch information
Showing
8 changed files
with
285 additions
and
189 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* formats a given numberic value to string | ||
*/ | ||
export default interface Formatter { | ||
/** | ||
* | ||
* @param n | ||
*/ | ||
format(n: number): string; | ||
/** | ||
* inverse of #format | ||
* @param s returnval from #format() | ||
*/ | ||
inverse(s: string): number; | ||
/** | ||
* RegExp to match the value in the formatted string | ||
*/ | ||
regexp: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {NUMBER} from '../regexp_util'; | ||
|
||
it('can match hole numbers', () => { | ||
const regexp = new RegExp(`^${NUMBER}$`); | ||
expect(regexp.test(`${5}`)).toBe(true); | ||
expect(regexp.test(`${-123}`)).toBe(true); | ||
expect(regexp.test(`${-0}`)).toBe(true); | ||
expect(regexp.test(`${+0}`)).toBe(true); | ||
expect(regexp.test(`${-9.5}`)).toBe(false); | ||
expect(regexp.test(`${13.5}`)).toBe(false); | ||
}) |
Oops, something went wrong.