Add Maybe.equals when inner type is equatable.

This commit is contained in:
Gregory Oakes
2025-05-15 22:59:12 -05:00
committed by Christoffer Lerno
parent bd1de1e7dc
commit 5c3b637cf6
3 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
module maybetest @test;
import std::collections::maybe;
import std::core::types;
alias maybeint = maybe::value{int};
struct Unequatable { int value; }
alias MaybeUnequatable = maybe::Maybe{Unequatable};
fn void test_equals() @test
{
$assert(!types::is_equatable_type(MaybeUnequatable));
assert(maybeint(1) == maybeint(1));
assert(maybeint(0) == maybeint(0));
assert(maybeint(0) != maybeint(1));
assert(maybeint(1) != maybeint(0));
assert(maybeint(0) != maybe::EMPTY{int});
assert(maybe::EMPTY{int} != maybeint(0));
}