From 10e106229b5a2006f2e7cf337a048859011f8798 Mon Sep 17 00:00:00 2001 From: Richard Carlsson Date: Thu, 19 May 2016 21:07:14 +0200 Subject: Replace suggested debugValAll/1 macro with debugVal/2 Also make the default depth for debugVal/1 possible to override by defining the macro EUNIT_DEBUG_VAL_DEPTH. --- lib/eunit/doc/overview.edoc | 11 ++++++----- lib/eunit/include/eunit.hrl | 16 +++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/eunit/doc/overview.edoc b/lib/eunit/doc/overview.edoc index ca7ffb83a4..3a46e991cb 100644 --- a/lib/eunit/doc/overview.edoc +++ b/lib/eunit/doc/overview.edoc @@ -690,11 +690,12 @@ it like `debugMsg'. The result is always `ok'.
`debugVal(Expr)'
Prints both the source code for `Expr' and its current value. E.g., `?debugVal(f(X))' might be displayed as "`f(X) = 42'". (Large terms are -shown truncated.) The result is always the value of `Expr', so this -macro can be wrapped around any expression to display its value when -the code is compiled with debugging enabled.
-
`debugValAll(Expr)'
-
This is almost same as `debugVal(Expr)`, but doesn't truncate terms to print.
+truncated to the depth given by the macro `EUNIT_DEBUG_VAL_DEPTH', which +defaults to 15 but can be overridden by the user.) The result is always the +value of `Expr', so this macro can be wrapped around any expression to +display its value when the code is compiled with debugging enabled. +
`debugVal(Expr, Depth)'
+
Like `debugVal(Expr)', but prints terms truncated to the given depth.
`debugTime(Text,Expr)'
Prints `Text' and the wall clock time for evaluation of `Expr'. The result is always the value of `Expr', so this macro can be wrapped diff --git a/lib/eunit/include/eunit.hrl b/lib/eunit/include/eunit.hrl index b6dbe2d706..7fd6c206a4 100644 --- a/lib/eunit/include/eunit.hrl +++ b/lib/eunit/include/eunit.hrl @@ -223,20 +223,18 @@ end). -define(debugHere, (?debugMsg("<-"))). -define(debugFmt(S, As), (?debugMsg(io_lib:format((S), (As))))). --define(debugVal(E), +-define(debugVal(E, D), begin ((fun (__V) -> - ?debugFmt(<<"~ts = ~tP">>, [(??E), __V, 15]), - __V - end)(E)) - end). --define(debugValAll(E), - begin - ((fun (__V) -> - ?debugFmt(<<"~ts = ~tp">>, [(??E), __V]), + ?debugFmt(<<"~ts = ~tP">>, + [(??E), __V, D]), __V end)(E)) end). +-ifndef(EUNIT_DEBUG_VAL_DEPTH). +-define(EUNIT_DEBUG_VAL_DEPTH, 15). +-endif. +-define(debugVal(E), ?debugVal(E, ?EUNIT_DEBUG_VAL_DEPTH)). -define(debugTime(S, E), begin ((fun () -> -- cgit v1.2.3