Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix random number digit #34

Merged
merged 1 commit into from
Dec 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/faker/provider/util.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import macros, random
from strformat import `&`
from strutils import join, align
from math import `^`

macro genProc*(names, modules: untyped): untyped =
## プロシージャ定義を生成する。 `names` がプロシージャ名、 `modules` はプロシ
Expand Down Expand Up @@ -42,7 +43,8 @@ macro genProc*(names, modules: untyped): untyped =

proc formatNumbers*(r: var Rand, format: string): string =
proc alignFmt(r: var Rand, buf: string): string =
let num = $r.rand(1..buf.len)
let max = 10 ^ buf.len - 1
let num = $r.rand(1..max)
result = num.align(buf.len, '0')

var buf: string
Expand Down