var assert = require('./');
var execFile = require('child_process').execFile;

assert(assert, 'assert exists');
assert(assert.equal, 'assert.equal exists');
assert.equal(typeof assert.strictEqual, 'function',
             'assert.strictEqual is a function');
assert.doesNotThrow(function() {
  assert.throws(function() {
    throw Error('expected!');
  }, /expected/, 'supports assert.throws');
}, 'nested asserts are weird.');

execFile(process.execPath, ['test-bad-tests.js'], {}, assertBad);
execFile(process.execPath, ['.'], {}, assertNoTests);

function assertBad(err, stdout, stderr) {
  assert(err, 'bad file exits with an error');
  assert(/Premature exit with code \d/.test(stdout), 'exits prematurely');
  assert(/No assertions run/.test(stdout),
         'notices that no asserions were run');
}

function assertNoTests(err, stdout, stderr) {
  assert(err, 'no assertions run is considered a failure');
  assert(!/Premature exit with code/.test(stdout),
         'does not exit prematurely');
  assert(/No assertions run/.test(stdout), 'says no assertions were run');
}

@@ -577,32 +577,69 @@
 dout, stderr) %7B%0A
+  assertHeader(err, stdout, stderr);%0A
   assert(err, 'b
@@ -665,24 +665,88 @@
 an error');%0A
+  assert.notEqual(stderr, '', 'tapsert does not clear stderr');%0A
   assert(/Pr
@@ -940,32 +940,69 @@
 dout, stderr) %7B%0A
+  assertHeader(err, stdout, stderr);%0A
   assert(err, 'n
@@ -1041,24 +1041,88 @@
  failure');%0A
+  assert.equal(stderr, '', 'tapsert does not write to stderr');%0A
   assert(!/P
@@ -1191,32 +1191,32 @@
  prematurely');%0A
-
   assert(/No ass
@@ -1260,24 +1260,185 @@
 ssertions were run');%0A%7D%0A
+%0Afunction assertHeader(err, stdout, stderr) %7B%0A  assert(/%5E%5B%5Cs%5D*TAP version 13/.test(stdout),%0A         'TAP version header is the first non-whitespace output');%0A%7D%0A

Test for headers and stderr changes