Package org.python.pydev.editor.autoedit

Examples of org.python.pydev.editor.autoedit.TestIndentPrefs


        expected = "():";
        assertEquals(expected, docCmd.text);
    }

    public void testNoAutoSelf3() {
        TestIndentPrefs testIndentPrefs = new TestIndentPrefs(false, 4, true);
        strategy.setIndentPrefs(testIndentPrefs);
        String doc = null;
        DocCmd docCmd = null;
        String expected = null;
View Full Code Here


        expected = "():";
        assertEquals(expected, docCmd.text);
    }

    public void testNoAutoSelf4() {
        TestIndentPrefs testIndentPrefs = new TestIndentPrefs(false, 4, true);
        strategy.setIndentPrefs(testIndentPrefs);
        String doc = null;
        DocCmd docCmd = null;
        String expected = null;
View Full Code Here

    /**
     * Tests automatically adding/replacing brackets, colons, and parentheses.
     * @see PyAutoIndentStrategy
     */
    public void testAutoPar() {
        strategy.setIndentPrefs(new TestIndentPrefs(false, 4, true));
        String doc = "class c";
        DocCmd docCmd = new DocCmd(doc.length(), 0, "(");
        strategy.customizeDocumentCommand(new Document(doc), docCmd);
        String expected = "():";
        assertEquals(expected, docCmd.text);
View Full Code Here

        assertEquals(expected, docCmd.text);
        assertEquals(-1, docCmd.caretOffset);
    }

    public void testParens() {
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4));
        String str = "isShown() #suite()" +
                "";
        final Document doc = new Document(str);
        DocCmd docCmd = new DocCmd(doc.getLength() - ") #suite()".length(), 0, ")");
        strategy.customizeDocumentCommand(doc, docCmd);
View Full Code Here

        assertEquals(9, docCmd.caretOffset);

    }

    public void testParens2() {
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4));
        String str = "isShown() #suite()'" +
                "";
        final Document doc = new Document(str);
        int offset = doc.getLength() - ") #suite()'".length();
        DocCmd docCmd = new DocCmd(offset, 0, ")");
View Full Code Here

        assertEquals(offset + 1, docCmd.caretOffset);

    }

    public void testParens3() {
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4));
        String str = "assert_('\\\\' in txt) a()";
        final Document doc = new Document(str);
        int offset = doc.getLength() - ")".length();
        DocCmd docCmd = new DocCmd(offset, 0, ")");
        strategy.customizeDocumentCommand(doc, docCmd);
View Full Code Here

        assertEquals(offset + 1, docCmd.caretOffset);
    }

    public void testElse() {
        //first part of test - simple case
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        String strDoc = "if foo:\n" +
                "    print a\n" +
                "    else";
        int initialOffset = strDoc.length();
        DocCmd docCmd = new DocCmd(initialOffset, 0, ":");
        Document doc = new Document(strDoc);
        strategy.customizeDocumentCommand(doc, docCmd);
        String expected = ":";
        assertEquals(docCmd.offset, initialOffset - 4);
        assertEquals(expected, docCmd.text);
        assertEquals("if foo:\n" +
                "    print a\n" +
                "else", doc.get());

        //second part of test - should not dedent
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        strDoc = "if foo:\n" +
                "    if somethingElse:" +
                "        print a\n" +
                "    else";
        initialOffset = strDoc.length();
View Full Code Here

                "    else", doc.get());

    }

    public void testElse2() {
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        String strDoc = "" +
                "try:\n" +
                "    print a\n" +
                "except RuntimeError:\n" +
                "    a = 20\n" +
View Full Code Here

    }

    public void testTryExceptDedent() {
        //first part of test - simple case
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        String strDoc = "try:\n" +
                "    print a\n" +
                "    except";
        int initialOffset = strDoc.length();
        DocCmd docCmd = new DocCmd(initialOffset, 0, ":");
        Document doc = new Document(strDoc);
        strategy.customizeDocumentCommand(doc, docCmd);
        String expected = ":";
        assertEquals(docCmd.offset, initialOffset - 4);
        assertEquals(expected, docCmd.text);
        assertEquals("try:\n" +
                "    print a\n" +
                "except", doc.get());

        //second part of test - should also dedent
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        strDoc = "try:\n" +
                "    if somethingElse:" +
                "        print a\n" +
                "    except";
        initialOffset = strDoc.length();
View Full Code Here

    }

    public void testElif() {
        //first part of test - simple case
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        String strDoc = "if foo:\n" +
                "    print a\n" +
                "    elif";
        int initialOffset = strDoc.length();
        DocCmd docCmd = new DocCmd(initialOffset, 0, " ");
        Document doc = new Document(strDoc);
        strategy.customizeDocumentCommand(doc, docCmd);
        String expected = " ";
        assertEquals(docCmd.offset, initialOffset - 4);
        assertEquals(expected, docCmd.text);
        assertEquals("if foo:\n" +
                "    print a\n" +
                "elif", doc.get());

        //second part of test - should not dedent
        strategy.setIndentPrefs(new TestIndentPrefs(true, 4, true));
        strDoc = "if foo:\n" +
                "    if somethingElse:" +
                "        print a\n" +
                "    elif";
        initialOffset = strDoc.length();
View Full Code Here

TOP

Related Classes of org.python.pydev.editor.autoedit.TestIndentPrefs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.