コード例 #1
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_namespace():
    code = '''namespace A {

void f(int *a)
{
    g(a * b);
}

}'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''namespace A
    {
    class B;
    }'''
    out = reformat.reformat(code)
    assert out == code
    expected = '''namespace A
{
class B;
}'''
    out = reformat.reformat(code, set_indent=True)
    assert out == expected
コード例 #2
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_unary_minus_operator():
    out = reformat.reformat('(-a-b)')
    assert out == '(-a - b)'
    out = reformat.reformat('(a+ -b)')
    assert out == '(a + -b)'
    out = reformat.reformat('return -1;')
    assert out == 'return -1;'
コード例 #3
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_brackets():
    out = reformat.reformat('( a )')
    assert out == '(a)'
    out = reformat.reformat('(   a )')
    assert out == '(a)'
    out = reformat.reformat('(   "a" )')
    assert out == '("a")'
コード例 #4
0
ファイル: __init__.py プロジェクト: ryanakca/frescobaldi
    def postImport(self, settings, doc):
        """Adaptations of the source after running musicxml2ly
		
		Present settings: 
		Reformat source
        Remove superfluous durations
        Remove duration scaling
        Engrave directly
		
        """
        cursor = QTextCursor(doc)
        if settings[0]:
            import reformat

            reformat.reformat(cursor)
        if settings[1]:
            cursor.select(QTextCursor.Document)
            from rhythm import rhythm

            rhythm.rhythm_implicit_per_line(cursor)
        if settings[2]:
            cursor.select(QTextCursor.Document)
            from rhythm import rhythm

            rhythm.rhythm_remove_fraction_scaling(cursor)
        if settings[3]:
            import engrave

            engrave.engraver(self.mainwindow()).engrave("preview", doc, False)
コード例 #5
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_increment_operator():
    out = reformat.reformat('a++ - b')
    assert out == 'a++ - b'
    out = reformat.reformat('a++-b')
    assert out == 'a++ - b'
    out = reformat.reformat('a++*b')
    assert out == 'a++ * b'
コード例 #6
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_unary_plus_operator():
    out = reformat.reformat('(+a-b)')
    assert out == '(+a - b)'
    out = reformat.reformat('(a- +b)')
    assert out == '(a - +b)'
    out = reformat.reformat('return +1;')
    assert out == 'return +1;'
コード例 #7
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_curly_bracket_alignment():
    code = '''
    if (a)
    {
        if (a < b < c)c;
        }

        if (e)
        {
            e;
        }'''

    expected = '''
    if (a)
    {
        if (a < b < c) c;
    }

    if (e)
    {
        e;
    }'''
    out = reformat.reformat(code, 1)
    assert out == code.replace(')c', ') c')
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == expected
コード例 #8
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_curly_bracket_alignment():
    code = '''
    if (a)
    {
        if (a < b < c)c;
        }

        if (e)
        {
            e;
        }'''

    expected = '''
    if (a)
    {
        if (a < b < c) c;
    }

    if (e)
    {
        e;
    }'''
    out = reformat.reformat(code, 1)
    assert out == code.replace(')c', ') c')
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == expected
コード例 #9
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_increment_operator():
    out = reformat.reformat('a++ - b')
    assert out == 'a++ - b'
    out = reformat.reformat('a++-b')
    assert out == 'a++ - b'
    out = reformat.reformat('a++*b')
    assert out == 'a++ * b'
コード例 #10
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_unary_plus_operator():
    out = reformat.reformat('(+a-b)')
    assert out == '(+a - b)'
    out = reformat.reformat('(a- +b)')
    assert out == '(a - +b)'
    out = reformat.reformat('return +1;')
    assert out == 'return +1;'
コード例 #11
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_namespace():
    code = '''namespace A {

void f(int *a)
{
    g(a * b);
}

}'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''namespace A
    {
    class B;
    }'''
    out = reformat.reformat(code)
    assert out == code
    expected = '''namespace A
{
class B;
}'''
    out = reformat.reformat(code, set_indent=True)
    assert out == expected
コード例 #12
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_unary_minus_operator():
    out = reformat.reformat('(-a-b)')
    assert out == '(-a - b)'
    out = reformat.reformat('(a+ -b)')
    assert out == '(a + -b)'
    out = reformat.reformat('return -1;')
    assert out == 'return -1;'
コード例 #13
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_brackets():
    out = reformat.reformat('( a )')
    assert out == '(a)'
    out = reformat.reformat('(   a )')
    assert out == '(a)'
    out = reformat.reformat('(   "a" )')
    assert out == '("a")'
コード例 #14
0
ファイル: __init__.py プロジェクト: ryanakca/frescobaldi
    def postImport(self, settings, doc):
        """Adaptations of the source after running musicxml2ly
		
		Present settings: 
		Reformat source
        Remove superfluous durations
        Remove duration scaling
        Engrave directly
		
        """
        cursor = QTextCursor(doc)
        if settings[0]:
            import reformat
            reformat.reformat(cursor)
        if settings[1]:
            cursor.select(QTextCursor.Document)
            from rhythm import rhythm
            rhythm.rhythm_implicit_per_line(cursor)
        if settings[2]:
            cursor.select(QTextCursor.Document)
            from rhythm import rhythm
            rhythm.rhythm_remove_fraction_scaling(cursor)
        if settings[3]:
            import engrave
            engrave.engraver(self.mainwindow()).engrave('preview', doc, False)
コード例 #15
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_for_statement():
    out = reformat.reformat('for(int i=0;i<c;++i) a;')
    assert out == 'for (int i = 0; i < c; ++i) a;'
    out = reformat.reformat('for(int i=0;i<c;++i)')
    assert out == 'for (int i = 0; i < c; ++i)'
    out = reformat.reformat('for ( int i = 0 ; i < c ; ++i ) ')
    assert out == 'for (int i = 0; i < c; ++i)'
    out = reformat.reformat('for ( int i = 0 ; i < a->c ; ++i ) ')
    assert out == 'for (int i = 0; i < a->c; ++i)'
    code = '''for (int i = 0; i < c; ++i)
{
    f();
}
a = g();'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''for (int i = 0; i < c; ++i)
    f();
a = g();'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''for (int i = 0; i < c; ++i) f();
a = g();'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True, extra_newlines=True)
    assert out == code
コード例 #16
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_default_values():
    code = '''f(int a = 2,
  int *b = NULL);'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #17
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_if_statement():
    out = reformat.reformat('if (a != b) c;')
    assert out == 'if (a != b) c;'
    out = reformat.reformat('if (a) * b = c;', 1)
    assert out == 'if (a) *b = c;'
    out = reformat.reformat('if (a < 0 || b > 0) *b = c;', 1)
    assert out == 'if (a < 0 || b > 0) *b = c;'
コード例 #18
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_exponent():
    out = reformat.reformat('1e-5')
    assert out == '1e-5'
    out = reformat.reformat('1.0e-5')
    assert out == '1.0e-5'
    out = reformat.reformat('3.5e+5')
    assert out == '3.5e+5'
コード例 #19
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_exponent():
    out = reformat.reformat('1e-5')
    assert out == '1e-5'
    out = reformat.reformat('1.0e-5')
    assert out == '1.0e-5'
    out = reformat.reformat('3.5e+5')
    assert out == '3.5e+5'
コード例 #20
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_default_values():
    code = '''f(int a = 2,
  int *b = NULL);'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #21
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_comments():
    code = '''// aaa
a &f(b);'''
    out = reformat.reformat(code)
    assert out == code
    code = '    // aaa:'
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
コード例 #22
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_nested_template_arguments():
    out = reformat.reformat('a<b<c> > = d')
    assert out == 'a<b<c> > = d'
    out = reformat.reformat('a<b<c> > = d', set_indent=True)
    assert out == 'a<b<c> > = d'
    out = reformat.reformat('a<b<c> > d')
    assert out == 'a<b<c> > d'
    out = reformat.reformat('a<b<c> > d', set_indent=True)
    assert out == 'a<b<c> > d'
コード例 #23
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_template_arguments():
    out = reformat.reformat('a<b> = c')
    assert out == 'a<b> = c'
    out = reformat.reformat('a<b *> = c')
    assert out == 'a<b *> = c'
    out = reformat.reformat('a<b &> = c')
    assert out == 'a<b &> = c'
    out = reformat.reformat('a<const b> = c')
    assert out == 'a<const b> = c'
コード例 #24
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_return_statement():
    out = reformat.reformat('return a;')
    assert out == 'return a;'
    out = reformat.reformat('return(a);')
    assert out == 'return (a);'
    out = reformat.reformat('int f() { return 1; }',
                            set_indent=True,
                            extra_newlines=True)
    assert out == '''int f()
コード例 #25
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_ternary_operator():
    out = reformat.reformat('a?b:c;')
    assert out == 'a ? b : c;'
    out = reformat.reformat('a=1?2:3;')
    assert out == 'a = 1 ? 2 : 3;'
    out = reformat.reformat('a=1 ? 2 : 3;')
    assert out == 'a = 1 ? 2 : 3;'
    out = reformat.reformat('a ? "a" : "b"')
    assert out == 'a ? "a" : "b"'
コード例 #26
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_nested_template_arguments():
    out = reformat.reformat('a<b<c> > = d')
    assert out == 'a<b<c> > = d'
    out = reformat.reformat('a<b<c> > = d', set_indent=True)
    assert out == 'a<b<c> > = d'
    out = reformat.reformat('a<b<c> > d')
    assert out == 'a<b<c> > d'
    out = reformat.reformat('a<b<c> > d', set_indent=True)
    assert out == 'a<b<c> > d'
コード例 #27
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_ternary_operator():
    out = reformat.reformat('a?b:c;')
    assert out == 'a ? b : c;'
    out = reformat.reformat('a=1?2:3;')
    assert out == 'a = 1 ? 2 : 3;'
    out = reformat.reformat('a=1 ? 2 : 3;')
    assert out == 'a = 1 ? 2 : 3;'
    out = reformat.reformat('a ? "a" : "b"')
    assert out == 'a ? "a" : "b"'
コード例 #28
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_multiline_comments():
    code = '''/*
   s*v)23a87+v"asd{"
*/'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
コード例 #29
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_multiline_comments():
    code = '''/*
   s*v)23a87+v"asd{"
*/'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
コード例 #30
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_template_arguments():
    out = reformat.reformat('a<b> = c')
    assert out == 'a<b> = c'
    out = reformat.reformat('a<b *> = c')
    assert out == 'a<b *> = c'
    out = reformat.reformat('a<b &> = c')
    assert out == 'a<b &> = c'
    out = reformat.reformat('a = dynamic_cast<const b &>(c);')
    assert out == 'a = dynamic_cast<const b &>(c);'
    out = reformat.reformat('a<const b> = c')
    assert out == 'a<const b> = c'
コード例 #31
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_comments():
    code = '''// aaa
a &f(b);'''
    out = reformat.reformat(code)
    assert out == code
    code = '    // aaa:'
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
    code = 'a; // comment'
    out = reformat.reformat(code, extra_newlines=True)
    assert out == code
コード例 #32
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_inheritance():
    code = '''class A : public B,
    public C
{
public:
    A f(int const &a, int const &b);
};'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #33
0
ファイル: defineoffset.py プロジェクト: zsalch/frescobaldi
 def insertOverride(self, x, y):
     """ Insert the override command. """
     doc = lydocument.Document(self.doc)
     block = doc.block(self.pos)
     p = block.position()
     cursor = QtGui.QTextCursor(self.doc)
     cursor.setPosition(p)
     cursor.beginEditBlock()
     cursor.insertText(self.createOffsetOverride(x, y))
     cursor.insertBlock()
     cursor.endEditBlock()
     reformat.reformat(cursor)
コード例 #34
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_inheritance():
    code = '''class A : public B,
    public C,
    public D
{
public:
    A f(int const &a, int const &b);
};'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #35
0
ファイル: defineoffset.py プロジェクト: AlexSchr/frescobaldi
 def insertOverride(self, x, y):
     """ Insert the override command. """
     doc = lydocument.Document(self.doc)
     block = doc.block(self.pos)
     p = block.position()
     cursor = QtGui.QTextCursor(self.doc)
     cursor.setPosition(p)
     cursor.beginEditBlock()
     cursor.insertText(self.createOffsetOverride(x, y))
     cursor.insertBlock()
     cursor.endEditBlock()
     reformat.reformat(cursor)
コード例 #36
0
    def __init__(self,MSname,Col="DATA",zero_flag=True,ReOrder=False,EqualizeFlag=False,DoPrint=True,DoReadData=True,
                 TimeChunkSize=None,GetBeam=False,RejectAutoCorr=False,SelectSPW=None,DelStationList=None):


        if MSname=="": exit()
        MSname=reformat.reformat(os.path.abspath(MSname),LastSlash=False)
        self.MSName=MSname
        self.ColName=Col
        self.zero_flag=zero_flag
        self.ReOrder=ReOrder
        self.EqualizeFlag=EqualizeFlag
        self.DoPrint=DoPrint
        self.TimeChunkSize=TimeChunkSize
        self.RejectAutoCorr=RejectAutoCorr
        self.SelectSPW=SelectSPW
        self.DelStationList=DelStationList
        self.ReadMSInfo(MSname,DoPrint=DoPrint)
        self.LFlaggedStations=[]
        try:
            self.LoadLOFAR_ANTENNA_FIELD()
        except:
            self.LOFAR_ANTENNA_FIELD=None
            pass

        #self.LoadLOFAR_ANTENNA_FIELD()

        if DoReadData: self.ReadData()
        #self.RemoveStation()


        self.SR=None
        if GetBeam:
            self.LoadSR()
コード例 #37
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_pointers_that_are_not_pointers():
    '''This is something that also doesn't work in astyle'''
    code = '''int a = 1;
int b = 2;
int c(a * b);'''
    out = reformat.reformat(code)
    assert out == code
コード例 #38
0
    def __init__(self,
                 MSname,
                 Col="DATA",
                 zero_flag=True,
                 ReOrder=False,
                 EqualizeFlag=False,
                 DoPrint=True,
                 DoReadData=True,
                 TimeChunkSize=None,
                 GetBeam=False,
                 RejectAutoCorr=False,
                 SelectSPW=None,
                 DelStationList=None):

        if MSname == "": exit()
        MSname = reformat.reformat(MSname, LastSlash=False)
        self.MSName = MSname
        self.ColName = Col
        self.zero_flag = zero_flag
        self.ReOrder = ReOrder
        self.EqualizeFlag = EqualizeFlag
        self.DoPrint = DoPrint
        self.TimeChunkSize = TimeChunkSize
        self.RejectAutoCorr = RejectAutoCorr
        self.SelectSPW = SelectSPW
        self.DelStationList = DelStationList
        self.ReadMSInfo(MSname, DoPrint=DoPrint)

        if DoReadData: self.ReadData()
        #self.RemoveStation()

        self.SR = None
        if GetBeam:
            self.LoadSR()
コード例 #39
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_pointers_that_are_not_pointers():
    '''This is something that also doesn't work in astyle'''
    code = '''int a = 1;
int b = 2;
int c(a * b);'''
    out = reformat.reformat(code)
    assert out == code
コード例 #40
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_classes():
    out = reformat.reformat('class A { int *f(int *a);};')
    assert out == 'class A {int *f(int *a); };'
    out = reformat.reformat('class A; void f(a*b);')
    assert out == 'class A; void f(a *b);'
    out = reformat.reformat('class A; {f(a*b);}')
    assert out == 'class A; {f(a * b); }'
    code = '''class A
{
public:
    A();
}'''
    out = reformat.reformat(code)
    assert out == code
    code = '''namespace N {
class A
{
public:
    A f(int const &a, int const &b);
};

}'''
    out = reformat.reformat(code)
    assert out == code
    code = '''class A
{
public:
    A f(int const &a, int const &b);
    B f(int const &a, int const &b);
};'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #41
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_classes():
    out = reformat.reformat('class A { int *f(int *a);};')
    assert out == 'class A {int *f(int *a); };'
    out = reformat.reformat('class A; void f(a*b);')
    assert out == 'class A; void f(a *b);'
    out = reformat.reformat('class A; {f(a*b);}')
    assert out == 'class A; {f(a * b); }'
    code = '''class A
{
public:
    A();
}'''
    out = reformat.reformat(code)
    assert out == code
    code = '''namespace N {
class A
{
public:
    A f(int const &a, int const &b);
};

}'''
    out = reformat.reformat(code)
    assert out == code
    code = '''class A
{
public:
    A f(int const &a, int const &b);
    B f(int const &a, int const &b);
};'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #42
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_extra_newlines():
    code = '''a f(a b, c d) {b; d;}'''
    out = reformat.reformat(code, set_indent=True, extra_newlines=True)
    expected = '''a f(a b, c d)
{
    b;
    d;
}'''
    assert out == expected
コード例 #43
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_extra_newlines():
    code = '''a f(a b, c d) {b; d;}'''
    out = reformat.reformat(code, set_indent=True,
                            extra_newlines=True)
    expected = '''a f(a b, c d)
{
    b;
    d;
}'''
    assert out == expected
コード例 #44
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_initializer_lists():
    code = '''A::A(int &a, int &b)
:
    a_(a * b)
{}'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code

    code = '''A::A(int &a, int &b)
:
    a_(a * b),
    b_(a * b)
{
    f(a);
}'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #45
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_initializer_lists():
    code = '''A::A(int &a, int &b)
:
    a_(a * b)
{}'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code

    code = '''A::A(int &a, int &b)
:
    a_(a * b),
    b_(a * b)
{
    f(a);
}'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #46
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_bitshift_operator():
    out = reformat.reformat('a>>b')
    assert out == 'a >> b'
    out = reformat.reformat('a<<b')
    assert out == 'a << b'
    code = '''std::cout << "test" <<
    "test 2" << "test 3" <<
    "test 4" << std::endl;'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''std::cout << "test"
          << f("test 2") << "test 3"
          << "test 4" << std::endl;'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''std::cout<<"test"
<<f("test 2")<<"test 3";
out2<<"test"
<<f("test 2")<<"test 3";'''
    code2 = '''std::cout << "test"
          << f("test 2") << "test 3";
out2 << "test"
     << f("test 2") << "test 3";'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code2
    code = '''
std::cout << std::endl << "test" << std::endl;
std::cout << "test" << "test"
          << "test" << "test"
          << std::endl;'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #47
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_nested_for():
    code = '''for (int i = 0; i < c; ++i)
    for (int j = 0; j < c; ++j)
    {
        f();
    }
a = g();'''
    out = reformat.reformat(code, set_indent=True)
    code = '''for (int i = 0; i < c; ++i)
{
    for (int j = 0; j < c; ++j)
    {
        f();
    }
}
a = g();'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''for (int i = 0; i < c; ++i)
    for (int j = 0; j < c; ++j)
        f();
a = g();'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''for (int i = 0; i < c; ++i)
    if (b < c)
        f();
a = g();'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
    code = '''for (int i = 0; i < c; ++i)
    for (int j = 0; j < c; ++j)
    {
        f();
    }
a = g();'''
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #48
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_multiplication_operator():
    out = reformat.reformat('a = b * c;', 1)
    assert out == 'a = b * c;'
    out = reformat.reformat('f(a * b);', 1)
    assert out == 'f(a * b);'
    out = reformat.reformat('std::cout<<a*b;')
    assert out == 'std::cout << a * b;'
    out = reformat.reformat('std::cout<<*a;')
    assert out == 'std::cout << *a;'
    out = reformat.reformat('if (a*b)', 1)
    assert out == 'if (a * b)'
    out = reformat.reformat('f((a*b)*c)', 1)
    assert out == 'f((a * b) * c)'
    out = reformat.reformat('f("a", b*c)', 1)
    assert out == 'f("a", b * c)'
    out = reformat.reformat('''f("a",
  b*c)''', 1)
    assert out == '''f("a",
コード例 #49
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_references():
    out = reformat.reformat('void f(int &c)')
    assert out == 'void f(int &c)'
    out = reformat.reformat('A &f(int &c)')
    assert out == 'A &f(int &c)'
    out = reformat.reformat('int &a = f[b];')
    assert out == 'int &a = f[b];'
    out = reformat.reformat('f(&a,&b)', 1)
    assert out == 'f(&a, &b)'
    out = reformat.reformat('f(& a)', 1)
    assert out == 'f(&a)'
    out = reformat.reformat('f(& (a) )', 1)
    assert out == 'f(&(a))'
    out = reformat.reformat('A &f(int &a, int &b)')
    assert out == 'A &f(int &a, int &b)'
    out = reformat.reformat('''A &f(int &a,
     int &b)''')
    assert out == '''A &f(int &a,
コード例 #50
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_multiplication_operator():
    out = reformat.reformat('a = b * c;', 1)
    assert out == 'a = b * c;'
    out = reformat.reformat('f(a * b);', 1)
    assert out == 'f(a * b);'
    out = reformat.reformat('std::cout<<a*b;')
    assert out == 'std::cout << a * b;'
    out = reformat.reformat('std::cout<<*a;')
    assert out == 'std::cout << *a;'
    out = reformat.reformat('if (a*b)', 1)
    assert out == 'if (a * b)'
    out = reformat.reformat('f((a*b)*c)', 1)
    assert out == 'f((a * b) * c)'
    out = reformat.reformat('f("a", b*c)', 1)
    assert out == 'f("a", b * c)'
    out = reformat.reformat('''f("a",
  b*c)''', 1)
    assert out == '''f("a",
コード例 #51
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_references():
    out = reformat.reformat('void f(int &c)')
    assert out == 'void f(int &c)'
    out = reformat.reformat('A &f(int &c)')
    assert out == 'A &f(int &c)'
    out = reformat.reformat('int &a = f[b];')
    assert out == 'int &a = f[b];'
    out = reformat.reformat('f(&a,&b)', 1)
    assert out == 'f(&a, &b)'
    out = reformat.reformat('f(& a)', 1)
    assert out == 'f(&a)'
    out = reformat.reformat('f(& (a) )', 1)
    assert out == 'f(&(a))'
    out = reformat.reformat('A &f(int &a, int &b)')
    assert out == 'A &f(int &a, int &b)'
    out = reformat.reformat('''A &f(int &a,
     int &b)''')
    assert out == '''A &f(int &a,
コード例 #52
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_index():
    out = reformat.reformat('a[i+1];')
    assert out == 'a[i+1];'
    out = reformat.reformat('a[b->idx];')
    assert out == 'a[b->idx];'
    out = reformat.reformat('a[idx(b)];')
    assert out == 'a[idx(b)];'
    out = reformat.reformat('a[idx--];')
    assert out == 'a[idx--];'
    out = reformat.reformat('a[idx++];')
    assert out == 'a[idx++];'
    out = reformat.reformat('a[--idx];')
    assert out == 'a[--idx];'
    out = reformat.reformat('a[++idx];')
    assert out == 'a[++idx];'
コード例 #53
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_and_operator():
    out = reformat.reformat('a = b & c;', 1)
    assert out == 'a = b & c;'
    out = reformat.reformat('f(a & b);', 1)
    assert out == 'f(a & b);'
    out = reformat.reformat('std::cout<<a&b;')
    assert out == 'std::cout << a & b;'
    out = reformat.reformat('if (a&b)', 1)
    assert out == 'if (a & b)'
    out = reformat.reformat('if (a&&b)', 1)
    assert out == 'if (a && b)'
    out = reformat.reformat('if ((a)&&(b))', 1)
    assert out == 'if ((a) && (b))'
コード例 #54
0
ファイル: test_reformat.py プロジェクト: krupalb/reformat.py
def test_or_operator():
    out = reformat.reformat('a = b | c;', 1)
    assert out == 'a = b | c;'
    out = reformat.reformat('f(a | b);', 1)
    assert out == 'f(a | b);'
    out = reformat.reformat('std::cout<<a|b;')
    assert out == 'std::cout << a | b;'
    out = reformat.reformat('if (a|b)', 1)
    assert out == 'if (a | b)'
    out = reformat.reformat('if (a||b)', 1)
    assert out == 'if (a || b)'
    out = reformat.reformat('if ((a)||(b))', 1)
    assert out == 'if ((a) || (b))'
コード例 #55
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_or_operator():
    out = reformat.reformat('a = b | c;', 1)
    assert out == 'a = b | c;'
    out = reformat.reformat('f(a | b);', 1)
    assert out == 'f(a | b);'
    out = reformat.reformat('std::cout<<a|b;')
    assert out == 'std::cout << a | b;'
    out = reformat.reformat('if (a|b)', 1)
    assert out == 'if (a | b)'
    out = reformat.reformat('if (a||b)', 1)
    assert out == 'if (a || b)'
    out = reformat.reformat('if ((a)||(b))', 1)
    assert out == 'if ((a) || (b))'
コード例 #56
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_bracket_alignment():
    code = '''
    f(a,
      b,
      c)'''
    out = reformat.reformat(code, 1)
    assert out == code
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
    code = '''
    f(
        a,
        b,
        c)'''
    out = reformat.reformat(code, 1)
    assert out == code
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
    code = '''
    f(a, g(b,
           c)
      d);'''
    out = reformat.reformat(code, 1)
    assert out == code
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
    code = '''
    freallylongname(
        freallylongname(
            Atype
                reallylongconstructorname(
                    a)));'''
    out = reformat.reformat(code, 1)
    assert out == code
    out = reformat.reformat(code, 1, set_indent=True)
    assert out == code
コード例 #57
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_for_statement():
    out = reformat.reformat('for(int i=0;i<c;++i) a;')
    assert out == 'for (int i = 0; i < c; ++i) a;'
    out = reformat.reformat('for(int i=0;i<c;++i)')
    assert out == 'for (int i = 0; i < c; ++i)'
    out = reformat.reformat('for ( int i = 0 ; i < c ; ++i ) ')
    assert out == 'for (int i = 0; i < c; ++i)'
    out = reformat.reformat('for ( int i = 0 ; i < a->c ; ++i ) ')
    assert out == 'for (int i = 0; i < a->c; ++i)'
    code = '''for (int i = 0; i < c; ++i)
{
    f();
}
a = g();'''
    out = reformat.reformat(code)
    assert out == code
    out = reformat.reformat(code, set_indent=True)
    assert out == code
コード例 #58
0
ファイル: ClassMS.py プロジェクト: griffinfoster/shapelets
    def __init__(self,MSname,Col="DATA",zero_flag=True,ReOrder=False,EqualizeFlag=False,DoPrint=True,DoReadData=True,
                 TimeChunkSize=None,GetBeam=False,RejectAutoCorr=False,SelectSPW=None,DelStationList=None):


        if MSname=="": exit()
        MSname=reformat.reformat(MSname,LastSlash=False)
        self.MSName=MSname
        self.ColName=Col
        self.zero_flag=zero_flag
        self.ReOrder=ReOrder
        self.EqualizeFlag=EqualizeFlag
        self.DoPrint=DoPrint
        self.TimeChunkSize=TimeChunkSize
        self.RejectAutoCorr=RejectAutoCorr
        self.SelectSPW=SelectSPW
        self.DelStationList=DelStationList
        self.ReadMSInfo(MSname,DoPrint=DoPrint)

        if DoReadData: self.ReadData()
        #self.RemoveStation()

        self.SR=None
        if GetBeam:
            self.LoadSR()
コード例 #59
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_includes():
    out = reformat.reformat('#include <iostream>')
    assert out == '#include <iostream>'
    out = reformat.reformat('#include <iostream> \n#include <string>')
    assert out == '#include <iostream>\n#include <string>'
コード例 #60
0
ファイル: test_reformat.py プロジェクト: Sbte/reformat.py
def test_template_members():
    out = reformat.reformat('a<b>::c')
    assert out == 'a<b>::c'