Closed franck44 closed 2 years ago
This command-line works:
dafny /runAllTests:1 /noVerify /compile:4 /compileTarget:java src/test/dafny/test.dfy
The test above appears to fail .. which I think is right?
I suggest we add /runAllTests:1
to the gradle build. Then you can add {:test}
directives to your hearts desire!
Ok, this is now done. Running gradle build
now also means anything in the directory src/test/dafny
directory will be verified and executed with /runAllTests:1
. This works, but there are at least two very annoying things:
runAllTests
. You can see it says on the console output that it failed, but you have to notice it.Additional target code written to
and I cannot seem to stop that.I will raise issues on the Dafny repo about these two things as they would improve our process.
Also also:
src/test/dafny/test1.dfy
which contained the test above (and a bunch of commented out stuff --- not pretty).src/test/dafny/test.dfy
and remove test1.dfy
.In general, we can add more files in that src/test/dafny
directory, for sure.
See https://github.com/dafny-lang/dafny/issues/2513
And in researching that, I have figured out the solution to the code gen output issue above. You can use compileVerbose:0
to suppress that output. I will action that now.
Dafny offers some basic support to write simple tests. The main ingredient are:
{:test}
expect
to check the test resultsf.dfy
withdafny /runAllTests:1 /noVerify /compile:4 f.dfy
[There is another more powerful techniques using compilation to c#/runAllTests:0
that I have not investigated]For example, a test for the program
test_Execute_01
intest.dfy
may look like so:and the execution yields:
note: the test fails as the result should be
[x]
not[x + 1]
.