@@ -4,32 +4,34 @@ const common = require('../../common');
4
4
const test_promise = require ( `./build/${ common . buildType } /test_promise` ) ;
5
5
const assert = require ( 'assert' ) ;
6
6
7
- let expected_result , promise ;
8
-
9
7
// A resolution
10
- expected_result = 42 ;
11
- promise = test_promise . createPromise ( ) ;
12
- promise . then (
13
- common . mustCall ( function ( result ) {
14
- assert . strictEqual ( result , expected_result ,
15
- 'promise resolved as expected' ) ;
16
- } ) ,
17
- common . mustNotCall ( ) ) ;
18
- test_promise . concludeCurrentPromise ( expected_result , true ) ;
8
+ {
9
+ const expected_result = 42 ;
10
+ const promise = test_promise . createPromise ( ) ;
11
+ promise . then (
12
+ common . mustCall ( function ( result ) {
13
+ assert . strictEqual ( result , expected_result ,
14
+ `promise resolved as expected, received ${ result } ` ) ;
15
+ } ) ,
16
+ common . mustNotCall ( ) ) ;
17
+ test_promise . concludeCurrentPromise ( expected_result , true ) ;
18
+ }
19
19
20
20
// A rejection
21
- expected_result = 'It\'s not you, it\'s me.' ;
22
- promise = test_promise . createPromise ( ) ;
23
- promise . then (
24
- common . mustNotCall ( ) ,
25
- common . mustCall ( function ( result ) {
26
- assert . strictEqual ( result , expected_result ,
27
- 'promise rejected as expected' ) ;
28
- } ) ) ;
29
- test_promise . concludeCurrentPromise ( expected_result , false ) ;
21
+ {
22
+ const expected_result = 'It\'s not you, it\'s me.' ;
23
+ const promise = test_promise . createPromise ( ) ;
24
+ promise . then (
25
+ common . mustNotCall ( ) ,
26
+ common . mustCall ( function ( result ) {
27
+ assert . strictEqual ( result , expected_result ,
28
+ `promise rejected as expected, received ${ result } ` ) ;
29
+ } ) ) ;
30
+ test_promise . concludeCurrentPromise ( expected_result , false ) ;
31
+ }
30
32
31
33
// Chaining
32
- promise = test_promise . createPromise ( ) ;
34
+ const promise = test_promise . createPromise ( ) ;
33
35
promise . then (
34
36
common . mustCall ( function ( result ) {
35
37
assert . strictEqual ( result , 'chained answer' ,
@@ -38,23 +40,10 @@ promise.then(
38
40
common . mustNotCall ( ) ) ;
39
41
test_promise . concludeCurrentPromise ( Promise . resolve ( 'chained answer' ) , true ) ;
40
42
41
- assert . strictEqual ( test_promise . isPromise ( promise ) , true ,
42
- 'natively created promise is recognized as a promise' ) ;
43
-
44
- assert . strictEqual ( test_promise . isPromise ( Promise . reject ( - 1 ) ) , true ,
45
- 'Promise created with JS is recognized as a promise' ) ;
46
-
47
- assert . strictEqual ( test_promise . isPromise ( 2.4 ) , false ,
48
- 'Number is recognized as not a promise' ) ;
49
-
50
- assert . strictEqual ( test_promise . isPromise ( 'I promise!' ) , false ,
51
- 'String is recognized as not a promise' ) ;
52
-
53
- assert . strictEqual ( test_promise . isPromise ( undefined ) , false ,
54
- 'undefined is recognized as not a promise' ) ;
55
-
56
- assert . strictEqual ( test_promise . isPromise ( null ) , false ,
57
- 'null is recognized as not a promise' ) ;
58
-
59
- assert . strictEqual ( test_promise . isPromise ( { } ) , false ,
60
- 'an object is recognized as not a promise' ) ;
43
+ assert . strictEqual ( test_promise . isPromise ( promise ) , true ) ;
44
+ assert . strictEqual ( test_promise . isPromise ( Promise . reject ( - 1 ) ) , true ) ;
45
+ assert . strictEqual ( test_promise . isPromise ( 2.4 ) , false ) ;
46
+ assert . strictEqual ( test_promise . isPromise ( 'I promise!' ) , false ) ;
47
+ assert . strictEqual ( test_promise . isPromise ( undefined ) , false ) ;
48
+ assert . strictEqual ( test_promise . isPromise ( null ) , false ) ;
49
+ assert . strictEqual ( test_promise . isPromise ( { } ) , false ) ;
0 commit comments