cancel
Showing results for 
Search instead for 
Did you mean: 

Code coverage in q

FutureInSound
New Contributor
Hi,

Anyone has an idea of how to implement code coverage in q?
So far I've built a simple library that retrieves the list of global functions called in a test and converging until I get the tree of all functions called.

However let's say there is an "if statement" in one of these functions, how can I know that it was called?
// I define two functions for info and error printing
.log.info:{-1 x};
.log.error:{-2 x};

// And then another function for adding two numbers
add
:{[a;b]
   
if[not all type a b;
       
.log.error "not numbers";
       
:"error";
   
];
   
.log.info "adding ",string[a]," to ",string[b];
   
:a+b;
 
};

Now if I pull out the globals used in that function I get the following:

q)get[add]3
``.log.error`.log.info

However if that function was called with two integers, then a hit on .log.error wouldn't count, only .log.info will count as code covered.


Thanks,
Zak
0 REPLIES 0