[SERVER-32665] tojson should print the elements when passed a Set object Created: 11/Jan/18  Updated: 04/Jan/23  Resolved: 04/Jan/23

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Backlog - Server Tooling and Methods (STM) (Inactive)
Resolution: Duplicate Votes: 0
Labels: stm, tig-assertjs, tig-qwin-eligible
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-69961 Assign expected / actual for assert.s... Closed
is duplicated by SERVER-40107 assert.eq always returns true for jav... Closed
Related
related to SERVER-50614 JS 'Set' type does not serialize well... Backlog
Assigned Teams:
Server Tooling & Methods
Participants:
Story Points: 2

 Description   

In the shell, doing:

tojson(new Set([1,2,3]))

Just prints out a misleading "{ }". tojson should either explicitly throw an error or print out the elements.



 Comments   
Comment by Romans Kasperovics [ 04/Jan/23 ]

This issue was solved within SERVER-69961.

Comment by Romans Kasperovics [ 04/Jan/23 ]

There is a separate function assert.setEq() which compares two sets properly.

Comment by Steven Vannelli [ 10/May/22 ]

Moving this ticket to the Backlog and removing the "Backlog" fixVersion as per our latest policy for using fixVersions.

Comment by Max Hirschhorn [ 06/Nov/18 ]

We should take care to ensure that order is ignored if we choose to convert the Set instance to an Array instance.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/values

Comment by David Bradford (Inactive) [ 30/Jul/18 ]

Because assert.eq function uses friendlyEqual, which uses tojson, this issue means that assert.eq will always be successful with Sets even if it should fail.

Moving to the TIG backlog to get prioritized.

Comment by Gregory McKeon (Inactive) [ 22/Jan/18 ]

The platforms team isn't prioritizing this, but PR's are welcome!

Generated at Thu Feb 08 04:30:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.