tree-sitter

tree-sitter fun
2020-09-08T01:25:22.029200Z

i've started using test.check and hypothesis (python testing library) to write some property-based tests. in both cases i'm using python's tree-sitter bindings to access tree-sitter functionality. for test.check / clojure, i've succeeded in doing this via libpython-clj. here's how a generator in test.check is looking for radix numbers: https://gist.github.com/sogaiu/41c5de864e2af77ef3dfb520e4e4707f in hypothesis, something comparable might look like: https://gist.github.com/sogaiu/68190262c5c50ea17d0cb54111a03f06 for using hypothesis, here's how putting the bits together can look: https://gist.github.com/sogaiu/45684afcbc37818b4651bcc550616ee9 one reason to consider hypothesis is that apparently it doesn't have "the bind problem" that test.check has: https://github.com/clojure/test.check/blob/master/doc/growth-and-shrinking.md#unnecessary-bind

2020-09-08T01:26:06.029600Z

note that the generator portions should be usable for other grammars too -- e.g. parcera.

2020-09-08T01:29:30.029900Z

a little bit more for how things look with test.check: https://gist.github.com/sogaiu/77f2bc36be4cbe41fd2363edcd740d2b

2020-09-08T01:47:23.034100Z

was wondering if there were some approach that would allow avoiding the writing of generators manually and came across this: https://github.com/kanaka/instacheck since parcera used to use instaparse, i took the latest version of that grammar i could find and updated it (not quite the latest, but fwiw: https://gist.github.com/sogaiu/2c0cdfc2193474679651f6fc8a3a49c0) to try with instacheck. unfortunately, instacheck appears to not quite be at the point of handling the instaparse grammar -- i think because of this: https://github.com/kanaka/instacheck/blob/ba2095f9b9691812342c54100cd7de83a5b9a74d/src/instacheck/codegen.cljc#L136 (cool project though -- there's even a strangeloop talk by the author that touches a bit on its use for a specific purpose) for the moment it seems the manual writing of generators is what i think i'll pursue.