-
-
Notifications
You must be signed in to change notification settings - Fork 307
Multiline comments #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Multiline comments #228
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cc3b58e
Exploratory comments to ascertain current behavior
nicolagi 0132b1d
Failing test for new functionality
nicolagi 9c00faf
Multiline comments
nicolagi 3a5417a
Removed unnecessary cast
nicolagi c66f25e
Added test case for Windows line endings
nicolagi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,177 @@ | ||
var concat = require('concat-stream'); | ||
var tap = require('tap'); | ||
var tape = require('../'); | ||
|
||
// Exploratory test to ascertain proper output when no t.comment() call | ||
// is made. | ||
tap.test('no comment', function (assert) { | ||
assert.plan(1); | ||
|
||
var verify = function (output) { | ||
assert.equal(output.toString('utf8'), [ | ||
'TAP version 13', | ||
'# no comment', | ||
'', | ||
'1..0', | ||
'# tests 0', | ||
'# pass 0', | ||
'', | ||
'# ok', | ||
'' | ||
].join('\n')); | ||
}; | ||
|
||
var test = tape.createHarness(); | ||
test.createStream().pipe(concat(verify)); | ||
test('no comment', function (t) { | ||
t.end(); | ||
}); | ||
}); | ||
|
||
// Exploratory test, can we call t.comment() passing nothing? | ||
tap.test('missing argument', function (assert) { | ||
assert.plan(2); | ||
var test = tape.createHarness(); | ||
test.createStream(); | ||
test('missing argument', function (t) { | ||
try { | ||
t.comment(); | ||
t.end(); | ||
} catch (err) { | ||
assert.equal(err.constructor, TypeError); | ||
assert.equal(err.message, 'Cannot call method on undefined'); | ||
} finally { | ||
assert.end(); | ||
} | ||
}); | ||
}); | ||
|
||
// Exploratory test, can we call t.comment() passing nothing? | ||
tap.test('null argument', function (assert) { | ||
assert.plan(2); | ||
var test = tape.createHarness(); | ||
test.createStream(); | ||
test('null argument', function (t) { | ||
try { | ||
t.comment(null); | ||
t.end(); | ||
} catch (err) { | ||
assert.equal(err.constructor, TypeError); | ||
assert.equal(err.message, 'Cannot call method on null'); | ||
} finally { | ||
assert.end(); | ||
} | ||
}); | ||
}); | ||
|
||
|
||
// Exploratory test, how is whitespace treated? | ||
tap.test('whitespace', function (assert) { | ||
assert.plan(1); | ||
|
||
var verify = function (output) { | ||
assert.equal(output.toString('utf8'), [ | ||
'TAP version 13', | ||
'# whitespace', | ||
'# ', | ||
'# a', | ||
'# a', | ||
'# a', | ||
'', | ||
'1..0', | ||
'# tests 0', | ||
'# pass 0', | ||
'', | ||
'# ok', | ||
'' | ||
].join('\n')); | ||
}; | ||
|
||
var test = tape.createHarness(); | ||
test.createStream().pipe(concat(verify)); | ||
test('whitespace', function (t) { | ||
t.comment(' '); | ||
t.comment(' a'); | ||
t.comment('a '); | ||
t.comment(' a '); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
// Exploratory test, how about passing types other than strings? | ||
tap.test('non-string types', function (assert) { | ||
assert.plan(1); | ||
|
||
var verify = function (output) { | ||
assert.equal(output.toString('utf8'), [ | ||
'TAP version 13', | ||
'# non-string types', | ||
'# true', | ||
'# false', | ||
'# 42', | ||
'# 6.66', | ||
'# [object Object]', | ||
'# [object Object]', | ||
'# [object Object]', | ||
'# function ConstructorFunction() {}', | ||
'', | ||
'1..0', | ||
'# tests 0', | ||
'# pass 0', | ||
'', | ||
'# ok', | ||
'' | ||
].join('\n')); | ||
}; | ||
|
||
var test = tape.createHarness(); | ||
test.createStream().pipe(concat(verify)); | ||
test('non-string types', function (t) { | ||
t.comment(true); | ||
t.comment(false); | ||
t.comment(42); | ||
t.comment(6.66); | ||
t.comment({}); | ||
t.comment({"answer": 42}); | ||
function ConstructorFunction() {} | ||
t.comment(new ConstructorFunction()); | ||
t.comment(ConstructorFunction); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
tap.test('multiline string', function (assert) { | ||
assert.plan(1); | ||
|
||
var verify = function (output) { | ||
assert.equal(output.toString('utf8'), [ | ||
'TAP version 13', | ||
'# multiline strings', | ||
'# a', | ||
'# b', | ||
'# c', | ||
'# d', | ||
'', | ||
'1..0', | ||
'# tests 0', | ||
'# pass 0', | ||
'', | ||
'# ok', | ||
'' | ||
].join('\n')); | ||
}; | ||
|
||
var test = tape.createHarness(); | ||
test.createStream().pipe(concat(verify)); | ||
test('multiline strings', function (t) { | ||
t.comment([ | ||
'a', | ||
'b', | ||
].join('\n')); | ||
t.comment([ | ||
'c', | ||
'd', | ||
].join('\r\n')); | ||
t.end(); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this result in invisible
\r
characters appearing in the output? it's likely that this is getting obscured in the test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're actually being
trim()
med intest.js:107
: removing the inner call totrim()
makes this part of the test fail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, ok that makes sense then :-) thanks for clarifying