x-lang

← Index

x/tool/cov

Library coverage analysis for x-bin-profile instrumented code.

cov-word-size

Return the size of a machine word on this engine, in bytes.

Returns: INTEGER — Bytes in a machine word, 8 or 4

Examples:

(import x/tool/cov cov-word-size) (List includes? (cov-word-size) (list 4 8)) => #t

cov-flags

Return the flags word of an object’s header.

Returns: INTEGER — The object’s flags word, or 0 for nil

Examples:

(import x/tool/cov cov-flags) (cov-flags ()) => 0

cov-covered?

Test whether an object was marked as evaluated by x-bin-profile.

Returns: BOOL — True if object was evaluated (FLAG_2 set)

cov-cons?

Test whether an object is a cell a body walk can step through.

Returns: BOOL — True if x is a pair, a list cell or an engine-built spine cell

Examples:

(import x/tool/cov cov-cons?) (cov-cons? (list 1)) => #t
(import x/tool/cov cov-cons?) (cov-cons? 5) => #f

cov-body

Return the body forms of a procedure or an operative.

Returns: LIST — The body forms, or nil when there are none

Examples:

(import x/tool/cov cov-body) (cov-body (fn (_ x) (+ x 1))) => (('+ 'x 1))
(import x/tool/cov cov-body) (cov-body (op (a) e a)) => ('a)

cov-count-tree

Count covered and total AST nodes in a tree.

Returns: LIST — (covered total) pair

Examples:

(import x/tool/cov cov-count-tree) (first (rest (cov-count-tree (list 1 2) 0))) => 2

cov-check-fn

Check coverage for a single function.

Returns: LIST — (name covered total) or nil

Examples:

(import x/tool/cov cov-check-fn) (first (cov-check-fn 'inc (fn (_ x) (+ x 1)) #f)) => 'inc

cov-check-class

Check coverage of every method a class defines itself.

Returns: LIST — List of (name covered total) rows (empty in TSV mode)

Examples:

(import x/tool/cov cov-check-class) (List includes? "Iter/next" (List map first (cov-check-class 'Iter Iter #f))) => #t

cov-walk

Walk an environment alist checking coverage on each procedure and class.

cov-skip-to-library

Skip past test definitions to the library boundary marker.

Returns: LIST — Alist from library boundary marker onward

Examples:

(import x/tool/cov cov-skip-to-library) (cov-skip-to-library (list (pair 'a 1) (pair '%cov-library-end 0) (pair 'b 2))) => (('b . 2))