mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-125237 (Misordered 'assertEquals()' arguments: support non-primitives)
This commit is contained in:
+11
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -185,7 +185,16 @@ public abstract class MisorderedAssertEqualsArgumentsInspectionBase extends Base
|
||||
return;
|
||||
}
|
||||
if (ExpressionUtils.computeConstantExpression(actualArgument) == null) {
|
||||
return;
|
||||
if (actualArgument instanceof PsiReferenceExpression) {
|
||||
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)actualArgument;
|
||||
final PsiElement target = referenceExpression.resolve();
|
||||
if (!(target instanceof PsiEnumConstant)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
registerMethodCallError(expression);
|
||||
}
|
||||
|
||||
+9
@@ -1,5 +1,7 @@
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
class Simple {
|
||||
|
||||
public static final int EXPECTED = -9;
|
||||
@@ -10,7 +12,14 @@ class Simple {
|
||||
Assert.<warning descr="Arguments to 'assertEquals()' in wrong order">assertEquals</warning>(s, -1);
|
||||
Assert.<warning descr="Arguments to 'assertSame()' in wrong order">assertSame</warning>(s, EXPECTED);
|
||||
junit.framework.Assert.<warning descr="Arguments to 'failNotEquals()' in wrong order">failNotEquals</warning>("asdfasd", s, EXPECTED);
|
||||
|
||||
TimeUnit timeUnit = TimeUnit.HOURS;
|
||||
Assert.<warning descr="Arguments to 'assertEquals()' in wrong order">assertEquals</warning>(timeUnit, TimeUnit.HOURS);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
enum TimeUnit {
|
||||
HOURS
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ public class MisorderedAssertEqualsParametersInspectionTest extends LightInspect
|
||||
"package org.junit;" +
|
||||
"public class Assert {" +
|
||||
" static public void assertEquals(long expected, long actual) {}" +
|
||||
" static public void assertEquals(Object expected, Object actual){}" +
|
||||
" static public void assertSame(Object expected, Object actual) {}" +
|
||||
"}",
|
||||
"package junit.framework;" +
|
||||
|
||||
Reference in New Issue
Block a user