279 lines
8.2 KiB
Plaintext
279 lines
8.2 KiB
Plaintext
(module main)
|
|
|
|
(import cli (arg_text_result arg_text_option arg_i32_result arg_i32_option arg_i32_or_zero arg_i32_or arg_u32_result arg_u32_option arg_u32_or_zero arg_u32_or arg_i64_result arg_i64_option arg_i64_or_zero arg_i64_or arg_u64_result arg_u64_option arg_u64_or_zero arg_u64_or arg_f64_result arg_f64_option arg_f64_or_zero arg_f64_or arg_bool_result arg_bool_option arg_bool_or_false arg_bool_or))
|
|
|
|
(fn impossible_index () -> i32
|
|
99999)
|
|
|
|
(fn first_index () -> i32
|
|
0)
|
|
|
|
(fn imported_cli_arg_text_missing () -> bool
|
|
(match (arg_text_result (impossible_index))
|
|
((ok text)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_text_option_ok () -> bool
|
|
(if (match (arg_text_option (first_index))
|
|
((some text)
|
|
true)
|
|
((none)
|
|
false))
|
|
(match (arg_text_option (impossible_index))
|
|
((some text)
|
|
false)
|
|
((none)
|
|
true))
|
|
false))
|
|
|
|
(fn imported_cli_arg_i32_missing () -> bool
|
|
(match (arg_i32_result (impossible_index))
|
|
((ok value)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_i32_or_zero_missing () -> bool
|
|
(= (arg_i32_or_zero (impossible_index)) 0))
|
|
|
|
(fn imported_cli_arg_u32_missing () -> bool
|
|
(match (arg_u32_result (impossible_index))
|
|
((ok value)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_u32_or_zero_missing () -> bool
|
|
(= (arg_u32_or_zero (impossible_index)) 0u32))
|
|
|
|
(fn imported_cli_arg_i64_missing () -> bool
|
|
(match (arg_i64_result (impossible_index))
|
|
((ok value)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_i64_or_zero_missing () -> bool
|
|
(= (arg_i64_or_zero (impossible_index)) 0i64))
|
|
|
|
(fn imported_cli_arg_u64_missing () -> bool
|
|
(match (arg_u64_result (impossible_index))
|
|
((ok value)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_u64_or_zero_missing () -> bool
|
|
(= (arg_u64_or_zero (impossible_index)) 0u64))
|
|
|
|
(fn imported_cli_arg_f64_missing () -> bool
|
|
(match (arg_f64_result (impossible_index))
|
|
((ok value)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_f64_or_zero_missing () -> bool
|
|
(= (arg_f64_or_zero (impossible_index)) 0.0))
|
|
|
|
(fn imported_cli_arg_bool_missing () -> bool
|
|
(match (arg_bool_result (impossible_index))
|
|
((ok value)
|
|
false)
|
|
((err code)
|
|
(= code 1))))
|
|
|
|
(fn imported_cli_arg_bool_or_false_missing () -> bool
|
|
(if (arg_bool_or_false (impossible_index))
|
|
false
|
|
true))
|
|
|
|
(fn imported_cli_typed_options_ok () -> bool
|
|
(if (match (arg_i32_option (impossible_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_i32_option (first_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_u32_option (impossible_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_u32_option (first_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_i64_option (impossible_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_i64_option (first_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_u64_option (impossible_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_u64_option (first_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_f64_option (impossible_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_f64_option (first_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(if (match (arg_bool_option (impossible_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
(match (arg_bool_option (first_index))
|
|
((some value)
|
|
false)
|
|
((none)
|
|
true))
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false))
|
|
|
|
(fn imported_cli_typed_custom_fallbacks_ok () -> bool
|
|
(if (= (arg_i32_or (impossible_index) 7) 7)
|
|
(if (= (arg_i32_or (first_index) 7) 7)
|
|
(if (= (arg_u32_or (impossible_index) 7u32) 7u32)
|
|
(if (= (arg_u32_or (first_index) 7u32) 7u32)
|
|
(if (= (arg_i64_or (impossible_index) 9i64) 9i64)
|
|
(if (= (arg_i64_or (first_index) 9i64) 9i64)
|
|
(if (= (arg_u64_or (impossible_index) 9u64) 9u64)
|
|
(if (= (arg_u64_or (first_index) 9u64) 9u64)
|
|
(if (= (arg_f64_or (impossible_index) 1.5) 1.5)
|
|
(if (= (arg_f64_or (first_index) 1.5) 1.5)
|
|
(if (arg_bool_or (impossible_index) true)
|
|
(arg_bool_or (first_index) true)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false))
|
|
|
|
(fn imported_cli_facade_ok () -> bool
|
|
(if (imported_cli_arg_text_missing)
|
|
(if (imported_cli_arg_text_option_ok)
|
|
(if (imported_cli_arg_i32_missing)
|
|
(if (imported_cli_arg_i32_or_zero_missing)
|
|
(if (imported_cli_arg_u32_missing)
|
|
(if (imported_cli_arg_u32_or_zero_missing)
|
|
(if (imported_cli_arg_i64_missing)
|
|
(if (imported_cli_arg_i64_or_zero_missing)
|
|
(if (imported_cli_arg_u64_missing)
|
|
(if (imported_cli_arg_u64_or_zero_missing)
|
|
(if (imported_cli_arg_f64_missing)
|
|
(if (imported_cli_arg_f64_or_zero_missing)
|
|
(if (imported_cli_arg_bool_missing)
|
|
(if (imported_cli_arg_bool_or_false_missing)
|
|
(if (imported_cli_typed_options_ok)
|
|
(imported_cli_typed_custom_fallbacks_ok)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false)
|
|
false))
|
|
|
|
(fn main () -> i32
|
|
(if (imported_cli_facade_ok)
|
|
42
|
|
1))
|
|
|
|
(test "explicit local cli arg text missing"
|
|
(imported_cli_arg_text_missing))
|
|
|
|
(test "explicit local cli arg text option"
|
|
(imported_cli_arg_text_option_ok))
|
|
|
|
(test "explicit local cli arg i32 missing"
|
|
(imported_cli_arg_i32_missing))
|
|
|
|
(test "explicit local cli arg i32 fallback missing"
|
|
(imported_cli_arg_i32_or_zero_missing))
|
|
|
|
(test "explicit local cli arg u32 missing"
|
|
(imported_cli_arg_u32_missing))
|
|
|
|
(test "explicit local cli arg u32 fallback missing"
|
|
(imported_cli_arg_u32_or_zero_missing))
|
|
|
|
(test "explicit local cli arg i64 missing"
|
|
(imported_cli_arg_i64_missing))
|
|
|
|
(test "explicit local cli arg i64 fallback missing"
|
|
(imported_cli_arg_i64_or_zero_missing))
|
|
|
|
(test "explicit local cli arg u64 missing"
|
|
(imported_cli_arg_u64_missing))
|
|
|
|
(test "explicit local cli arg u64 fallback missing"
|
|
(imported_cli_arg_u64_or_zero_missing))
|
|
|
|
(test "explicit local cli arg f64 missing"
|
|
(imported_cli_arg_f64_missing))
|
|
|
|
(test "explicit local cli arg f64 fallback missing"
|
|
(imported_cli_arg_f64_or_zero_missing))
|
|
|
|
(test "explicit local cli arg bool missing"
|
|
(imported_cli_arg_bool_missing))
|
|
|
|
(test "explicit local cli arg bool fallback missing"
|
|
(imported_cli_arg_bool_or_false_missing))
|
|
|
|
(test "explicit local cli typed option"
|
|
(imported_cli_typed_options_ok))
|
|
|
|
(test "explicit local cli typed custom fallback"
|
|
(imported_cli_typed_custom_fallbacks_ok))
|
|
|
|
(test "explicit local cli facade all"
|
|
(= (main) 42))
|