Skip to content

Commit

Permalink
test multiple modules with a single call to doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed May 12, 2012
1 parent d7b2591 commit f0173e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ those rare occasions when tests of this nature are actually appropriate.
}
}

To run doctests, pass `doctest` a path to the "module" to be tested. The
path should be one of the following:
To run doctests, pass `doctest` paths to one or more "modules" to be tested.
Each path should be one of the following:

- an absolute URL; e.g. "http://example.com/scripts/math-extensions.js"
- a root-relative URL; e.g. "/scripts/math-extensions.js"
Expand Down
7 changes: 5 additions & 2 deletions doctest.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
window.doctest = (url) ->
window.doctest = (urls...) ->
fetch url for url in urls
return

fetch = (url) ->
# Support relative paths; e.g. `doctest("./foo.js")`.
if /^[.]/.test(url) and ($script = jQuery 'script[src$="doctest.js"]').length
url = $script.attr('src').replace(/doctest[.]js$/, url)
Expand All @@ -12,7 +15,7 @@ window.doctest = (url) ->
for [pass, expected, actual, num] in (r for r in results when not r[0])
console.warn "expected #{expected} on line #{num} (got #{actual})"

window.doctest.version = '0.1.1'
window.doctest.version = '0.1.2'

commented_lines = (text) ->
lines = []
Expand Down
16 changes: 13 additions & 3 deletions doctest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0173e3

Please sign in to comment.