Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created September 9, 2008 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/9702 to your computer and use it in GitHub Desktop.
Save tenderlove/9702 to your computer and use it in GitHub Desktop.
class CommentsTest < NodeTestCase
def test_line_numbers
parser = RKelly::Parser.new
ast = parser.parse(<<-eojs)
/**
* This is an awesome test comment.
*/
function aaron() { // This is a side comment
var x = 10;
return 1 + 1; // America!
}
eojs
func = ast.pointcut(FunctionDeclNode).matches.first
assert func
assert_match('awesome', func.comments[0].value)
assert_match('side', func.comments[1].value)
return_node = ast.pointcut(ReturnNode).matches.first
assert return_node
assert_match('America', return_node.comments[0].value)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment