diff --git a/README.markdown b/README.markdown index 7f475d20..5bcbe333 100644 --- a/README.markdown +++ b/README.markdown @@ -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" diff --git a/doctest.coffee b/doctest.coffee index aa6346b2..fd61cfb5 100644 --- a/doctest.coffee +++ b/doctest.coffee @@ -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) @@ -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 = [] diff --git a/doctest.js b/doctest.js index 497f7ed9..97d1273b 100644 --- a/doctest.js +++ b/doctest.js @@ -1,8 +1,18 @@ // Generated by CoffeeScript 1.3.1 (function() { - var commented_lines, q, test; + var commented_lines, fetch, q, test, + __slice = [].slice; - window.doctest = function(url) { + window.doctest = function() { + var url, urls, _i, _len; + urls = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + for (_i = 0, _len = urls.length; _i < _len; _i++) { + url = urls[_i]; + fetch(url); + } + }; + + fetch = function(url) { var $script; if (/^[.]/.test(url) && ($script = jQuery('script[src$="doctest.js"]')).length) { url = $script.attr('src').replace(/doctest[.]js$/, url); @@ -41,7 +51,7 @@ }); }; - window.doctest.version = '0.1.1'; + window.doctest.version = '0.1.2'; commented_lines = function(text) { var idx, line, lines, match, _i, _len, _ref;