dodona-edu / universal-judge

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

Support map with non-string keys in JavaScript #386

Closed pdawyndt closed 1 month ago

pdawyndt commented 1 year ago

Suggestion: Consider supporting maps with non-string keys in JavaScript as Map, where Object can only be used for maps with string keys.

Rationale: JavaScript objects (Object) always have string keys. As a result, TESTed currently also supports maps with string keys in JavaScript. However, TESTed also supports Map as a representation of maps in JavaScript, and they can have non-string keys.

pdawyndt commented 3 months ago

Are there any ideas on how to resolve this issue? As a use case, I would apply this for the exercise "Str8ts" which currently has two methods the now require to have String keys instead of the (more logical) Number keys.

niknetniko commented 3 months ago

A full solution would need two parts here I think:

Then, we can support Map with different types of keys in the test suite in addition to objects.

pdawyndt commented 3 months ago

I would agree with this solution. As far as I can judge, this does not seem to break anything (except for the fact that we may have to add some explicit types wherever we explicitly want to pass Object arguments instead of Map arguments).

One issue that came to mind for later: when TESTed supports map-item access, we need to take into account that the syntax is different for Map and Object in JavaScript.