GildedRose-Refactoring-Kata
GildedRose-Refactoring-Kata copied to clipboard
Gilded rose in Nim
It may be interesting to see how this is refactored in Nim. Particularly I'd be interested to see if anyone gets it to the point of being able to write a macro.
It doesn't have support for texttest, but it uses Nim's unittest module and picks a few critical test cases, so it should be fairly usable by just running that module.
Also Nim's object model prefering value semantics over reference semantics required a small top level API change where rather than a command pattern class, I just have a function.
Thankyou so much for taking the time to translate to Nim!
About the unit test - it is too good I'm afraid. There should be two starting positions. One is a single, failing unit test. The other is a texttest fixture. The fixture is just a main function that prints stuff. I'm not sure what you mean by "it doesn't have support for texttest"? Surely you can print stuff to the console from Nim?
The failing unit test would be
import unittest
import ../src/items
import ../src/gildedrose
suite "Gilded Rose":
test "foo":
var items = @[initItem("foo", 0, 0)]
items.updateQuality()
check items[0].name == "fixme"
If that would be enough I will try to modify this PR
Thanks, yes please
Checked out PR, modified the test and merged manually. Thank you.