diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 304592e..c393d45 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,6 +30,7 @@ add_test(NAME simple_implicit3 COMMAND artic --print-ast ${CMAKE_CURRENT_SOURC add_test(NAME simple_implicit4 COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/implicit4.art) add_test(NAME simple_implicit5 COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/implicit5.art) add_test(NAME simple_implicit6 COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/implicit6.art) +add_test(NAME simple_implicit7 COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/implicit7.art) add_test(NAME simple_while COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/while.art) add_test(NAME simple_while_let COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/while_let.art) add_test(NAME simple_for COMMAND artic --print-ast ${CMAKE_CURRENT_SOURCE_DIR}/simple/for.art) diff --git a/test/simple/implicit7.art b/test/simple/implicit7.art new file mode 100644 index 0000000..1199a73 --- /dev/null +++ b/test/simple/implicit7.art @@ -0,0 +1,12 @@ +struct Zero[T] { value: T } +struct Cmp[T] { cmp: fn(T, T) -> bool } + +implicit = Zero[i32] { value = 0 }; +implicit = Cmp[i32] { cmp = |x, y| x == y }; + +fn is_zero[T](value: T, implicit zero: Zero[T], implicit cmp: Cmp[T]) -> bool { + cmp.cmp(value, zero.value) +} + +#[export] +fn foo(i: i32) = if (is_zero[i32](i)) { 1 } else { 0 }; \ No newline at end of file