amuletml / amulet

An ML-like functional programming language
https://amulet.works/
BSD 3-Clause "New" or "Revised" License
324 stars 14 forks source link

Simple Unit Test & Terminal Color Modules #269

Closed chrisnevers closed 4 years ago

chrisnevers commented 4 years ago

While playing around I found myself writing these modules/functions and figured they could be generally handy? It doesn't seem like Amulet has a package manager yet, with that said I understand if these don't belong in the standard library.

Colors

Test

Example Program

let test_add_1 () = add (Some 1) (Some 4) == 5
let test_add_2 () = add None None == 0

Test.run_tests [
  ("If both are present, add", test_add_1),
  ("If both absent, return 0", test_add_2)
]
Test.run_test ("Quick math", fun () -> 2 + 2 == 4)
Test.expect ("Get 3", fun () -> 5, 3)

Example Output

Screen Shot 2020-01-31 at 8 05 00 PM
plt-amy commented 4 years ago

Please use currying instead of tuples to define functions of multiple arguments.

SquidDev commented 4 years ago

I've cherry-picked the filter_map implementation in the above commit. Having had a chat with @plt-abigail, we decided we're not entirely sure the ANSI support. Sorry!