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: fix order in assertions #2314

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/comment/CommentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ public boolean matches(CtElement element) {
);

try {
assertEquals("doc outdated, please commit doc/code_elements.md", codeElementsDocumentationPage.toString(), IOUtils.toString(new FileReader("doc/code_elements.md")));
assertEquals("doc outdated, please commit doc/code_elements.md", IOUtils.toString(new FileReader("doc/code_elements.md")), codeElementsDocumentationPage.toString());
} finally {
write(codeElementsDocumentationPage.toString(), new FileOutputStream("doc/code_elements.md"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/main/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public void scan(CtElement element) {
CtPath pathRead = new CtPathStringBuilder().fromString(pathStr);
Collection<CtElement> returnedElements = pathRead.evaluateOn(rootPackage);
//contract: CtUniqueRolePathElement.evaluateOn() returns a unique elements if provided only a list of one inputs
assertEquals(returnedElements.size(), 1);
assertEquals(1, returnedElements.size());
CtElement actualElement = (CtElement) returnedElements.toArray()[0];
//contract: Element -> Path -> String -> Path -> Element leads to the original element
assertSame(element, actualElement);
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/spoon/test/path/PathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ public void testMultiPathFromString() {
// When role match a list but no index is provided, all of them must be returned
Collection<CtElement> results = new CtPathStringBuilder().fromString(".spoon.test.path.testclasses.Foo.foo#body#statement")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 3);
assertEquals(3, results.size());
// When role match a set but no name is provided, all of them must be returned
results = new CtPathStringBuilder().fromString("#subPackage")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 1);
assertEquals(1, results.size());
// When role match a map but no key is provided, all of them must be returned
results = new CtPathStringBuilder().fromString(".spoon.test.path.testclasses.Foo.bar##annotation[index=0]#value")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 1);
assertEquals(1, results.size());

}

Expand All @@ -125,19 +125,19 @@ public void testIncorrectPathFromString() {
// match the else part of the if in Foo.bar() method which does not exist (Test non existing unique element)
Collection<CtElement> results = new CtPathStringBuilder().fromString(".spoon.test.path.testclasses.Foo.bar#body#statement[index=2]#else")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 0);
assertEquals(0, results.size());
// match the third statement of Foo.foo() method which does not exist (Test non existing element of a list)
results = new CtPathStringBuilder().fromString(".spoon.test.path.testclasses.Foo.foo#body#statement[index=3]")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 0);
assertEquals(0, results.size());
// match an non existing package (Test non existing element of a set)
results = new CtPathStringBuilder().fromString("#subPackage[name=nonExistingPackage]")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 0);
assertEquals(0, results.size());
//match a non existing field of an annotation (Test non existing element of a map)
results = new CtPathStringBuilder().fromString(".spoon.test.path.testclasses.Foo.bar##annotation[index=0]#value[key=misspelled]")
.evaluateOn(factory.getModel().getRootPackage());
assertEquals(results.size(), 0);
assertEquals(0, results.size());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/properties/PropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void testNonExistingDirectory() throws Exception {
compiler.build();

compiler.instantiateAndProcess(Arrays.asList(SimpleProcessor.class.getName()));
assertEquals(factory.getEnvironment().getErrorCount(), 0);
assertEquals(0, factory.getEnvironment().getErrorCount());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void testOneReferenceWithGenericMethodOutOfTheClass() {
CtExecutable execRefsMethods2 = refsMethodA.get(0).getDeclaration();
//T has more information in the invocation than its declaration because of the argument type
// assertEquals(expectedMethod1, refsMethodA.get(0).getDeclaration());
assertEquals(execRefsMethods2.getSignature(), "method1(T extends java.lang.String)");
assertEquals("method1(T extends java.lang.String)", execRefsMethods2.getSignature());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/spoon/test/reference/TypeReferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public void testNullReferenceSubtype() {
public void unboxTest() {
Factory factory = new Launcher().createFactory();
CtTypeReference<Boolean> boxedBoolean = factory.Class().createReference(Boolean.class);
assertEquals(boxedBoolean.unbox().getActualClass(), boolean.class);
assertEquals(boolean.class, boxedBoolean.unbox().getActualClass());
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/spoon/test/reference/VariableAccessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ public <T> void visitCtLocalVariableReference(
final CtLocalVariableReference<T> reference) {
assertNotNull(reference.getDeclaration());
final CtLocalVariable decl = reference.getDeclaration();
assertEquals(decl.getPosition().getLine(), 7);
assertEquals(7, decl.getPosition().getLine());
assertTrue(decl.getDefaultExpression() instanceof CtLiteral);
final CtLiteral literal = (CtLiteral) decl.getDefaultExpression();
assertEquals(literal.getValue(), 42);
assertEquals(42, literal.getValue());
super.visitCtLocalVariableReference(reference);
}
}
Expand Down