Skip to content

feat: add string object value#61

Merged
summer-ji-eng merged 12 commits intomasterfrom
string-object-value
Jun 23, 2020
Merged

feat: add string object value#61
summer-ji-eng merged 12 commits intomasterfrom
string-object-value

Conversation

@xiaozhenliu-gg5
Copy link
Copy Markdown
Contributor

@xiaozhenliu-gg5 xiaozhenliu-gg5 commented Jun 19, 2020

No description provided.

Comment thread src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java Outdated
Copy link
Copy Markdown
Contributor

@summer-ji-eng summer-ji-eng left a comment

Choose a reason for hiding this comment

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

Should we add a unit test under /test/ast

@xiaozhenliu-gg5
Copy link
Copy Markdown
Contributor Author

The unit test is added in JavaWriterVisitortest file @summer-ji-eng

Copy link
Copy Markdown
Contributor

@miraleung miraleung left a comment

Choose a reason for hiding this comment

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

@summer-ji-eng Since StringObjectValue just holds objects, we're fine without a unit test. However, we should have unit tests for classes that have additional logic (e.g. type-checking). The writer visitor test is not intended as a replacement, and checks only for the serialization logic.

LGTM assuming the nit will be addressed.

Comment thread src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java Outdated
@summer-ji-eng summer-ji-eng merged commit e08cf65 into master Jun 23, 2020
@xiaozhenliu-gg5 xiaozhenliu-gg5 deleted the string-object-value branch June 23, 2020 21:58
/** =============================== EXPRESSIONS =============================== */
@Test
public void writeStringObjectValue() {
StringObjectValue s = StringObjectValue.builder().setValue("\"test\"").build();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should have picked this up in the last review, but here we want to test that the writer visitor actually writes this string. The test here would go into ast/StringObjectValueTest.java. In the general case, the caller wouldn't pass in "\"test\"" unless they wanted to print \"test\".

}

public static StringObjectValue withValue(String value) {
return builder().setValue(value).build();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test case reminded me that we should also handle special and escaped characters, e.g. if someone passes a quote in here, or escaped characters.

VariableExpr variableExpr =
VariableExpr.builder().setVariable(variable).setIsDecl(true).build();

Value value = StringObjectValue.withValue("\"test\"");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the expected behavior below, the caller should be doing withValue("test") IMO.

@miraleung
Copy link
Copy Markdown
Contributor

This needs fixing, let's not merge this yet.

@miraleung
Copy link
Copy Markdown
Contributor

@summer-ji-eng Since StringObjectValue just holds objects, we're fine without a unit test. However, we should have unit tests for classes that have additional logic (e.g. type-checking). The writer visitor test is not intended as a replacement, and checks only for the serialization logic.

LGTM assuming the nit will be addressed.

On second thought, we do need a unit test for handling special characters.

Copy link
Copy Markdown
Contributor

@miraleung miraleung left a comment

Choose a reason for hiding this comment

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

Shouldn't there be a corresponding change for the writer visitor?

@xiaozhenliu-gg5
Copy link
Copy Markdown
Contributor Author

what does corresponding change for writer visitor mean? Thanks, I will resolve the comments in a new PR. @miraleung

suztomo pushed a commit that referenced this pull request Mar 21, 2023
* updated CHANGELOG.md [ci skip]

* updated README.md [ci skip]

* updated versions.txt [ci skip]

* updated pom.xml

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
suztomo pushed a commit that referenced this pull request Mar 21, 2023
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