Skip to content

Runtime behavior tests #135

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 3 commits into from
Jan 26, 2018
Merged

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jan 25, 2018

This doesn't quite add behavior tests to the runtime parser because the runtime parser doesn't produce the same errors as the tooling one. What we can do, however, is parse all fixtures in fluent-syntax and check if the runtime parser parsed the same messages (check if keys are present) and if so, if their interface is the same (is value present or missing? which attributes are defined?).

@stasm stasm force-pushed the runtime-behavior-tests branch from a51498e to 2e64d46 Compare January 25, 2018 16:42
@@ -24,11 +24,13 @@ ifneq (,$(wildcard ./test/__setup.js))
@mocha --recursive --ui tdd \
--require babel-register \
--require babel-polyfill \
--require ./test/__setup
--require ./test/__setup \
test/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was getting some strange unknown option --recursive errors from mocha without this.

val += ch;
}

if (ps.currentIs('\n')) {
throw new ParseError('E0020');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I submitted projectfluent/fluent#83 to reflect this change in the spec.

while (this._index < this._length) {
this.skipInlineWS();

if (this._source[this._index] === ')') {
return args;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving this here allows the last argument to be followed by a comma. I filed projectfluent/fluent#84 to allow this in the spec.

const [entries] = parse(source);
const expectedEntries = JSON.parse(json);

for (const [id, expected] of Object.entries(expectedEntries)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Iterating over expectedEntries here means that the runtime parser could possibly parse more entries and we wouldn't learn about it from these tests. I'd like to fix this in a follow-up later on.

test(ftlfilename, function() {
return Promise.all(
test(ftlfilename, async function() {
const [ftl, expected] = await Promise.all(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No functional changes here; just switching to async.

@stasm stasm requested a review from zbraniecki January 25, 2018 16:43
@stasm
Copy link
Contributor Author

stasm commented Jan 25, 2018

This is PR consists of 3 commits: the first one adds the tests and the other two fix the differences in parsing between the runtime and the tooling parser.

Copy link
Collaborator

@zbraniecki zbraniecki left a comment

Choose a reason for hiding this comment

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

This looks awesome! So happy to see the coverage for the runtime parser! :)

@stasm stasm merged commit 5e12a17 into projectfluent:master Jan 26, 2018
@stasm stasm deleted the runtime-behavior-tests branch January 26, 2018 08:35
stasm added a commit to projectfluent/python-fluent that referenced this pull request Jan 29, 2018
Partial port of projectfluent/fluent.js#135 affecting
the tooling parser.
eemeli pushed a commit to mozilla/fluent-migrate that referenced this pull request May 16, 2023
Partial port of projectfluent/fluent.js#135 affecting
the tooling parser.
jfx2006 pushed a commit to jfx2006/tb-fluent-migrate that referenced this pull request Jul 27, 2023
Partial port of projectfluent/fluent.js#135 affecting
the tooling parser.
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.

2 participants