Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 8312218

Browse files
committed
test: update inspect Promise output
PR-URL: #474 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com> Reviewed-By: Jimmy Thomson <jithomso@microsoft.com> Reviewed-By: Seth Brenith <sethb@microsoft.com>
1 parent 8fcb1b4 commit 8312218

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

test/parallel/parallel.status

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ test-url-domain-ascii-unicode : SKIP
8686
test-util : SKIP
8787
test-util-format-shared-arraybuffer : SKIP
8888
test-util-inspect-proxy : SKIP
89-
test-util-inspect : SKIP
9089
test-v8-serdes : SKIP
9190
test-v8-serdes-sharedarraybuffer : SKIP
9291
test-vm-cached-data : SKIP

test/parallel/test-util-inspect.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,11 @@ if (!common.isChakraEngine) {
479479
obj = vm.runInNewContext('var s=new Set();s.add(1);s.add(2);s', {});
480480
assert.strictEqual(util.inspect(obj), 'Set { 1, 2 }');
481481
obj = vm.runInNewContext('fn=function(){};new Promise(fn,fn)', {});
482-
assert.strictEqual(util.inspect(obj), common.engineSpecificMessage({
483-
v8: 'Promise { <pending> }',
484-
chakracore: 'Promise {}'
485-
}));
482+
assert.strictEqual(util.inspect(obj),
483+
common.engineSpecificMessage({
484+
v8: 'Promise { <pending> }',
485+
chakracore: 'Promise {}'
486+
}));
486487
}
487488

488489
// Test for property descriptors.
@@ -901,39 +902,37 @@ if (typeof Symbol !== 'undefined') {
901902
}
902903

903904
// Test Promise.
905+
// NOTE: ChakraCore promise objects are only inspectable when created from
906+
// native code. Promises created in script will always show as `<pending>`.
904907
{
905908
const resolved = Promise.resolve(3);
906909
assert.strictEqual(util.inspect(resolved),
907910
common.engineSpecificMessage({
908911
v8: 'Promise { 3 }',
909-
chakracore: 'Promise {}'
912+
chakracore: 'Promise { <pending> }'
910913
}));
911914

912915
const rejected = Promise.reject(3);
913916
assert.strictEqual(util.inspect(rejected),
914917
common.engineSpecificMessage({
915918
v8: 'Promise { <rejected> 3 }',
916-
chakracore: 'Promise {}'
919+
chakracore: 'Promise { <pending> }'
917920
}));
918921
// Squelch UnhandledPromiseRejection.
919922
rejected.catch(() => {});
920923

921924
const pending = new Promise(() => {});
922-
assert.strictEqual(util.inspect(pending), common.engineSpecificMessage({
923-
v8: 'Promise { <pending> }',
924-
chakracore: 'Promise {}'
925-
}));
925+
assert.strictEqual(util.inspect(pending), 'Promise { <pending> }');
926926

927927
const promiseWithProperty = Promise.resolve('foo');
928928
promiseWithProperty.bar = 42;
929929
assert.strictEqual(util.inspect(promiseWithProperty),
930930
common.engineSpecificMessage({
931931
v8: 'Promise { \'foo\', bar: 42 }',
932-
chakracore: 'Promise { bar: 42 }'
932+
chakracore: 'Promise { <pending>, bar: 42 }'
933933
}));
934934
}
935935

936-
937936
// Make sure it doesn't choke on polyfills. Unlike Set/Map, there is no standard
938937
// interface to synchronously inspect a Promise, so our techniques only work on
939938
// a bonafide native Promise.
@@ -1029,10 +1028,7 @@ if (!common.isChakraEngine) {
10291028
assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])),
10301029
'MapSubclass [Map] { \'foo\' => 42 }');
10311030
assert.strictEqual(util.inspect(new PromiseSubclass(() => {})),
1032-
common.engineSpecificMessage({
1033-
v8: 'PromiseSubclass [Promise] { <pending> }',
1034-
chakracore: 'PromiseSubclass [Promise] {}'
1035-
}));
1031+
'PromiseSubclass [Promise] { <pending> }');
10361032
assert.strictEqual(
10371033
util.inspect({ a: { b: new ArraySubclass([1, [2], 3]) } }, { depth: 1 }),
10381034
'{ a: { b: [ArraySubclass] } }'
@@ -1357,8 +1353,14 @@ util.inspect(process);
13571353
expect = [
13581354
'{',
13591355
' a: [Function] {',
1360-
' [length]: 0,',
1361-
" [name]: ''",
1356+
common.engineSpecificMessage({
1357+
v8: ' [length]: 0,',
1358+
chakracore: " [name]: '',",
1359+
}),
1360+
common.engineSpecificMessage({
1361+
v8: " [name]: ''",
1362+
chakracore: ' [length]: 0',
1363+
}),
13621364
' },',
13631365
' b: [Number: 3]',
13641366
'}'

0 commit comments

Comments
 (0)