hare

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

signal+test.ha (603B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use errors;
      5 use rt;
      6 use time;
      7 use unix;
      8 
      9 // Forward declaration to resolve signal => test => signal loop
     10 fn test::require(keywords: str...) void;
     11 
     12 let ok = false;
     13 
     14 fn handle_signal(
     15 	_sig: sig,
     16 	info: *siginfo,
     17 	ucontext: *opaque
     18 ) void = {
     19 	ok = true;
     20 };
     21 
     22 @test fn test_handle() void = {
     23 	test::require("integration");
     24 	handle(sig::USR1, &handle_signal);
     25 	match (rt::kill(unix::getpid(), sig::USR1)) {
     26 	case let errno: rt::errno =>
     27 		abort(errors::strerror(errors::errno(errno)));
     28 	case void => void;
     29 	};
     30 
     31 	assert(ok);
     32 };