-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose expected test output to headless test runner
- Loading branch information
1 parent
92dc561
commit 0c0a48d
Showing
8 changed files
with
129 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
jQuery ($) -> | ||
|
||
doctest.complete = (results) -> | ||
for message, expected of tests | ||
deepEqual results.shift(), expected, message | ||
start() | ||
|
||
asyncTest 'JavaScript doctests', -> | ||
doctest './test.js' | ||
|
||
asyncTest 'CoffeeScript doctests', -> | ||
doctest './test.coffee' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{isEqual} = require 'underscore' | ||
|
||
doctest = require '../src/doctest' | ||
tests = require './tests' | ||
|
||
|
||
gray = green = red = reset = '' | ||
unless process.env.NODE_DISABLE_COLORS or process.platform is 'win32' | ||
gray = '\x1B[0;37m' | ||
green = '\x1B[0;32m' | ||
red = '\x1B[0;31m' | ||
reset = '\x1B[0m' | ||
|
||
queue = ['test/test.js', 'test/test.coffee'] | ||
next = -> doctest queue.shift() if queue.length | ||
|
||
doctest.complete = (results) -> | ||
for message, expected of tests | ||
actual = results.shift() | ||
if isEqual actual, expected | ||
console.log "#{green} \u2714 #{gray} #{message}#{reset}" | ||
else | ||
console.warn "#{red} \u2718 #{gray} #{message}#{reset}" | ||
console.log "#{gray} expected: #{green}#{expected}#{reset}" | ||
console.log "#{gray} received: #{red}#{actual}#{reset}" | ||
next() | ||
next() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
for program in open xdg-open ; do | ||
command -v $program >/dev/null 2>&1 | ||
if [[ $? == 0 ]] ; then | ||
$program "$@" | ||
exit 0 | ||
fi | ||
done | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
tests = | ||
|
||
'global variable accessible in outer scope': | ||
[yes, '"global"', '"global"', 3] | ||
|
||
'global variable accessible in inner scope': | ||
[yes, '"global"', '"global"', 10] | ||
|
||
'local variable referenced, not shadowed global': | ||
[yes, '"shadowed"', '"shadowed"', 14] | ||
|
||
'local variable accessible before declaration': | ||
[yes, 2, 2, 20] | ||
|
||
'assignment is an expression': | ||
[yes, 3, 3, 25] | ||
|
||
'variable declared in doctest remains accessible': | ||
[yes, [1, 2, 3], [1, 2, 3], 28] | ||
|
||
'arithmetic error reported': | ||
[no, 5, 4, 31] | ||
|
||
'TypeError captured and reported': | ||
[yes, 'TypeError', 'TypeError', 35] | ||
|
||
'TypeError expected but not reported': | ||
[no, 'TypeError', 0, 38] | ||
|
||
'function accessible before declaration': | ||
[yes, 12, 12, 42] | ||
|
||
'NaN can be used as expected result': | ||
[yes, NaN, NaN, 45] | ||
|
||
'function accessible after declaration': | ||
[yes, 4, 4, 53] | ||
|
||
'multiline input': | ||
[yes, [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], 65] | ||
|
||
'multiline assignment': | ||
[yes, '"input may span many lines"', '"input may span many lines"', 71] | ||
|
||
'spaces following "//" and ">" are optional': | ||
[yes, '"no spaces"', '"no spaces"', 75] | ||
|
||
'indented doctest': | ||
[yes, '"Docco-compatible whitespace"', '"Docco-compatible whitespace"', 78] | ||
|
||
'">" in doctest': | ||
[yes, yes, yes, 81] | ||
|
||
'comment on input line': | ||
[yes, '"foobar"', '"foobar"', 85] | ||
|
||
'comment on output line': | ||
[yes, 25, 25, 88] | ||
|
||
'variable in creation context is not accessible': | ||
[yes, '"undefined"', '"undefined"', 92] | ||
|
||
|
||
if typeof window isnt 'undefined' | ||
window.tests = tests | ||
else | ||
module.exports = tests |