Skip to content
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

Refactor directive prologue tests for parsers #1592

Closed

Conversation

jugglinmike
Copy link
Contributor

@leobalter @rwaldron This is in service of gh-1356. The tests modified in this patch have a trait that differentiates them from the tests we've previously reformatted for the benefit of parsers. Because they concern the observance of strict mode, there are parsing and runtime behaviors that we need to verify. So while in those previous patches, we could just replace the calls to eval with direct program code, in this case, I've taken care to preserve assertions for runtime semantics. That said, I've still modified those tests in order to make this consideration more clear (they now test for strict mode through assignment instead of eval).

To facilitate review (and help verify that I didn't invalidate any of the old tests), I've split this work into a number of distinct commits. Hope that helps!

Promote consistency in coverage by adding new tests that correspond to
those that were authored previously.
Verify runtime semantics through assignment to an unresolvable
reference, reducing the complexity of tests that previously relied on
the semantics of the `eval` function.
Test262 already includes tests to ensure the correct runtime semantics
for these forms. Add equivalent tests designed to verify that the
equivalent parsing behavior is also observed.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-2-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: use-strict-directive

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-15-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: sec-strict-mode-code

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-2-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: use-strict-directive

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-2-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: use-strict-directive

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-19-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: sec-strict-mode-code

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-16-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: sec-strict-mode-code

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-2-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: sec-strict-mode-code

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-22-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: sec-strict-mode-code

// This code is governed by the BSD license found in the LICENSE file.

/*---
es5id: 10.1.1-25-s
Copy link
Contributor

Choose a reason for hiding this comment

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

Add or replace es5id with:

esid: sec-strict-mode-code

@jugglinmike
Copy link
Contributor Author

@rwaldron Metadata added!

@jugglinmike
Copy link
Contributor Author

It looks like the linter has a faulty rule. There are a number of ways we could address this:

  • add exceptions for the new files to the linter's white list
  • extend the regular expression with a special case for this particular esid value
  • remove the linting rule
  • relax the linting rule to simply assert the value of esid satisfies the general requirements for HTML document fragment identifiers
  • extend the linter to fetch the spec and scrape out the value identifiers

I'm happy to help out with any of these, though my preference would be the fourth. @rwaldron what do you think?

@rwaldron
Copy link
Contributor

jugglinmike#2

eval("var public = 1;");
assert.sameValue(public, 1);
test262unresolvable = null;
assert.sameValue(test262unresolvable, null);
"use strict";
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we have some coverage for the pragma only preceded by an empty statement. I did not find anything from a quick grep.

function fun() {
  ;'use strict';
  unr = null;
  assert.sameValue(unr, null);
}
fun();

@leobalter
Copy link
Member

relax the linting rule to simply assert the value of esid satisfies the general requirements for HTML document fragment identifiers

I'm positive with this solution.

@jugglinmike
Copy link
Contributor Author

To unblock this, I've submitted #1632 (as an alternative to jugglinmike#2).

@rwaldron
Copy link
Contributor

I've rebased this locally and confirmed that linting passes:

rwaldron in ~/clonez/test262 on refactor-for-parsers-directive
$ ./tools/lint/lint.py --whitelist lint.whitelist test/language/directive-prologue/
Linting 62 files
Linting complete. 0 errors found.

@rwaldron
Copy link
Contributor

rwaldron commented Jul 13, 2018

Merged locally, pushed to master. Thanks!

@rwaldron rwaldron closed this Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants