evylang / todo

0 stars 0 forks source link

Standard Lib Assert function #103

Closed joshcarp closed 1 month ago

joshcarp commented 1 month ago

Add variadic assert function to standard library:

assert <bool> -> asserts true assert <arg1> <arg2> -> asserts arg1==arg2

juliaogris commented 1 month ago

copying some notes a discord conversation around an evy test command:

@joshcarp this is the assert function we discussed ☝️ (https://github.com/evylang/evy/pull/355)

@camh- and I were debating the need and meaning of an evy test command and how it would map to playground. I'm looking for your input and feedback here. tbh I'm not quite sure we need a separate evy test command at this tage, you can place all relevant assertoins in a func test and then just call test at the bottom of the file.

Cam argues that testing is separate to running the program proper, but if we don't have a main function and we want to allow global state (which I think we need), evy test is just like evy run + execute all test* functions.

We were debating introducing a special main function that gets automatically executed if present with evy run after all top level code is executed.

This is an option but would be a little less beginner friendly.

It is less beginner friendly because if we translate this to playground, we either need separate buttons for test run run or we assume test run unless there are test* functions and no main function. testing could then be turned off and on by renaming func main to say func mainx.... However, there is a fair bit of "magic" (at least from the beginners perspective imo) happening here....

what do you think? Is the current implementation of assert enough for your needs or do you see real value in using evy run and evy test in parallel?

This is what assertion usage looks like with the current PR: https://evy-lang-stage-play--355-h39vs8dy.web.app/#content=H4sIAAAAAAAAE0ssLk4tKlEoKSpN5UqEsI0UDLUNYRylCiUFpUolGDctMac4lQsAm3OL7DUAAAA=