Ian Bicking
Ian Bicking
Print serves a lot of purposes, like in the Spy case. But I can see how a second form could be interesting, in the general pattern of: ``` // (expression)...
Spies work like this: ``` function Spy(name) { return function () { var a = repr(args); print(name + '(' + a.substr(0, a.length-2) + ')'); }; } ``` That is, print...
No, Spies actually call `print()`. You might find the pseudocode in this section useful: http://doctestjs.org/reference.html#wait Every block of code between `// =>` comments is executed in its entirety. All calls...
`value // => 42` would be cool, but not easy to implement. But if someone wants to take it on, sure!
This is old-style (inline in HTML and using the doctest format), but it's longish: https://github.com/mozilla/receiptverifier/blob/master/test.html I don't think this would be that helpful for that test – I watch for...
Which example are you looking at that isn't right? I see this one in the tutorial: ``` javascript var endpoint = location.href; print(endpoint); // => ... var req = new...
Well huh, I just now realize it says `Current state: 1` – that's not right. Well, no, it's right... it's an example of the somewhat weird nature of `watch()`, but...
At a certain point having large bits of logic between tests seems like it's encouraging some questionable complexity. You can still use things like `` to share code between tests...
What I do in practice is this: ``` javascript foo(); wait(condition); // => print(fooDone); // => true ``` That is, a dummy/empty `// =>` causes the wait to actually happen....
I agree a simple "or" is probably good enough, instead of conditional expressions. But maybe like: ``` javascript // => Error: TypeError Cannot ... // OR => Error: TypeError: x...