Closed Maltysen closed 9 years ago
Cool feature. However I don't like it, that the tests have a fixed line count. Sometimes the line count varies. Maybe the tests should simply be separated by a line like ====================
.
And there's a bug. Try this link. It shows 'Regular Input', but runs the test-suite.
@jakobkogler ah no that's the intended behavior, but maybe its not clear. That link is supposed to indicate the other textbox, kind of like pause/play. Maybe I should use an actual chevron glyph instead of ->
Ah, I see.
Why not name it Switch to ...
Good idea, updated. I don't really think variable length inputs are common enough to be worth the extra trouble for the constant length ones. I guess we'll wait for issacg1 to decide.
I like the switch to
change. I can't actually try it out, because the VM is asleep. Also, I don't think variable length inputs are all that common, and needing to include ===================
is rather unintuitive. I like it how it is. I'll merge once I can check it out on the Koding VM. @Maltysen
The code has a bug in submit_test_suite()
:
If input_size
is larger than the number of lines in the input, inputs
is an empty list, and inputs[0]
throws an error. This leads to the website hanging, as you can see in this test case.
I don't really care about the output in this, such as an error message, no output, or whatever, but the website shouldn't hang. @Maltysen
@isaacg1 it just returns an empty string now, by doing if inputs else ""
.
Excellent. All right, that was the only bug I found, so I'm going to merge.
Adding scaffolding to existing code to make test suites is annoying, messes up byte counts, and does not work with multi-line inputs. So I added that to the online interpreter.
Above the normal input textbox, there is a gray link which says "Test Suite ->":
Then when you click on that, it changes the textbox to another one and adds numeric input for input size:
When you run it, it runs all of them, and then returns their outputs, separated by linebreaks. The debug parameter is only honored on the first test, the rest all have no debug:
The permalinks all also work pretty naturally. Both textboxes are preserved over permalinks, though obviously, it also preserves which one was the current one.
Internally, I have encapsulated the code running in a function, and made two separate handlers for regular submissions and test suites.
I have hosted a live copy on my Koding VM here: http://maltysen.koding.io/ to play around on for bugs & suggestions before deciding on the pull request. I have not done animations for the boxes, but if you think its necessary, I can add it.