Open mertyildiran opened 3 years ago
I really like this idea:
$ chaos --test/-t <file>
I say let's get this in. It reminds me of how Zig programmers code (tests in the same file, and can be invoked via the CLI). I really like this.
$ chaos dev.kaos
Chaos Warning: `sum` function is not tested!
hello world
We can also change the wording to function is unused or untested!
. I feel like this is better, because Chaos is built to encourage testing, but not everyone will want to write tests, especially for small programs. Adding unused
seems a bit more semantically appropriate for certain cases.
@naltun I've updated the description to <FUNCTION_NAME> function is untested!
format. Do you suggest to add another keyword like unused
to ignore untested function warnings? Like a function decorator:
@unused
num def sum(num a, num b)
num c = a + b
return c
end
such that the Chaos Warning: sum function is not tested!
message will be suppressed?
Add
assert
andtests
keyword to the grammar. Add-t/--test
CLI option. Consider the above Chaos program file:dev.kaos:
When you run it with
chaos dev.kaos
it printshello world
. But when you run it withchaos -t dev.kaos
it does not printhello world
but instead executes the code below thetests:
tag. If the assertion fails exits with a non-zero code.Optionally; warn user if there are no assertions on
sum
function when they runchaos dev.kaos
like:Add a CLI option to suppress these warnings.