dodona-edu / universal-judge

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

Improve JavaScript handling of Map/Object #503

Closed niknetniko closed 4 months ago

niknetniko commented 5 months ago

Switch to Map by default and introduce two new advanced types to make the distinction between Map/Object when needed. The new types are dictionary (since map is already in use) for the data structure and object for the JavaScript-specific Object type, which no other language natively supports at the moment.

All existing languages have been updated to support the dictionary advanced type if they supported the basic map type, while the advanced type for object is reduced, except in JavaScript, which supports both.

As part of this, the way to indicate type limits on certain elements of collections has been reworked to be more flexible. It is now possible to specify limits for all types separately. At the moment, we still only recognise limits on map keys and set elements, so nothing changes there.

Fixes #386

pdawyndt commented 4 months ago

@niknetniko Feel free to merge this pull request. I have already updated the JavaScript Str8ts exercise (wrongly assuming that you already merged this request) to see if we could now use a Map using Number-keys.

As soon as this pull request gets merged, I will update the other exercises mentioned in https://github.ugent.be/Scriptingtalen/javascript-oefeningen/issues/16

pdawyndt commented 4 months ago

The Str8ts exercise now uses dictionaries (Map or Object) that maps numbers (Number) onto strings (String). However, before this pull request got merged, TESTed seems to give the wrong explanation why the JavaScript-module does not support this exercise:

This test suite is not solvable in JavaScript. The required map types are: frozenset({<BasicNumericTypes.INTEGER: 'integer'>}) The programming language has support for: {<BasicStringTypes.TEXT: 'text'>} This means support is lacking for these: frozenset({<BasicNumericTypes.INTEGER: 'integer'>}) Note that support for certain types means real support, not reduced support. For example, if tuples are required, the language must have a dedicated tuple type. One solution is to use less-specific types, e.g. using a sequence instead of a tuple.

niknetniko commented 4 months ago

@pdawyndt The PR was merged.

The Str8ts exercise now uses dictionaries (Map or Object) that maps numbers (Number) onto strings (String). However, before this pull request got merged, TESTed seems to give the wrong explanation why the JavaScript-module does not support this exercise:

This test suite is not solvable in JavaScript. The required map types are: frozenset({<BasicNumericTypes.INTEGER: 'integer'>}) The programming language has support for: {<BasicStringTypes.TEXT: 'text'>} This means support is lacking for these: frozenset({<BasicNumericTypes.INTEGER: 'integer'>}) Note that support for certain types means real support, not reduced support. For example, if tuples are required, the language must have a dedicated tuple type. One solution is to use less-specific types, e.g. using a sequence instead of a tuple.

The set and object restrictions used to be linked in JavaScript (although this was erroneously), but is PR should have also fixed this.