Something went wrong. Try again.
The Monad language. Dependent types, functional programming compiled with LLVM. Hobby project.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193/// Smoke tests for `cli/src/main.mo`'s `Command.from_args` argv parser.////// This used to say `cargo run -- run cli/src/main.mo ...` (actually/// executing `main`) hit a separate, pre-existing `instance-Monad-IO/// not found` failure — no longer reproduces (confirmed via many real/// `compile`/`check`/`pretty`/`test` invocations, 2026-08-19); whatever/// that was has since been fixed elsewhere, or this repro was itself/// stale. Kept testing `Command.from_args` directly anyway (isolating/// argv-parsing from everything downstream is still the more precise/// unit of test coverage, real end-to-end runs notwithstanding).use lib::main {*}#[test]def test_from_args_compile_positional_name : Bool := match Command.from_args ["compile", "a.mo", "myname"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && Path.to_string out_name == "myname" && verbose == false && debug == true, _ => false, }#[test]def test_from_args_compile_default_name : Bool := match Command.from_args ["compile", "a.mo"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && Path.to_string out_name == "source" && verbose == false && debug == true, _ => false, }#[test]def test_from_args_compile_output_flag : Bool := match Command.from_args ["compile", "a.mo", "--output", "out", "--verbose"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && Path.to_string out_name == "out" && verbose == true && debug == true, _ => false, }#[test]def test_from_args_compile_short_flags : Bool := match Command.from_args ["compile", "a.mo", "-o", "out", "-v"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && Path.to_string out_name == "out" && verbose == true && debug == true, _ => false, }#[test]def test_from_args_compile_debug_flag : Bool := match Command.from_args ["compile", "a.mo", "--debug"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && verbose == false && debug == true, _ => false, }#[test]def test_from_args_compile_debug_short_flag : Bool := match Command.from_args ["compile", "a.mo", "-g", "-v"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && verbose == true && debug == true, _ => false, }/// Debug info is ON by default (rustc's own dev-profile default);/// `--release` is how you opt out.#[test]def test_from_args_compile_release_opts_out_of_debug : Bool := match Command.from_args ["compile", "a.mo", "--release"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && verbose == false && debug == false, _ => false, }/// An explicit `--debug` wins over `--release` -- asking twice, with/// the more specific request, is not an error.#[test]def test_from_args_compile_debug_beats_release : Bool := match Command.from_args ["compile", "a.mo", "--release", "--debug"] { Command.compile path out_name verbose debug => Path.to_string path == "a.mo" && verbose == false && debug == true, _ => false, }#[test]def test_from_args_pretty : Bool := match Command.from_args ["pretty", "b.mo"] { Command.pretty path => path == "b.mo", _ => false, }#[test]def test_from_args_check : Bool := match Command.from_args ["check", "a.mo", "b.mo", "-v"] { Command.check files verbose workspace => files == ["a.mo", "b.mo"] && verbose == true && workspace == false, _ => false, }#[test]def test_from_args_check_workspace_flag : Bool := match Command.from_args ["check", "--workspace"] { Command.check files verbose workspace => List.is_empty files && workspace == true && verbose == false, _ => false, }#[test]def test_from_args_check_workspace_short_flag : Bool := match Command.from_args ["check", "-w", "-v"] { Command.check files verbose workspace => List.is_empty files && workspace == true && verbose == true, _ => false, }// The flag must be PEELED, not left among the paths -- otherwise it is// handed to the path expander as a filename.#[test]def test_from_args_check_workspace_flag_not_a_path : Bool := match Command.from_args ["check", "--workspace", "a.mo"] { Command.check files verbose workspace => files == ["a.mo"] && workspace == true, _ => false, }// A bare `monad check` no longer means "print help": it means "check the// mote containing the working directory" (and only falls back to help,// at RUN time, when there is no such mote). Mirroring// `test_from_args_test_no_files_is_a_test_command`, which Phase 9b made// true for `test` too.#[test]def test_from_args_check_no_files_is_a_check_command : Bool := match Command.from_args ["check"] { Command.check files verbose workspace => List.is_empty files && workspace == false && verbose == false, _ => false, }#[test]def test_from_args_test : Bool := match Command.from_args ["test", "a.mo", "b.mo", "-v"] { Command.test files verbose workspace => files == ["a.mo", "b.mo"] && verbose == true && workspace == false, _ => false, }#[test]def test_from_args_test_workspace_flag : Bool := match Command.from_args ["test", "--workspace"] { Command.test files verbose workspace => List.is_empty files && workspace == true && verbose == false, _ => false, }#[test]def test_from_args_test_workspace_short_flag : Bool := match Command.from_args ["test", "-w", "-v"] { Command.test files verbose workspace => List.is_empty files && workspace == true && verbose == true, _ => false, }// The flag must be PEELED, not left among the paths -- otherwise it is// handed to the path expander as a filename.#[test]def test_from_args_test_workspace_flag_not_a_path : Bool := match Command.from_args ["test", "--workspace", "a.mo"] { Command.test files verbose workspace => files == ["a.mo"] && workspace == true, _ => false, }// A bare `monad test` no longer means "print help": it means "test the// mote containing the working directory" (and only falls back to help,// at RUN time, when there is no such mote).#[test]def test_from_args_test_no_files_is_a_test_command : Bool := match Command.from_args ["test"] { Command.test files verbose workspace => List.is_empty files && workspace == false && verbose == false, _ => false, }#[test]def test_from_args_help_on_empty : Bool := match Command.from_args [] { Command.help => true, _ => false, }#[test]def test_from_args_help_on_unknown : Bool := match Command.from_args ["bogus"] { Command.help => true, _ => false, }