My Kind of REPL
ianthehenry.com
ianthehenry.com
I use REPLs in ways that are similar to yours, but 1) you have several tricks that are new to me, and 2) you've been able to put into words many ideas that I haven't!
My way is here,
http://anggtwu.net/eepitch.html
and I'm certainly going to cite you in my presentation in the next EmacsConf! =)
Example of use: the ## comments and #. outputs in https://github.com/darius/sturm/blob/master/tictactoe.py#L20...
(It'll need a Python 3 update if you're more up with the times than me.)
Like smalltalk.
This works for regression tests, and documentation, but not so much for something like TDD, where the test is more like (or should be) a specification for the program you are about to write.
Really interesting stuff I'm going to play with personally and in school I think. Thank you.
One thing that is a little different is that this type of testing makes it easier to write "counterfactual" tests, which are sort of similar: you observe the behavior of a function with input A, and then you make an interesting tweak to the input to get input B, and you can see how the output changes (you can even print the diff between the two outputs in your test). This is useful for ensuring that a test is actually testing exactly the thing that you want it to test -- if you have a test that "X fails validation when Y is Z," you can ensure that the only difference between a failing and a passing X is the value of Y, whereas if you only test that "X with Y=Z fails," you won't be totally confident that the failure is due to Y or due to some other newly introduced E. I think that the ability to print diffs between inputs and outputs makes this kind of REPL test a lot easier to read and write in this case.