zksecurity / noname

Noname: a programming language to write zkapps
https://zksecurity.github.io/noname/
181 stars 47 forks source link

noname tests and `noname test` #32

Open mimoo opened 6 months ago

mimoo commented 6 months ago

We should aim to have first-class citizen testing in our ecosystem. This is a bit premature considering we're missing more important things, but at least we should start thinking about how developers should write tests using noname.

Ideally, we should follow the modern pattern of

$ noname test

Also I think it's nice that in Golang tests are separated in their own files, and you just have to have _test.go in the filename to have a test file (great example of convention of configuration)

It would also be nice to have proptest/quickcheck integrated in the language. So for example my_module.test.no would get access to all private structs/fns/fields of my_module.no and would be written like that:

use std::testing;

fn test_something(tt: testing::State) {
  // testing a function with real values
  let out = some_fn(3, 6);
  tt.assert(out == 5);

  // testing main with real values
  let arg = SomeStruct { some_field: 6 };
  main(arg);

  // with property test
  let arg: SomeStruct = tt.gen();
  if arg.some_field > 4 {
    main(arg);
  } else {
    tt.should_fail { main(arg); }
  }
}

a few problems: