@@ -4,32 +4,34 @@ const common = require('../../common');
44const test_promise = require ( `./build/${ common . buildType } /test_promise` ) ;
55const assert = require ( 'assert' ) ;
66
7- let expected_result , promise ;
8-
97// 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+ }
1919
2020// 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+ }
3032
3133// Chaining
32- promise = test_promise . createPromise ( ) ;
34+ const promise = test_promise . createPromise ( ) ;
3335promise . then (
3436 common . mustCall ( function ( result ) {
3537 assert . strictEqual ( result , 'chained answer' ,
@@ -38,23 +40,10 @@ promise.then(
3840 common . mustNotCall ( ) ) ;
3941test_promise . concludeCurrentPromise ( Promise . resolve ( 'chained answer' ) , true ) ;
4042
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