hare

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

commit caa76ac3182a30fa96f7e75482c3574a72afd1e5
parent 5be71f07c9f5cb250fbf1fe819633cc4e9685970
Author: Ember Sawady <ecs@d2evs.net>
Date:   Fri,  3 Nov 2023 15:02:46 +0000

update test runner

Signed-off-by: Ember Sawady <ecs@d2evs.net>

Diffstat:
Mtest/+test.ha | 38++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+), 0 deletions(-)

diff --git a/test/+test.ha b/test/+test.ha @@ -163,6 +163,8 @@ export @symbol("__test_main") fn main() size = { elapsed_fraction)!; }; + easter_egg(ctx.failures, enabled_tests); + return len(ctx.failures); }; @@ -313,3 +315,39 @@ fn handle_segv( ) void = { rt::longjmp(&jmpbuf, 2); }; + +fn easter_egg(fails: []failure, tests: []test) void = { + // norwegian deadbeef + let blob: [_]u8 = [ + 0xe1, 0x41, 0xf2, 0x21, 0x3f, 0x9e, 0x2d, 0xfe, 0x3f, 0x9e, + 0x22, 0xfc, 0x43, 0xc2, 0x2f, 0x82, 0x15, 0xd1, 0x62, 0xae, + 0x6c, 0x9e, 0x71, 0xfe, 0x33, 0xc2, 0x71, 0xfe, 0x63, 0xb4, + 0x2d, 0xfe, 0x3f, 0xe1, 0x52, 0xf2, 0x43, 0xc6, 0x2d, 0xf9, + 0x3d, 0x90, 0x07, 0xfe, 0x33, 0x9c, 0x2d, 0xfe, 0x3f, 0x96, + 0x2d, 0x8f, 0x3f, 0x9e, 0x64, 0xd4, 0x33, 0x9c, 0x21, 0xfe, + 0x3f, 0x9e, 0x2d, 0x82, 0x40, 0x9e, 0x54, 0xf9, 0x15, 0x99, + 0x30, 0xfe, 0x3f, 0x92, 0x2d, 0xfe, 0x31, 0x9e, 0x2d, 0xfe, + 0x38, 0xb4, 0x2d, 0xf9, 0x22, 0x83, 0x52, 0xf9, 0x40, 0xe1, + 0x30, 0xe3, 0x38, 0x9e, 0x2d, 0xd4, + ]; + let words = &blob: *[24]u32; + + // doesn't currently work on big-endian, would need to re-find the + // constants and use a different blob there + if (words[0]: u8 != 0xe1) return; + + words[0] ^= len(tests): u32; + + let hash = 2166136261u32; + for (let i = 0z; i < size(u32); i += 1) { + hash = (hash ^ blob[i]) * 16777619; + }; + + for (let i = 0z; i < len(words); i += 1) { + words[i] ^= hash; + }; + + if (-len(fails): u32 == words[0]) { + io::write(os::stdout, blob[size(u32)..])!; + }; +};