;;-*-Lisp-*- (in-package goal) (bundles "ENGINE.CGO" "GAME.CGO") (require "engine/debug/assert-h.gc") (define *run-time-assert-enable* #t) ;; TODO macros (defun __assert ((exp symbol) (msg string)) "When exp is false, print msg and the source position captured by the assert macro. Return zero." (when (not exp) (format #t "(ASSERT ~S) FAILED in " msg) (print-pos *__private-assert-info*)) 0) (defun __assert-min-max-range-float ((exp float) (minimum float) (maximum float) (msg-exp string) (msg-min string) (msg-max string)) "When exp lies outside the inclusive floating-point range [minimum, maximum], print the source expressions, their values, and the captured assert position. Return zero." (when (or (< exp minimum) (< maximum exp)) (format #t "(ASSERT_MIN_MAX_RANGE_FLOAT ~S ~S ~S) FAILED (values ~F ~F ~F) in " msg-exp msg-min msg-max exp minimum maximum) (print-pos *__private-assert-info*)) 0) (defun __assert-min-max-range-int ((exp int) (minimum int) (maximum int) (msg-exp string) (msg-min string) (msg-max string)) "When exp lies outside the inclusive integer range [minimum, maximum], print the source expressions, their values, and the captured assert position. Return zero." (when (or (< exp minimum) (< maximum exp)) (format #t "(ASSERT_MIN_MAX_RANGE_INT ~S ~S ~S) FAILED (values ~D ~D ~D) in " msg-exp msg-min msg-max exp minimum maximum) (print-pos *__private-assert-info*)) 0) (defun __assert-zero-lim-range-int ((exp int) (maximum int) (msg-exp string) (msg-max string)) "When exp lies outside the half-open integer range [0, maximum), print the source expressions, their values, and the captured assert position. Return zero." (when (or (< exp 0) (>= exp maximum)) (format #t "(ASSERT_ZERO_LIM_RANGE_INT ~S ~S) FAILED (values ~D ~D) in " msg-exp msg-max exp maximum) (print-pos *__private-assert-info*)) 0)