Add tests for import attributes#3843
Conversation
| flags: [module] | ||
| ---*/ | ||
|
|
||
| import x from './import-assertion-1_FIXTURE.js' with {test262:'',}; |
There was a problem hiding this comment.
With the new proposal, unknown import attributes should throw rather than being ignored. Should we require runner to define a no-op test262 attribute that we can use for testing purposes?
There was a problem hiding this comment.
Not sure how the runner would add a new attribute -- the set of expected attributes isn't user-extensible is my understanding.
For this test case, it seems like type: 'js' would be sufficient?
There was a problem hiding this comment.
Not sure how the runner would add a new attribute -- the set of expected attributes isn't user-extensible is my understanding.
It's defined at the embedder level.
For this test case, it seems like type: 'js' would be sufficient?
In this specific case it would, however:
- the
typeattribute is not defined in ECMA-262. It's defined by the JSON modules proposal, but only withtype: "json" - we need multiple attributes for some tests, for example for testing the order properties in dynamic import are accessed.
There was a problem hiding this comment.
So hosts will have to implement 'test262-only' attributes?
There was a problem hiding this comment.
That seems like it'd be prohibitive for runners that aren't a JS engine's shell...
|
Nevermind -- I see this is still keeping the old tag :) |
| // Define a property on the global "this" value so that the effect of the | ||
| // expected IdentifierReference can be observed. | ||
| Object.defineProperty(globalThis, 'assert', { | ||
| get: function() { | ||
| callCount += 1; | ||
| } | ||
| }); | ||
|
|
||
| import x from './import-assertion-1_FIXTURE.js' | ||
| with | ||
| {test262:''}; | ||
|
|
There was a problem hiding this comment.
This test currently is sort of splinched; should define with and ensure callCount === 0 right?
|
|
||
| var thrown = new Test262Error(); | ||
| var options = { | ||
| get assert() { |
|
|
||
| test262 | ||
|
|
||
| :with |
There was a problem hiding this comment.
This with doesn't seem to belong here.
| '' | ||
|
|
||
| }; | ||
| import './import-assertion-2_FIXTURE.js' assert |
| '' | ||
|
|
||
| }; | ||
| export * from './import-assertion-3_FIXTURE.js' assert |
2372a51 to
de99e4c
Compare
|
I don't think this was supposed to be auto-closed by #3921! |
|
Yes it was :) This PR was split in separate PRs to make it easier to review. |
https://github.com/tc39/proposal-import-attributes
The proposal supersedes import assertions, and is at stage 3 conditional on ecma-262 editors reviewing its spec.
Closes #3829
TODO (Maybe in a separate PR, to keep this one only about renaming and copying tests):