News for hackers. Stuff that matters.
Re:Pyret: A new programming language from the creators of Ra... by jacques_chester on Saturday November 09, 2013 @10:11AM (#6701796)
D has something like this[1]. It might have come from a still-earlier language.

[1] http://dlang.org/unittest.html

Re:Pyret: A new programming language from the creators of Ra... by sparkie on Saturday November 09, 2013 @11:53AM (#6702173)
My biggest gripe with these is the inability to name the tests. What exactly is a unittest block testing for? You need to rely on comments or read the test code where none exists. Doesn't seem like Pyret fixed that issue.
Re:Pyret: A new programming language from the creators of Ra... by skrishnamurthi on Saturday November 09, 2013 @01:38PM (#6702564)
Everything is fixable in a new language (-:. Say more!
Re:Pyret: A new programming language from the creators of Ra... by akkartik on Saturday November 09, 2013 @03:37PM (#6703078)
One of my favorite things about tests is that they let me read a new codebase more interactively. If I don't understand why a function is built like this and not that I can rewrite it the new way, run the tests. Without names I'd know I broke something, but with a good name I'll often realize why that something matters in the big picture.

(I think about tests a lot: http://akkartik.name/post/tracing-tests)

Re:Pyret: A new programming language from the creators of Ra... by skrishnamurthi on Saturday November 09, 2013 @06:58PM (#6704219)
I understand your point. One thing I pushed for initially, dropped because we had bigger fish to fry, and will revisit later, is the idea that you should be able to name everything: not just tests but an individual variant in your data definition, lines of code, etc. And this should be intrinsic to the language.

That said, I couldn't see what your post had to do with this concept; if I've missed something, please explain. (As an aside, I believe this -- http://cs.brown.edu/~sk/Publications/Papers/Published/mcskr-... -- generalizes the idea in your tracing post.)

Re:Pyret: A new programming language from the creators of Ra... by akkartik on Saturday November 09, 2013 @09:32PM (#6704845)
Thanks. My post wasn't about names, I was just looking for feedback. Which I got; thanks.
Re:Pyret: A new programming language from the creators of Ra... by alexatkeplar on Saturday November 09, 2013 @08:42PM (#6704669)
I would like it if the `where` tests supported DataTables for a slightly more declarative style. Here's an example from Scala/Specs2: https://github.com/snowplow/snowplow/blob/master/3-enrich/ha...
Re:Pyret: A new programming language from the creators of Ra... by skrishnamurthi on Sunday November 10, 2013 @08:48AM (#6706398)
The fact that they don't now doesn't mean they can't in future!

One of the advantages of having a separate block for tests is we can do things in that block that won't necessarily pervade the whole language where it might not make sense (which we already do: eg, the keywords "is" and "satisfies"). We've all done some sort of "here's a list of tuples, now map the prefix of this as arguments and the suffix as the expected value over this function", so it is something on our mind.

But I've struggled a bit to find a good way of writing it. We've written a few things where it looked truly "naked" to have these tuples without the surrounding function call. So it's as much a matter of syntax design as anything else.

I must say that the code on that page does not look like something I want to copy; it looks like a good compromise, but with emphasis on both words. We don't need to compromise.

Re:Pyret: A new programming language from the creators of Ra... by alexatkeplar on Sunday November 10, 2013 @02:09PM (#6707936)
If you can up with a cleaner syntax for test data tables that would be awesome, thanks Shriram.
Re:Pyret: A new programming language from the creators of Ra... by sitkack on Saturday November 09, 2013 @02:10PM (#6702716)
Could the tests be more declarative, defining properties over a space?
Re:Pyret: A new programming language from the creators of Ra... by skrishnamurthi on Saturday November 09, 2013 @05:31PM (#6703685)
Absolutely! Pyret's test section has a "satisfies" keyword for property tests. E.g.:

  check:
    insert(a-value, a-balanced-tree) satisfies is-balanced
  end
or even

  check:
    tree-examples = [ ... ]
    values = [ ... ]
    for each2(t in tree-examples, v in values):
      insert(t, v) satisfies is-rbtree
    end
  end
Re:Pyret: A new programming language from the creators of Ra... by amenod on Saturday November 09, 2013 @02:08PM (#6702705)
That's an advantage in my book... it is testing the unit (function in this case) and it is testing all the corner cases... do you have a name for each of them? Description through comments is much more suitable IMHO.
Re:Pyret: A new programming language from the creators of Ra... by lukeschlather on Saturday November 09, 2013 @04:31PM (#6703335)
I really hate some things about the Rspec/Cucumber suite, but providing a way to output what the tests are testing as they run is a major advantage. I like being able to run my test suite and see "it does what it's supposed to do in this case" output.

At a glance, the Pyret default appears to be that tests run silently. How do I know the right tests were run?

Re:Pyret: A new programming language from the creators of Ra... by mercurial on Saturday November 09, 2013 @04:39PM (#6703374)
Corner cases? Tests test the behaviour of the function. Functions, depending on their complexity, have a range of behaviour. And yes, you should (usually) be able to come up with a name for it. As a bonus, you'll get immediately an idea of what broke upon test failure.