@@ -290,19 +290,16 @@ pub inline fn expectApproxEqAbs(expected: anytype, actual: anytype, tolerance: a
290290
291291fn expectApproxEqAbsInner (comptime T : type , expected : T , actual : T , tolerance : T ) ! void {
292292 switch (@typeInfo (T )) {
293- .float = > if (! math .approxEqAbs (T , expected , actual , tolerance )) {
293+ .float , .comptime_float = > if (! math .approxEqAbs (T , expected , actual , tolerance )) {
294294 print ("actual {}, not within absolute tolerance {} of expected {}\n " , .{ actual , tolerance , expected });
295295 return error .TestExpectedApproxEqAbs ;
296296 },
297-
298- .comptime_float = > @compileError ("Cannot approximately compare two comptime_float values" ),
299-
300297 else = > @compileError ("Unable to compare non floating point values" ),
301298 }
302299}
303300
304301test expectApproxEqAbs {
305- inline for ([_ ]type { f16 , f32 , f64 , f128 }) | T | {
302+ inline for ([_ ]type { f16 , f32 , f64 , f128 , comptime_float }) | T | {
306303 const pos_x : T = 12.0 ;
307304 const pos_y : T = 12.06 ;
308305 const neg_x : T = -12.0 ;
@@ -326,19 +323,16 @@ pub inline fn expectApproxEqRel(expected: anytype, actual: anytype, tolerance: a
326323
327324fn expectApproxEqRelInner (comptime T : type , expected : T , actual : T , tolerance : T ) ! void {
328325 switch (@typeInfo (T )) {
329- .float = > if (! math .approxEqRel (T , expected , actual , tolerance )) {
326+ .float , .comptime_float = > if (! math .approxEqRel (T , expected , actual , tolerance )) {
330327 print ("actual {}, not within relative tolerance {} of expected {}\n " , .{ actual , tolerance , expected });
331328 return error .TestExpectedApproxEqRel ;
332329 },
333-
334- .comptime_float = > @compileError ("Cannot approximately compare two comptime_float values" ),
335-
336330 else = > @compileError ("Unable to compare non floating point values" ),
337331 }
338332}
339333
340334test expectApproxEqRel {
341- inline for ([_ ]type { f16 , f32 , f64 , f128 }) | T | {
335+ inline for ([_ ]type { f16 , f32 , f64 , f128 , comptime_float }) | T | {
342336 const eps_value = comptime math .floatEps (T );
343337 const sqrt_eps_value = comptime @sqrt (eps_value );
344338
0 commit comments