alexei / sprintf.js

sprintf.js is a complete open source JavaScript sprintf implementation
BSD 3-Clause "New" or "Revised" License
2.11k stars 291 forks source link

#181 %.f fails with unexpected placeholder #188

Open ashwalk33r opened 4 years ago

ashwalk33r commented 4 years ago

fix https://github.com/alexei/sprintf.js/issues/181

change regex matching precision in order to reflect C documentation: "if the period is specified without an explicit value for precision, 0 is assumed"

alexei commented 4 years ago

Please provide unit tests

ashwalk33r commented 4 years ago

To be honest I do not know sprintf - what types of input are good to include in test? Can you guide me a little?

Basicly I change how ".precision" is interpreted - from digit(s) to digit(s) or 0 - what would be enough coverage in unit tests for that?

Idea 1 take existing precision tests (there is few) and change their precision to nothing and compare with .0

Idea 2 http://www.cplusplus.com/reference/cstdio/printf/ cover every case described in ".precision | description" section

Idea 3 Any place already containing tests that you know about (can be in diff language) that we can inspire from?

ashwalk33r commented 4 years ago

Best tests I could think of added.

ricksterhd123 commented 4 years ago

Bump

ashwalk33r commented 4 years ago

bump?

ricksterhd123 commented 4 years ago

bump?

Can't remember why but I think this PR fixed some issue on another repo. Test still not good enough? It's been months.

ashwalk33r commented 2 years ago

alexei doesnt care apperantly

d0sboots commented 3 months ago

Can't remember why but I think this PR fixed some issue on another repo. Test still not good enough? It's been months.

The other repo/issue is https://github.com/fengari-lua/fengari/issues/147 (still blocked on this, 5 years later). Just ran into this one myself. XD