New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Too easy create incoherent result without enough restriction #115
Comments
That does not look incoherent to me There are a lot of cobinations, but, unlike the DateTimeFormat components bag, I'm not aware of any combinations that are incoherent. Can you provide an example? |
or
|
Actaully, if we switch to pass ListFormat with {type: "unit", style} then the output will be |
I think those are not incoherent, but I get your point. |
Yeah, I don't believe the results are completely incoherent either, but I understand your concern. That said, fine-tuning the result in this way happens due to explicit programmer choice, and the default "blanket" styles (just to call them that) are fairly coherent in this way. I feel that it's fine to allow this degree of freedom to the programmer if they believe a certain kind of result makes sense for their interface and as we've realized after months if not over a year of circling around, there's no perfect solution to this API design. |
ok, If I follow your argument of " it's fine to allow this degree of freedom to the programmer if they believe a certain kind of result makes sense" then would that also apply to locales so we should allow programmer to set the locale of the years to English, months to French, weeks to Thai, and days to Chinese for the sake of "allow this degree of freedom to the programmer if they believe a certain kind of result makes sense" ? I am not supporting such move. I just want to use that to point out that most arguments you can think about to counter that move could also use to counter the current flexiblity to let the programmer to mixed styles together. The key reason I bring this up is because I try to wrinte down a test plan to test the implementation and then I realize the size of the testing matrix is just way too big for me to handle. |
I don't agree that mixed locales and mixed unit styles are equally "incoherent" or even are so in the same way. That said, we have a more pressing issue here: we've tried multiple other designs for this API over and over again, and nothing worked. This is the only workable design we could come up with. Could we perhaps try to innovate on the side of test262 instead? |
Conclusion: @ryzokuken to drive a relationship witih @ptomato to devise a Test262 strategy for this and come back with concrete recommendations that could reduce the testing complexity. |
TG2 discussion: https://github.com/tc39/ecma402/blob/master/meetings/notes-2022-10-06.md#too-easy-create-incoherent-result-without-enough-restriction Conclusion: We are happy with @ptomato's proposed testing strategy. @romulocintra and @ryzokuken will write the tests. |
The last conclusion of what discussed in https://github.com/tc39/ecma402/blob/master/meetings/notes-2022-10-06.md#too-easy-create-incoherent-result-without-enough-restriction now is more than 8 months after Oct 6, 2022, I look at https://github.com/tc39/test262/tree/main/test/intl402/DurationFormat/prototype/format there are zero coverage of testing how the following options will impact the output of Intl.DurationFormat.prototype.(format|formatToParts) "years" There are test to test the impact the output of Intl.DurationFormat.prototype.(format|formatToParts) from "style" and some test to valid these option reading will or will not throw error, but no validation of the formtted result. Any ETA for the availability? |
Here's a potential testing strategy. Take the product of the following:
The thing to test on the output is which fields end up being present in the output, which we can determine from formatToParts. We can run over all this in a loop of 20*4*(1 + 9 + 36)*(12ish) = 44160 cases. |
what is (1 + 9 + 36) ? I do not understand what is that. |
also, {hours, minutes, seconds} has 5 not 3 styles |
There are
Yes which is what I meant with "12ish"; it should be more for those units
Yes, true, we should include fractionalDigits as an extra axis. I'd say just three values (undefined, 0, 3) should be enough. With these combinations we're probably going to be above 100k cases, but I think that's fine. These can be performed in a tight loop, and the expectations can be derived directly from the test inputs. Note also that one possible expectation is RangeError, because not all combinations here are valid. |
oh, I see, be aware with such strategy, option bags such as the following will NOT be part of that testing {years: "short", months: "long", days: "narrow"} => becasue this is a combination of 3 unit styles, more than 2. |
That's fair. Combinations of 3 might be safer. Just throwing out ideas on how to make the tests run faster. |
Currently, the API allow "very flexible" setting to each fields, which mean it could easily produce incoherent results- is this what we really want to produce?
For example:
will produce
"1 year, 2 mths, 3 wks, 3 days, 4 hr, 5 min, 6 sec, and 7 ms"
this approach also provide a lot of knot and bolt for the caller to tune,
But it also means our test need to cover a huge number of testing configuration:
with "style" and a total 10 styles and 10 displays for each field, the total combination to be test are
(4+1) x (5+1)^10 x (2+1)^10 = 1.7852336e+13 way too many possible combinations to test (yes, I know some combination are not allowed, but that mean we need to test those combination should throw )
4+1 : style could be undefined, "long", "short", "narrow", "digital" => 5 possible values to test
5+1: style for each field could be undefined, "long", "short", "narrow", "numeric" and "2-digits" => 6 possible values to test
2+1: display for each field could be undefined, "auto", "always" => 3 possible values to test
I am not even counting the 11 possible values of fractionalDigits undefined, 0, .... 9 => 11 possible settings.
The text was updated successfully, but these errors were encountered: