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

test: Adds a test case to compile snippets several times. #362

Merged
merged 1 commit into from
Oct 8, 2015
Merged

test: Adds a test case to compile snippets several times. #362

merged 1 commit into from
Oct 8, 2015

Conversation

GerardPaligot
Copy link
Contributor

Closes #304

assertTrue(secondCompile instanceof CtBinaryOperator);

// Compile a third time a snippet but different.
final CtCodeSnippetExpression<Object> snippet2 = factory.Code().createCodeSnippetExpression("2 < 1");
Copy link
Collaborator

Choose a reason for hiding this comment

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

call snippet.setExpression instead of a fresh object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean something like this?

final CtCodeSnippetExpression<Object> snippet3 = factory.Core().createCodeSnippetExpression();
snippet3.setValue("1 > 3");
final CtExpression<Object> compile1 = snippet3.compile();
final CtExpression<Object> compile2 = snippet3.compile();

assertTrue(compile1 instanceof CtBinaryOperator);
assertTrue(compile2 instanceof CtBinaryOperator);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Something like:

final CtCodeSnippetExpression snippet =
factory.Code().createCodeSnippetExpression("1 > 2");
final CtExpression compile1 = snippet3.compile();
final CtExpression compile2 = snippet3.compile();
assertEquals("1>2", compile1.toString());
...
snippet3.setValue("1 > 3");
final CtExpression compile3 = snippet3.compile();
final CtExpression compile4 = snippet3.compile();
assertEquals("1>3", compile3.toString());
....

@GerardPaligot
Copy link
Contributor Author

@monperrus Everything seems good here.

@@ -38,4 +41,31 @@ public void testSnippetWihErrors() {
}
}

@Test
public void testCompileSnippetSeveralTimes() throws Exception {
final Factory factory = TestUtils.createFactory();
Copy link
Collaborator

Choose a reason for hiding this comment

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

contract: a snippet object can be reused several times

@GerardPaligot
Copy link
Contributor Author

@monperrus Travis ok.

monperrus added a commit that referenced this pull request Oct 8, 2015
@monperrus monperrus merged commit f7dbd93 into INRIA:master Oct 8, 2015
@GerardPaligot GerardPaligot deleted the fix_304 branch October 8, 2015 12:03
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