-
Notifications
You must be signed in to change notification settings - Fork 461
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
testing ECMAScript parsers #196
Comments
I think this is a great idea, and I'd like to help make it happen! I don't |
(The 'negative' field has values 'SyntaxError' and 'ReferenceError', so presumably already handles your intuition.) The thing is, a SyntaxError can arise in various different ways:
Moreover, these can happen "statically" (for the top-level Script or Module) or 4. "dynamically" (for a call to eval() or Function()). Now, when the test suite is only testing ES implementations, these distinctions aren't that important, because the end result is the same. However, if you're testing something less than a full implementation, the distinctions are important, because your software probably doesn't implement all sources of SyntaxErrors. So if the test is tagged as 'SyntaxError', you want to know if it's a SyntaxError that your software should or shouldn't be raising. In particular, an ES parser would presumably not raise "runtime" SyntaxErrors (4 above). It might or might not enforce early error rules (3). If you've written a code highlighter for JS, you might not even care about parsing errors (2), but still be interested in tokenization errors (1). That's the kind of distinction I'm proposing. |
Thanks for the explanation. I think I understand most of this now, but one
I can't think of an example of an error like this. Maybe source text encoded in
Would this be something like: var x = {;
For instance: 0 = 0; and also let x;
let x;
As in eval("!!!"); |
Although the contribution guidelines now recommend using
This means that even with a new tag like We could stick with the @bterlson I know there are test runners beyond the one included in this |
This should be fixed by #559. I'm going to move the contents of that PR to https://github.com/tc39/test262-parser-tests shortly. |
@jmdyck You can now find the parser tests at https://github.com/tc39/test262-parser-tests. |
@jmdyck As I understand the request, you were looking for the tests to be marked with the expected error "phase". The published parser tests separate out grammar errors from early errors, so I'd at least call that progress. |
I'd call it progress too. (I did say that test262-parser-tests improves things.) |
Oh, sorry, I did not mean to imply that you would not call that progress. I realise now it could have been read that way. |
No problem. |
I think this can be closed, since the original issue is solved. |
I'm wondering if it would be possible to increase test262's usefulness for testing ECMAScript parsers. Presumably, every positive test in the suite is a positive test for a parser, but not so for negative tests. I'm guessing that the negative parser tests are (pretty much?) a subset of the tests marked
negative: SyntaxError
, but I don't think there's a way to auto-detect which ones.(According to https://github.com/tc39/test262/blob/master/CONTRIBUTING.md :
But note that (a) this uses the old header syntax, and (b) no "negative:" field in the suite currently uses that pattern, so I suspect it's stale advice.)
What I had in mind is a new field for the file-header (say, "parser-negative:") to designate which tests are negative for parsers. The value for the field could be an indication of roughly at what 'level' the error occurs (lexical, syntactic, early error, others?) to accommodate parsers of different "depths". E.g., when testing a parser that checks for early errors, you'd expect tests matching
to cause an error, but when testing a parser that doesn't, you'd only expect
tests to cause errors. (I realize that not all parsers would conform to such a categorization of errors, but at least it would be a better starting point than now.)
(I suppose, if tests had references back to the pertinent section(s) of the spec, that might supply the necessary info, e.g. a pointer to a Syntax section vs an Early Errors section. But I haven't heard any discussion of adding such references lately, so I'm doubtful it'll happen any time soon.)
The text was updated successfully, but these errors were encountered: