5 ms·
Ask HN: Is there a programming language with embedded testing support?
There are many dimensions to programming languages that range from systems to scripting, weakly typed to strongly typed, dynamic to static typed, purely functional to statefull, imperative to declarative, etc...
There are also very few languages that focus on correctness and contracts to help create programs that have fewer bugs. Yet The mayority of languages simply focus on "getting things done", so to speak, and leave testing and correctness out of the picture or add them later on.
Granted, testing support can be added later via libraries and frameworks, but I wonder: in the continuum of program correctness, is there a language that perhaps does not provide full proof/correctness/contract support but does come with testing right out of the box, either in its implementation or philosophy?
Also related question: do you know of any language that was specifically designed to encourage and/or make testing easier for its programs?
Even though I didn't get the "joke" for a recent post about Go[0], I still think it's interesting to ask.
[0] https://news.ycombinator.com/item?id=12371029
- dougdescombaz 10y agoAssertions in Java exist. Not really tests per se, but the closest thing I could think of.
- based2 10y agohttps://en.wikipedia.org/wiki/Design_by_contract https://en.wikipedia.org/wiki/Design_by_contract https://coq.inria.fr/about-coq https://coq.inria.fr/about-coq http://www.adacore.com/adaanswers/about/ada-comparison-chart http://www.adacore.com/adaanswers/about/ada-comparison-chart http://www.adacore.com/gnatpro/toolsuite/utilities/ http://www.adacore.com/gnatpro/toolsuite/utilities/ https://github.com/lampepfl/dotty https://github.com/lampepfl/dotty http://www.scalatest.org/getting_started_with_feature_spec http://www.scalatest.org/getting_started_with_feature_spec http://etorreborre.github.io/specs2/ http://etorreborre.github.io/specs2/ http://www.gebish.org/ http://www.gebish.org/ http://spockframework.github.io/spock/docs/1.1-rc-2/introduction.html http://spockframework.github.io/spock/docs/1.1-rc-2/introduc...
- reitanqild 10y ago> perhaps does not provide full proof/correctness/contract support but does come with testing right out of the box, either in its implementation or philosophy? Python has doctests. Not sure if thats what you mean?
- fdslkjlkjfds 10y agoRust has cargo test and cargo benchmark. Its basically a unit testing framework and benchmarking framework that is provided "batteries included" with the language distribution. Its dirt simple to add testing to your project, just create a directory called tests in top level of your project and place rust source files inside them. It then looks for functions inside those files that are annotated as being tests. Similar setup for benchmarks. Rust also includes generating documentation from comments inside the source code just like doxygen. And it supports embedded examples, which will be checked if those example programs compile at all. It really helps with prevent documentation from going out of date. All of this is provided from the start when you install rust.
- deleted 10y ago[deleted]
- philippnagel 10y agoLike Rust: https://doc.rust-lang.org/book/testing.html https://doc.rust-lang.org/book/testing.html ?
- piinbinary 10y agoI'm not sure this is exactly what you are asking about, but Rust does support testing right in the language. You can add #[test] before a function to make it a test function (tests and regular functions can live together in the same file). https://doc.rust-lang.org/book/testing.html https://doc.rust-lang.org/book/testing.html
- tomjen3 10y agoEiffel has design by contract build in, as does D.
- vram22 10y agoD also has unit testing built in. IIRC, they do mention a limitation or two.
- danblick 10y agoLook up "model checking" and see how that compares to what you're thinking about. How would you specify tests (or rather, correct program behavior) in such a language? The languages Alloy and TLA+ come to mind. (So does Coq, which is at the other extreme of actually proving your program correct.)
- jsli 10y agoYeah, Pyret!
- jeff_petersen 10y agoCame here to post just this. It is an "academic" language, designed more for teaching than for any production use, but it has a good pedigree and I've had some fun playing around with it.
- alimw 10y agoClojure's most recent builds include "spec". http://clojure.org/guides/spec http://clojure.org/guides/spec