src/parsing/parse-comments.js
function onComment(isBlock, text, _s, _e, sLoc, eLoc) {

  var tRegex = /test\s*>\s*(.*)/i;
  var aRegex = /#\s*(.*)/i;
  var isTest = R.test(tRegex);
  var extractTest = R.pipe(R.match(tRegex), R.last(), R.trim());
  var isAssertion = R.test(aRegex);
  var extractAssertion = R.pipe(R.match(aRegex), R.last(), R.trim());
  var lastTestFound = R.last(tests);
  var newTest;

  function belongToTest(locLine, test) {
    return (test === undefined) ? false : locLine - 1 === test.loc.endLine;
  }

  function createEmptyTest(title) {
    return {
      title: title || null,
      loc: { startLine: sLoc.line, endLine: eLoc.line },
      assertions: []
    };
  }

  function addAssertionToTest(assertion, test) {
    test.assertions.push(assertion);
    test.loc.endLine = eLoc.line;
    return test;
  }

  function setTestTitle(title, test) {
    test.title = title;
    return test;
  }

  function buildTest(test, string) {
    if (isTest(string)) {
      setTestTitle(extractTest(string), test);
    } else if (isAssertion(string)) {
      addAssertionToTest(extractAssertion(string), test);
    }
    return test;
  }

  if (!isBlock) {
    if (isTest(text)) {
      newTest = R.pipe(extractTest, createEmptyTest)(text);
      tests.push(newTest);
    } else if (isAssertion(text) && belongToTest(sLoc.line, lastTestFound)) {
      addAssertionToTest(extractAssertion(text), lastTestFound);
    }
  }

  if (isBlock && isTest(text)) {
    newTest = R.reduce(buildTest, createEmptyTest(), R.split('\n', text));
    tests.push(newTest);
  }
}
function onComment(isBlock, text, _s, _e, sLoc, eLoc) {

  var tRegex = /test\s*>\s*(.*)/i;
  var aRegex = /#\s*(.*)/i;
  var isTest = R.test(tRegex);
  var extractTest = R.pipe(R.match(tRegex), R.last(), R.trim());
  var isAssertion = R.test(aRegex);
  var extractAssertion = R.pipe(R.match(aRegex), R.last(), R.trim());
  var lastTestFound = R.last(tests);
  var newTest;

  function belongToTest(locLine, test) {
    return (test === undefined) ? false : locLine - 1 === test.loc.endLine;
  }

  function createEmptyTest(title) {
    return {
      title: title || null,
      loc: { startLine: sLoc.line, endLine: eLoc.line },
      assertions: []
    };
  }

  function addAssertionToTest(assertion, test) {
    test.assertions.push(assertion);
    test.loc.endLine = eLoc.line;
    return test;
  }

  function setTestTitle(title, test) {
    test.title = title;
    return test;
  }

  function buildTest(test, string) {
    if (isTest(string)) {
      setTestTitle(extractTest(string), test);
    } else if (isAssertion(string)) {
      addAssertionToTest(extractAssertion(string), test);
    }
    return test;
  }

  if (!isBlock) {
    if (isTest(text)) {
      newTest = R.pipe(extractTest, createEmptyTest)(text);
      tests.push(newTest);
    } else if (isAssertion(text) && belongToTest(sLoc.line, lastTestFound)) {
      addAssertionToTest(extractAssertion(text), lastTestFound);
    }
  }

  if (isBlock && isTest(text)) {
    newTest = R.reduce(buildTest, createEmptyTest(), R.split('\n', text));
    tests.push(newTest);
  }
}
function onComment ( isBlock , text , _s , _e , sLoc , eLoc ) { var tRegex = / test\s*>\s*(.*) / i ; var aRegex = / #\s*(.*) / i ; var isTest = R . test ( tRegex ) ; var extractTest = R . pipe ( R . match ( tRegex ) , R . last ( ) , R . trim ( ) ) ; var isAssertion = R . test ( aRegex ) ; var extractAssertion = R . pipe ( R . match ( aRegex ) , R . last ( ) , R . trim ( ) ) ; var lastTestFound = R . last ( tests ) ; var newTest ; function belongToTest ( locLine , test ) { return ( test === undefined ) ? false : locLine - 1 === test . loc . endLine ; } function createEmptyTest ( title ) { return { title : title || null , loc : { startLine : sLoc . line , endLine : eLoc . line } , assertions : [ ] } ; } function addAssertionToTest ( assertion , test ) { test . assertions . push ( assertion ) ; test . loc . endLine = eLoc . line ; return test ; } function setTestTitle ( title , test ) { test . title = title ; return test ; } function buildTest ( test , string ) { if ( isTest ( string ) ) { setTestTitle ( extractTest ( string ) , test ) ; } else if ( isAssertion ( string ) ) { addAssertionToTest ( extractAssertion ( string ) , test ) ; } return test ; } if ( ! isBlock ) { if ( isTest ( text ) ) { newTest = R . pipe ( extractTest , createEmptyTest ) ( text ) ; tests . push ( newTest ) ; } else if ( isAssertion ( text ) && belongToTest ( sLoc . line , lastTestFound ) ) { addAssertionToTest ( extractAssertion ( text ) , lastTestFound ) ; } } if ( isBlock && isTest ( text ) ) { newTest = R . reduce ( buildTest , createEmptyTest ( ) , R . split ( '\n' , text ) ) ; tests . push ( newTest ) ; } }
Sanitizing iterator to run on each comment found during parsing
Sanitizing iterator to run on each comment found during parsing