hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 4a7f2fddd1dc27db747d598d0b89e23cc2e8a845
parent 6df07020525689247ecccf3e6f946d4785206883
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 30 Apr 2021 08:47:36 -0400

hare::types: add pointer test case

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Mhare/types/hash.ha | 25+++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/hare/types/hash.ha b/hare/types/hash.ha @@ -2,7 +2,6 @@ use endian; use hash::fnv; use hash; use strings; -use fmt; // Keep ordered with respect to bootstrap harec:include/types.h type storage = enum u8 { @@ -95,5 +94,27 @@ export fn hash(t: *_type) u32 = { }; assert(hash(&sample) == 4003927486); - // TODO: more samples + let _int = _type { + flags = flags::NONE, + _type = builtin::INT, + }; + assert(hash(&_int) == 1737287038); + + let sample = _type { + flags = flags::NONE, + _type = pointer { + referent = &_int, + flags = pointer_flags::NONE, + }, + }; + assert(hash(&sample) == 1453816944); + + let sample = _type { + flags = flags::NONE, + _type = pointer { + referent = &_int, + flags = pointer_flags::NULLABLE, + }, + }; + assert(hash(&sample) == 1467299071); };