"use strict" ; module /**
 * Module dependencies.
 */ var util = require ( "util" ) ; var Base = require ( "./base" ) ; var constants = require ( "../runner" ) . default . constants ; var EVENT_TEST_PASS = constants . EVENT_TEST_PASS ; var EVENT_TEST_FAIL = constants . EVENT_TEST_FAIL ; var EVENT_RUN_BEGIN = constants . EVENT_RUN_BEGIN ; var EVENT_RUN_END = constants . EVENT_RUN_END ; var EVENT_TEST_PENDING = constants . EVENT_TEST_PENDING ; var EVENT_TEST_END = constants . EVENT_TEST_END ; var inherits = require ( "../utils" ) . inherits ; var sprintf = util . format ; /**
 * Expose `TAP`.
 */ exports = module . exports = TAP ; public class memberof extends Mocha . reporters . Base param { Runner } runner param { Object } options function TAP ( runner , options ) { Base . call ( this , runner , options ) ; var self = this ; var n = 1 ; var tapVersion = "12" ; if ( options && options . reporterOptions ) { if ( options . reporterOptions . tapVersion ) { tapVersion = options . reporterOptions . tapVersion . toString ( ) ; } } this . _producer = createProducer ( tapVersion ) ; runner . once ( EVENT_RUN_BEGIN , function ( ) { self . _producer . writeVersion ( ) ; } ) ; runner . on ( EVENT_TEST_END , function ( ) { ++ n ; } ) ; runner . on ( EVENT_TEST_PENDING , function ( test ) { self . _producer . writePending ( n , test ) ; } ) ; runner . on ( EVENT_TEST_PASS , function ( test ) { self . _producer . writePass ( n , test ) ; } ) ; runner . on ( EVENT_TEST_FAIL , function ( test , err ) { self . _producer . writeFail ( n , test , err ) ; } ) ; runner . once ( EVENT_RUN_END , function ( ) { self . _producer . writeEpilogue ( runner . stats ) ; } ) ; } /**
 * Inherit from `Base.prototype`.
 */ inherits ( TAP , Base ) ; private param { Test } test return { String } function title ( test ) { return test . fullTitle ( ) . replace ( /#/g , "" ) ; } private param { string } format param { ... * } varArgs function println ( format , varArgs ) { var vargs = Array . from ( arguments ) ; vargs [ 0 ] += "\n" ; process . stdout . write ( sprintf . apply ( null , vargs ) ) ; } private param { string } tapVersion returns { TAPProducer } throws function createProducer ( tapVersion ) { var producers = { 12 : new TAP12Producer ( ) , 13 : new TAP13Producer ( ) , } ; var producer = producers [ tapVersion ] ; if ( ! producer ) { throw new Error ( "invalid or unsupported TAP version: " + JSON . stringify ( tapVersion ) ) ; } return producer ; } summary description private constructor function TAPProducer ( ) { } abstract TAPProducer . prototype . writeVersion = function ( ) { } ; abstract param { number } ntests TAPProducer . prototype . writePlan = function ( ntests ) { println ( "%d..%d" , 1 , ntests ) ; } ; abstract param { number } n param { Test } test TAPProducer . prototype . writePass = function ( n , test ) { println ( "ok %d %s" , n , title ( test ) ) ; } ; abstract param { number } n param { Test } test TAPProducer . prototype . writePending = function ( n , test ) { println ( "ok %d %s # SKIP -" , n , title ( test ) ) ; } ; abstract param { number } n param { Test } test param { Error } err TAPProducer . prototype . writeFail = function ( n , test , err ) { println ( "not ok %d %s" , n , title ( test ) ) ; } ; abstract param { Object } stats TAPProducer . prototype . writeEpilogue = function ( stats ) { println ( "# tests " + ( stats . passes + stats . failures ) ) ; println ( "# pass " + stats . passes ) ; println ( "# fail " + stats . failures ) ; this . writePlan ( stats . passes + stats . failures + stats . pending ) ; } ; summary description private constructor extends TAPProducer see https function TAP12Producer ( ) { @override
      this . writeFail = function ( n , test , err ) { TAPProducer . prototype . writeFail . call ( this , n , test , err ) ; if ( err . message ) { println ( err . message . replace ( /^/gm , "  " ) ) ; } if ( err . stack ) { println ( err . stack . replace ( /^/gm , "  " ) ) ; } } ; } /**
 * Inherit from `TAPProducer.prototype`.
 */ inherits ( TAP12Producer , TAPProducer ) ; summary description private constructor extends TAPProducer see https function TAP13Producer ( ) { @override
      this . writeVersion = function ( ) { println ( "TAP version 13" ) ; } ; @override
      this . writeFail = function ( n , test , err ) { TAPProducer . prototype . writeFail . call ( this , n , test , err ) ; var emitYamlBlock = err . message != null || err . stack != null ; if ( emitYamlBlock ) { println ( indent ( 1 ) + "---" ) ; if ( err . message ) { println ( indent ( 2 ) + "message: |-" ) ; println ( err . message . replace ( /^/gm , indent ( 3 ) ) ) ; } if ( err . stack ) { println ( indent ( 2 ) + "stack: |-" ) ; println ( err . stack . replace ( /^/gm , indent ( 3 ) ) ) ; } println ( indent ( 1 ) + "..." ) ; } } ; function indent ( level ) { return Array ( level + 1 ) . join ( "  " ) ; } } /**
 * Inherit from `TAPProducer.prototype`.
 */ inherits ( TAP13Producer , TAPProducer ) ; TAP . description = "TAP-compatible output" ;