var tap = require('../tap');

tap.count(22);

try {
	throw new Error('ok')
} catch (e) {
	tap.ok(e.message == 'ok');
}


tap.ok(Error)
tap.ok(Error('ok').type == 'Error')
tap.ok(new Error('ok').type == 'Error')
tap.ok(EvalError)
tap.ok(EvalError('ok').type == 'EvalError')
tap.ok(new EvalError('ok').type == 'EvalError')
tap.ok(RangeError)
tap.ok(RangeError('ok').type == 'RangeError')
tap.ok(new RangeError('ok').type == 'RangeError')
tap.ok(ReferenceError)
tap.ok(ReferenceError('ok').type == 'ReferenceError')
tap.ok(new ReferenceError('ok').type == 'ReferenceError')
tap.ok(SyntaxError)
tap.ok(SyntaxError('ok').type == 'SyntaxError')
tap.ok(new SyntaxError('ok').type == 'SyntaxError')
tap.ok(TypeError)
tap.ok(TypeError('ok').type == 'TypeError')
tap.ok(new TypeError('ok').type == 'TypeError')
tap.ok(URIError)
tap.ok(URIError('ok').type == 'URIError')
tap.ok(new URIError('ok').type == 'URIError')
@@ -37,10 +37,10 @@
 unt(
-22
+33
 );%0A%0A
@@ -124,24 +124,78 @@
 p.ok(Error)%0A
+// TODO: these %60.type ==%60 checks don't pass under v8!%0A
 tap.ok(Error
@@ -899,32 +899,32 @@
  == 'URIError')%0A
-
 tap.ok(new URIEr
@@ -932,28 +932,1043 @@
 or('ok').type == 'URIError')
+%0A%0A// stack capturing%0Avar err = new Error('thing');%0Afunction CAPTURER(err, ctor) %7B%0A  Error.captureStackTrace(err, ctor);%0A%7D%0ACAPTURER(err);%0Atap.ok(/CAPTURER/.test(err.stack), %22expected callsite in trace%22);%0ACAPTURER(err, CAPTURER);%0Atap.ok(!/CAPTURER/.test(err.stack), %22excludable via argument%22);%0A%0A// stack formatting%0Avar prepErr, prepArr;%0AError.prepareStackTrace = function (err, arr) %7B%0A  prepErr = err;%0A  prepArr = arr;%0A  return %22my stack%22;%0A%7D%0Avar err = Error();%0ACAPTURER(err);%0Atap.eq(err.stack, %22my stack%22, %22got return value%22);%0Atap.eq(prepErr, err, %22saw correct object%22);%0Atap.ok(Array.isArray(prepArr), %22got array too%22);%0Atap.eq(prepArr%5B0%5D.constructor.name, %22CallSite%22, %22correct object type%22);%0Atap.eq(prepArr%5B0%5D.getFunction(), CAPTURER, %22correct function%22);%0Atap.ok(prepArr.length %3E 1, %22multiple callsites%22);%0A%0A// stack limiting%0AError.stackTraceLimit = 1;%0Avar err = Error();%0ACAPTURER(err);%0Atap.ok(err.stack);%0Atap.eq(prepArr.length, 1, %22only one callsite%22);%0Atap.eq(prepArr%5B0%5D.getFunction(), CAPTURER, %22correct function%22);%0A

add JavaScriptStackTraceApi tests