All files / src/walk predWalker.ts

100% Statements 10/10
100% Branches 2/2
100% Functions 3/3
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  15x 15x 15x   20534x         14479x 14479x 7563x     6915x       6065x    
import fnName from "../utils/fnName";
import Problem from "../models/Problem";
 
export default function predWalker( clause ) {
  return {
    trailblaze: predTraiblaze,
    reconstruct: predReconstruct,
  }
 
  function predTraiblaze( x ) {
    var predFn = clause.exprs[ 0 ];
    if ( !predFn( x ) ) {
      return new Problem( x, clause, [], 'Predicate ' + fnName( predFn ) + '() returns false' );
    } else {
      return x;
    }
  }
 
  function predReconstruct( x ) {
    return x;
  }
}