@@ -81,11 +81,11 @@ tap.test('preserves stack trace for failed assertions', function (tt) {
81
81
tt . equal ( typeof data . diag . stack , 'string' ) ;
82
82
at = data . diag . at || '' ;
83
83
stack = data . diag . stack || '' ;
84
- tt . ok ( / ^ E r r o r : f a l s e s h o u l d b e t r u e ( \n a t .+ ) + / . exec ( stack ) , 'stack should be a stack' )
84
+ tt . ok ( / ^ E r r o r : t r u e s h o u l d b e f a l s e ( \n a t .+ ) + / . exec ( stack ) , 'stack should be a stack' )
85
85
tt . deepEqual ( data , {
86
86
ok : false ,
87
87
id : 1 ,
88
- name : "false should be true " ,
88
+ name : "true should be false " ,
89
89
diag : {
90
90
at : at ,
91
91
stack : stack ,
@@ -103,7 +103,7 @@ tap.test('preserves stack trace for failed assertions', function (tt) {
103
103
body ,
104
104
'TAP version 13\n'
105
105
+ '# t.equal stack trace\n'
106
- + 'not ok 1 false should be true \n'
106
+ + 'not ok 1 true should be false \n'
107
107
+ ' ---\n'
108
108
+ ' operator: equal\n'
109
109
+ ' expected: false\n'
@@ -129,7 +129,72 @@ tap.test('preserves stack trace for failed assertions', function (tt) {
129
129
130
130
test ( 't.equal stack trace' , function ( t ) {
131
131
t . plan ( 1 ) ;
132
- t . equal ( true , false , 'false should be true' ) ;
132
+ t . equal ( true , false , 'true should be false' ) ;
133
+ } ) ;
134
+ } ) ;
135
+
136
+ tap . test ( 'preserves stack trace for failed assertions where actual===falsy' , function ( tt ) {
137
+ tt . plan ( 6 ) ;
138
+
139
+ var test = tape . createHarness ( ) ;
140
+ var stream = test . createStream ( ) ;
141
+ var parser = stream . pipe ( tapParser ( ) ) ;
142
+
143
+ var stack = ''
144
+ parser . once ( 'assert' , function ( data ) {
145
+ tt . equal ( typeof data . diag . at , 'string' ) ;
146
+ tt . equal ( typeof data . diag . stack , 'string' ) ;
147
+ at = data . diag . at || '' ;
148
+ stack = data . diag . stack || '' ;
149
+ tt . ok ( / ^ E r r o r : f a l s e s h o u l d b e t r u e ( \n a t .+ ) + / . exec ( stack ) , 'stack should be a stack' )
150
+ tt . deepEqual ( data , {
151
+ ok : false ,
152
+ id : 1 ,
153
+ name : "false should be true" ,
154
+ diag : {
155
+ at : at ,
156
+ stack : stack ,
157
+ operator : 'equal' ,
158
+ expected : true ,
159
+ actual : false
160
+ }
161
+ } ) ;
162
+ } ) ;
163
+
164
+ stream . pipe ( concat ( function ( body ) {
165
+ var body = body . toString ( 'utf8' ) ;
166
+ body = stripAt ( body ) ;
167
+ tt . equal (
168
+ body ,
169
+ 'TAP version 13\n'
170
+ + '# t.equal stack trace\n'
171
+ + 'not ok 1 false should be true\n'
172
+ + ' ---\n'
173
+ + ' operator: equal\n'
174
+ + ' expected: true\n'
175
+ + ' actual: false\n'
176
+ + ' stack: |-\n'
177
+ + ' '
178
+ + stack . replace ( / \n / g, '\n ' ) + '\n'
179
+ + ' ...\n'
180
+ + '\n'
181
+ + '1..1\n'
182
+ + '# tests 1\n'
183
+ + '# pass 0\n'
184
+ + '# fail 1\n'
185
+ ) ;
186
+
187
+ tt . deepEqual ( getDiag ( body ) , {
188
+ stack : stack ,
189
+ operator : 'equal' ,
190
+ expected : true ,
191
+ actual : false
192
+ } ) ;
193
+ } ) ) ;
194
+
195
+ test ( 't.equal stack trace' , function ( t ) {
196
+ t . plan ( 1 ) ;
197
+ t . equal ( false , true , 'false should be true' ) ;
133
198
} ) ;
134
199
} ) ;
135
200
0 commit comments