From cc804bf4a73ac27847ad9ca299588693e8abde5e Mon Sep 17 00:00:00 2001 From: Keldan Chapman Date: Fri, 25 Aug 2023 08:17:42 +0200 Subject: [PATCH] Keep timestamps off stack (#41) --- tools/testest/testest.factor | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/testest/testest.factor b/tools/testest/testest.factor index 0fd71f1..06cdbd1 100644 --- a/tools/testest/testest.factor +++ b/tools/testest/testest.factor @@ -5,9 +5,16 @@ io io.streams.string io.styles kernel locals math namespaces parser prettyprint prettyprint.config prettyprint.custom quotations sequences splitting system ; IN: tools.testest -: describe#{ ( description -- starttime ) nl "%s" printf nl flush nano-count ; -: it#{ ( description -- starttime ) nl "%s" printf nl flush nano-count ; -: }# ( starttime -- ) nano-count swap - 1000000 / nl "%f ms" printf nl ; +DEFER: }# delimiter +: timed-block ( accum tag -- accum ) + \ }# parse-until >quotation '[ + nl _ printf nl flush nano-count _ dip + nano-count swap - 1000000 / nl "%f ms" printf nl + ] append! ; + +SYNTAX: describe#{ "%s" timed-block ; +SYNTAX: it#{ "%s" timed-block ; + ! user redefinable test result message quotations