Search in sources :

Example 1 with LeonidasTipper

use of il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper in project Main by SpartanRefactoring.

the class BooleanLiteralTest method testTipper.

public void testTipper() throws Exception {
    File f = new File(Resources.getResource("BooleanLiteralTestTip.java").getPath());
    LeonidasTipper lt = new LeonidasTipper("BooleanLiteralTestTip.java", IOUtils.toString(new BufferedReader(new InputStreamReader(new FileInputStream(f)))));
    PsiWhileStatement pws1 = createTestWhileStatementFromString("while (true) {\nx++;\n}");
    assertTrue(lt.canTip(pws1));
    PsiWhileStatement pws2 = createTestWhileStatementFromString("while (false) {\nx++;\n}");
    assertTrue(lt.canTip(pws2));
    PsiWhileStatement pws3 = createTestWhileStatementFromString("while (x > 2) {\nx++;\n}");
    assertFalse(lt.canTip(pws3));
    PsiWhileStatement pws4 = createTestWhileStatementFromString("while (true) {\nx++; x--;\n}");
    assertFalse(lt.canTip(pws4));
}
Also used : InputStreamReader(java.io.InputStreamReader) LeonidasTipper(il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper) BufferedReader(java.io.BufferedReader) PsiWhileStatement(com.intellij.psi.PsiWhileStatement) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 2 with LeonidasTipper

use of il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper in project Main by SpartanRefactoring.

the class OptionalTest method testTip1.

public void testTip1() throws Exception {
    File f = new File(Resources.getResource("OptionalTestTipper1.java").getPath());
    LeonidasTipper lt = new LeonidasTipper("OptionalTestTipper1", IOUtils.toString(new BufferedReader(new InputStreamReader(new FileInputStream(f)))));
    PsiWhileStatement pws1 = createTestWhileStatementFromString("while (x > 2) {\nx++; y--; x--;  \n}");
    assertTrue(lt.canTip(pws1));
    PsiWhileStatement pws2 = createTestWhileStatementFromString("while (x > 2) {\nx++; x--;  \n}");
    assertTrue(lt.canTip(pws2));
    PsiWhileStatement pws3 = createTestWhileStatementFromString("while (x > 2) {\nx++;\n}");
    assertFalse(lt.canTip(pws3));
    PsiWhileStatement pws4 = createTestWhileStatementFromString("while (x > 2) {\nx++; x--; x--;  \n}");
    assertTrue(lt.canTip(pws4));
    PsiWhileStatement pws5 = createTestWhileStatementFromString("while (x > 2) {\nx++; x++; x--;  \n}");
    assertTrue(lt.canTip(pws5));
}
Also used : InputStreamReader(java.io.InputStreamReader) LeonidasTipper(il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper) BufferedReader(java.io.BufferedReader) PsiWhileStatement(com.intellij.psi.PsiWhileStatement) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with LeonidasTipper

use of il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper in project Main by SpartanRefactoring.

the class AnyNumberOfTest method testTipper.

public void testTipper() throws Exception {
    File f = new File(Resources.getResource("AnyNumberOfTipperTest.java").getPath());
    LeonidasTipper lt = new LeonidasTipper("AnyNumberOfTipperTest", IOUtils.toString(new BufferedReader(new InputStreamReader(new FileInputStream(f)))));
    PsiWhileStatement pws1 = createTestWhileStatementFromString("while (x > 2) {\nx++; y--; x--;  \n}");
    assertTrue(lt.canTip(pws1));
    PsiWhileStatement pws2 = createTestWhileStatementFromString("while (x > 2) {\nx++; x--;  \n}");
    assertTrue(lt.canTip(pws2));
    PsiWhileStatement pws3 = createTestWhileStatementFromString("while (x > 2) {\nx++;\n}");
    assertFalse(lt.canTip(pws3));
    PsiWhileStatement pws4 = createTestWhileStatementFromString("while (x > 2) {\nx++; x--; x--;  \n}");
    assertTrue(lt.canTip(pws4));
    PsiWhileStatement pws5 = createTestWhileStatementFromString("while (x > 2) {\nx++; x++; x--;  \n}");
    assertTrue(lt.canTip(pws5));
    PsiWhileStatement pws6 = createTestWhileStatementFromString("while (x > 2) {\nx++; y--; y++; x--;  \n}");
    assertTrue(lt.canTip(pws6));
}
Also used : InputStreamReader(java.io.InputStreamReader) LeonidasTipper(il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper) BufferedReader(java.io.BufferedReader) PsiWhileStatement(com.intellij.psi.PsiWhileStatement) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

PsiWhileStatement (com.intellij.psi.PsiWhileStatement)3 LeonidasTipper (il.org.spartan.Leonidas.plugin.tippers.LeonidasTipper)3 BufferedReader (java.io.BufferedReader)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 InputStreamReader (java.io.InputStreamReader)3