Community
Participate
Working Groups
We already have literal expressions for Sequences, Bags, OrderedSets and so on, but we don't have one for Map objects. In the upcoming version of EUnit, we currently do something like this: $with Sequence {"", "A"} @test operation etc() { -- ... } In the $with annotation, we intend to say 'the default model is A', but this meaning is hard to see, as we're using a Sequence instead of a Map. It would be easier to read with a Map literal expression, like this: $with Map {"" = "A"} @test operation etc() { -- ... } After talking with Dimitris, we'd like to use "=" instead of ":" (à la Python) or "=>" (à la Perl) as key-value separator, in order to stay closer to OCL and its Tuples. However, this may introduce ambiguities in the grammar. How should we interpret "Map { 1 = 2 = 3 }"? Should it have one (false, 3) pair, or one (1, false) pair?
Created attachment 191687 [details] Patch which implements Map literals Here is a patch which adds Map literals to EOL, including several test cases for the EOL acceptance suite. Please note that: - To make the patch more readable, it does not include the code generated by ANTLR. After applying the patch, ANTLR will have to be run again in all E*L languages. - The "a = b = c" ambiguity has been resolved by using additiveExpression for the key, and logicalExpression for the value. Therefore, keys cannot use logical or relational operators unless between parenthesis, and "1 = 2 = 3" will be split into 1 (the key) and 2 = 3 (the value).
I have integrated the patch which adds Map literals. I'm not sure about using them in EUnit, though: I think Louis
I have integrated the patch. Do you think it would be OK to change $with to use Map literals now, before (hopefully) EUnit starts being more widely used?
(In reply to comment #3) > I have integrated the patch. Do you think it would be OK to change $with to use > Map literals now, before (hopefully) EUnit starts being more widely used? +1 for changing EUnit now. If we choose to change it now, we should also make a note to the update the paper (if it's accepted)!
I've changed EUnit so it uses Map literals. I've also updated the tests, examples and the EUnit chapter accordingly. I'll tackle the "floating point numbers do not allow exponents" issue described in 333740 and then write the section on EOL literals.
I have just committed to SVN the section on EOL literals to the book. Marking this as fixed in SVN.
Fixed in 0.9.1