dodona-edu / universal-judge

Universal judge for educational software testing
https://docs.dodona.be/en/tested
MIT License
9 stars 5 forks source link

representation of Set and Map as return value #510

Closed pdawyndt closed 4 months ago

pdawyndt commented 4 months ago

When a JavaScript expression yields a Set object, it is displayed as new Set([value1, value2, ...]) in the feedback table. For simplicity, we may consider dropping the new keyword in that case. Idem for Maps.

I understand that this would deviate from using a Set or a Map as part of a JavaScript expression, but this would look simpler in the feedback table.

niknetniko commented 4 months ago

I agree that especially the map representation is not ideal, for example draaien(new Map([["x", 0], ["y", 4]]), new Map([["x", 2], ["y", 4]]), new Map([["x", 5], ["y", 2]])) instead of draaien({"x": 0, "y": 4}, {"x": 2, "y": 4}, {"x": 5, "y": 2}). In this particular example we maybe want to use objects instead of maps, but it does illustrate the problem.

I am hesitant to provide an ad-hoc solution for JavaScript, we might want to tackle this together with or as part of #350.

pdawyndt commented 4 months ago

I discussed with @tibdhond where we would use the generic type map or one of the specific types dictionary and object. Wherever an object represents a struct (as in the above case) we opted for object (as in the example you mentioned above). Wherever an objects represents a lookup-table we opted for a dictionary. None of the exercises we have so far will eventually use the generic map type, because JavaScript is not orthogonal in manipulating Object and Map objects.

niknetniko commented 4 months ago

I'll close this in favour of #350 then, to revisit it there if needed.