Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#470 fix #473

Closed
wants to merge 1 commit into from
Closed

#470 fix #473

wants to merge 1 commit into from

Conversation

diberry
Copy link
Contributor

@diberry diberry commented Mar 10, 2019

No description provided.

Copy link
Member

@puzrin puzrin left a comment

Choose a reason for hiding this comment

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

See comments


assert.strictEqual(actual, expected);
});
test('should not unnecessaryly apply quotes - ', function () {
Copy link
Member

Choose a reason for hiding this comment

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

This test looks like previous, with no difference.

assert.strictEqual(actual, expected);
});

test('should not unnecessaryly apply quotes - space then /\n at end of value', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Don't see difference with first test


assert.strictEqual(actual, expected);
});
test('should not unnecessaryly apply quotes - space after colon', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Don't see difference with first test

}
);

assert.strictEqual(actual, expected);
Copy link
Member

Choose a reason for hiding this comment

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

That's not enougth. Need to check that after load back result will be exact as initial

plain = plain && isPlainSafe(char);
if (!isPlainSafe(char)) {
plain = plain && !isWhitespace(string.charCodeAt(i + 1));
}
Copy link
Member

Choose a reason for hiding this comment

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

This is a very cryptic way to express "if plainsafe and next is not whitespace". Very deficult to understand real intent. Please, reorganize somehow.

@@ -272,7 +265,7 @@ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, te
if (!isPrintable(char)) {
return STYLE_DOUBLE;
}
plain = plain && isPlainSafe(char);
plain = plain && (isPlainSafe(char) && !isWhitespace(string.charCodeAt(i + 1)));
Copy link
Member

@puzrin puzrin Mar 10, 2019

Choose a reason for hiding this comment

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

isWhitespace(string.charCodeAt(i + 1)) - missed length check, to avoid out of bounds access at [i + 1]. Such thing will trash JIT optimisations.

Copy link
Member

Choose a reason for hiding this comment

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

Should it check next or prev char?

{ test: 'C #123' } - make sure this will be quoted.

// - ":" - "#"
&& c !== CHAR_COLON
&& c !== CHAR_SHARP;
&& c !== CHAR_COLON;
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to cover this change with tests. For example, check dumping (and load back) of this strings:

C#, C#123, C #123, C# 123

@GerHobbelt
Copy link

https://github.com/diberry/js-yaml/pull/1 should answer many of the comments above. That pullreq introduces round-trip tests and has more tests.

@puzrin
Copy link
Member

puzrin commented Apr 15, 2019

@GerHobbelt i think it's better to make your PR as independent, and to this repo. Then we can discuss details.

@puzrin
Copy link
Member

puzrin commented Apr 16, 2019

Close as incomplete/invalid.

As been noted in #484 (comment), this will break flow style of dump.

@puzrin puzrin closed this Apr 16, 2019
GerHobbelt added a commit to GerHobbelt/js-yaml that referenced this pull request Apr 16, 2019
…e rendered output is ambiguous and hence erroneous YAML.
GerHobbelt added a commit to GerHobbelt/js-yaml that referenced this pull request Apr 16, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants