take absolute value of a remainder, not a remainder of an absolute value

`Math.abs(INT_MIN) == INT_MIN`
as a result, `Math.abs(x) % 10` might return negative value.
This commit is contained in:
Aleksey Pivovarov
2017-04-24 18:56:20 +03:00
parent 21572903ae
commit f5d308a28c
6 changed files with 13 additions and 5 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.codeInsight.daemon;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NotNull;
@@ -76,6 +77,10 @@ public class LightRainbowHighlightingTest extends LightCodeInsightFixtureTestCas
"}", true, true);
}
public void testBadStringHashValue() {
int color = UsedColors.getOrAddColorIndex(new UserDataHolderBase(), "JHZaWC", 5);
assertEquals(3, color);
}
void checkRainbow(@NotNull String code, boolean isRainbowOn, boolean withColor) throws Exception {
myFixture.testRainbow(