
Ask HN: Is there a programming language with embedded testing support? - maramono
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...<p>There are also very few languages that focus on <i>correctness</i> and <i>contracts</i> to help create programs that have fewer bugs. Yet The mayority of languages simply focus on &quot;getting things done&quot;, so to speak, and leave testing and correctness out of the picture or add them later on.<p>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&#x2F;correctness&#x2F;contract support but does come with testing right out of the box, either in its implementation or philosophy?<p>Also related question: do you know of any language that was specifically <i>designed</i> to encourage and&#x2F;or make testing easier for its programs?<p>Even though I didn&#x27;t get the &quot;joke&quot; for a recent post about Go[0], I still think it&#x27;s interesting to ask.<p>[0] https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=12371029
======
based2
[https://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/introduc...](http://spockframework.github.io/spock/docs/1.1-rc-2/introduction.html)

------
tomjen3
Eiffel has design by contract build in, as does D.

~~~
vram22
D also has unit testing built in. IIRC, they do mention a limitation or two.

------
piinbinary
I'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)

------
dougdescombaz
Assertions in Java exist. Not really tests per se, but the closest thing I
could think of.

------
danblick
Look 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.)

------
alimw
Clojure's most recent builds include "spec".
[http://clojure.org/guides/spec](http://clojure.org/guides/spec)

------
reitanqild
> 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?

------
philippnagel
Like Rust: [https://doc.rust-lang.org/book/testing.html](https://doc.rust-
lang.org/book/testing.html) ?

------
jsli
Yeah, Pyret!

~~~
jeff_petersen
Came 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.

