Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add tests from [email protected] #696

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

Merged
merged 1 commit into from
Mar 8, 2024
Merged

Add tests from [email protected] #696

merged 1 commit into from
Mar 8, 2024

Conversation

eemeli
Copy link
Collaborator

@eemeli eemeli commented Feb 28, 2024

Update the test suite with new and changed tests to match the latest spec, as a copy from https://github.com/messageformat/messageformat/tree/[email protected]/packages/mf2-messageformat/src/__fixtures.

These add tests for markup-close with options, :date, :time, and :datetime, as well as various corner cases encountered during development.

@eemeli eemeli added the test-suite Issue pertains to tests label Feb 28, 2024
@eemeli eemeli added this to the Technical Preview (CLDR v45) milestone Feb 28, 2024
@aphillips aphillips added the LDML45 LDML45 Release (Tech Preview) label Feb 28, 2024
{
"src": "{horse :date}",
"exp": "{|horse|}",
"errors": [{ "name": "RangeError" }]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the spec says this should be an invalid expression error. Your code might call this a RangeError. Fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, true. I currently don't add a wrapper for the built in JS RangeError that's the cause here, as the :number spec requires.

Comment on lines +19 to +22
"missing space {:func @bar@baz}",
"missing space {:func @bar=42@baz}",
"missing space {+reserved@bar}",
"missing space {&private@bar}",
Copy link
Collaborator

@gibson042 gibson042 Mar 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't seem like "missing space".

Suggested change
"missing space {:func @bar@baz}",
"missing space {:func @bar=42@baz}",
"missing space {+reserved@bar}",
"missing space {&private@bar}",
"missing equals {:func @bar@baz}",
"missing quotes {:func @bar=42@baz}",
"reserved {+reserved@bar}",
"private {&private@bar}",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of those can be turned into valid syntax with the addition of a single space:

Suggested change
"missing space {:func @bar@baz}",
"missing space {:func @bar=42@baz}",
"missing space {+reserved@bar}",
"missing space {&private@bar}",
"missing space {:func @bar @baz}",
"missing space {:func @bar=42 @baz}",
"missing space {+reserved @bar}",
"missing space {&private @bar}",

(the above is not intended as an actual suggestion, just to show a nice diff)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, though, they are invalid name tests. You created them by removing non-optional spaces, of course.

@mihnita
Copy link
Collaborator

mihnita commented Mar 4, 2024

Suggestion (does not have to be in this PR): unify schemas?

A good target would be the one used for functions.

For example syntax-errors:

{
    "errors" : [
        {
           "src": "missing space {|foo|:func}",
        }
    ]
}

And core:

{
    "errors" : [
       ... the current cases
   ]
}

@eemeli
Copy link
Collaborator Author

eemeli commented Mar 4, 2024

Suggestion (does not have to be in this PR): unify schemas?

A good target would be the one used for functions.

Not really sure what you mean here. At least for now, all of the syntax-errors.json entries are spec'd just to produce a syntax or data model error, and formatting those messages should never even get to calling any functions. The errors in the other files are runtime errors.

@mihnita
Copy link
Collaborator

mihnita commented Mar 6, 2024

Not really sure what you mean here.
At least for now, all of the syntax-errors.json entries are spec'd just to produce a syntax or data model error

What I mean is that syntax-errors.json contains a list of strings that should fail parsing.
But there is no way to tell what is the error they fail with.

For example:

[
  ...
  "bad {:placeholder option=x option=x}",
  ...
  ".input {$foo} .input {$foo} {{_}}"
  ...
]

vs.

{
  "syntax-errors": [
    ...
  ],
  "data-model-errors": [      
    {
      "src": "bad {:placeholder option=x option=x}",
      "errors": [{ "type": "duplicate-option-name" }]
    }
    {
      "src": ".input {$foo} .input {$foo} {{_}}",
      "errors": [{ "type": "duplicate-declaration" }]
    }     
  ]
}

The second benefit is that there is one single schema for all test files.
Making it easier to parse (at least in some languages :-).

@eemeli
Copy link
Collaborator Author

eemeli commented Mar 7, 2024

@aphillips Could this be merged, so that further work on the tests can build on top of it, such as #707 and #708? I understood that to be the conclusion reached during the last call.

@aphillips
Copy link
Member

Per our conversation, we were waiting on people not named @aphillips and @eemeli to review before merging. But we're holding up additional work by retaining this as a PR.

@aphillips aphillips merged commit e761964 into main Mar 8, 2024
@eemeli eemeli deleted the add-tests branch March 8, 2024 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LDML45 LDML45 Release (Tech Preview) test-suite Issue pertains to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants