File tree 3 files changed +25
-16
lines changed
3 files changed +25
-16
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ tap.test('async4', function (t) {
119
119
120
120
tap . test ( 'async5' , function ( t ) {
121
121
runProgram ( 'async-await' , 'async5.js' , function ( r ) {
122
- t . same ( r . stdout . toString ( 'utf8' ) , [
122
+ t . same ( stripFullStack ( r . stdout . toString ( 'utf8' ) ) , [
123
123
'TAP version 13' ,
124
124
'# async5' ,
125
125
'ok 1 before server' ,
@@ -128,14 +128,24 @@ tap.test('async5', function (t) {
128
128
'ok 4 after request' ,
129
129
'ok 5 should be equal' ,
130
130
'ok 6 should be equal' ,
131
+ 'ok 7 undefined' ,
132
+ 'not ok 8 .end() called twice' ,
133
+ ' ---' ,
134
+ ' operator: fail' ,
135
+ ' at: Server.<anonymous> ($TEST/async-await/async5.js:$LINE:$COL)' ,
136
+ ' stack: |-' ,
137
+ ' Error: .end() called twice' ,
138
+ ' [... stack stripped ...]' ,
139
+ ' at Server.<anonymous> ($TEST/async-await/async5.js:$LINE:$COL)' ,
140
+ ' [... stack stripped ...]' ,
141
+ ' ...' ,
131
142
'' ,
132
- '1..6' ,
133
- '# tests 6' ,
134
- '# pass 6' ,
135
- '' ,
136
- '# ok'
143
+ '1..8' ,
144
+ '# tests 8' ,
145
+ '# pass 7' ,
146
+ '# fail 1'
137
147
] . join ( '\n' ) + '\n\n' ) ;
138
- t . same ( r . exitCode , 0 ) ;
148
+ t . same ( r . exitCode , 1 ) ;
139
149
t . same ( r . stderr . toString ( 'utf8' ) , '' ) ;
140
150
t . end ( ) ;
141
151
} ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ test('async1', async function myTest(t) {
7
7
setTimeout ( resolve , 10 ) ;
8
8
} ) ;
9
9
t . ok ( true , 'after await' ) ;
10
+ t . end ( ) ;
10
11
} catch ( err ) {
11
12
t . ifError ( err ) ;
12
13
}
Original file line number Diff line number Diff line change @@ -42,16 +42,14 @@ test('async5', async function myTest(t) {
42
42
res . resume ( ) ;
43
43
t . equal ( res . statusCode , 200 ) ;
44
44
45
- await new Promise ( function ( resolve , reject ) {
46
- setTimeout ( function ( ) {
47
- t . equal ( mockDb . state , 'new' ) ;
45
+ setTimeout ( function ( ) {
46
+ t . equal ( mockDb . state , 'new' ) ;
48
47
49
- server . close ( function ( err ) {
50
- if ( err ) { reject ( err ) ; }
51
- else { resolve ( ) ; }
52
- } ) ;
53
- } , 50 ) ;
54
- } ) ;
48
+ server . close ( function ( err ) {
49
+ t . ifError ( err ) ;
50
+ t . end ( ) ;
51
+ } ) ;
52
+ } , 50 ) ;
55
53
} catch ( err ) {
56
54
t . ifError ( err ) ;
57
55
t . end ( ) ;
You can’t perform that action at this time.
0 commit comments