Example #1
0
    def testAddIfNotInNCallsBeforeEntryPoint(self):
        fe1 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe3 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe4 = FlowEntry('C', 'f', 'j', '(a, b)', 'RetClass')

        rfp = RecordedFlowPath('B', 'j')
        rfp.addIfNotIn(fe1)
        rfp.addIfNotIn(fe3)
        rfp.addIfNotIn(fe4)
        self.assertEqual('C.f, B.j, (a, b), RetClass\n', str(rfp))
Example #2
0
    def testAddIfNotInEntryPointNeverReached(self):
        fe1 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe3 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe4 = FlowEntry('C', 'f', 'j', '(a, b)', 'RetClass')

        rfp = RecordedFlowPath('A', 'a')
        rfp.addIfNotIn(fe1)
        rfp.addIfNotIn(fe3)
        rfp.addIfNotIn(fe4)
        self.assertEqual('', str(rfp))
    def testAddIfNotInNCallsBeforeEntryPointEntryPointAddedTwiceWithSubsequentEntries(self):
        fe4 = FlowEntry('C', 'f', 'j', '(a, b)', 'RetClass')
        fe5 = FlowEntry('C', 'f', 'j', '(a, b)', 'RetClass')
        fe1 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe3 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')

        rfp = RecordedFlowPath('B', 'j')
        rfp.addIfNotIn(fe1) # before entry point: will not be added
        rfp.addIfNotIn(fe3) # before entry point: will not be added
        rfp.addIfNotIn(fe4)
        rfp.addIfNotIn(fe5)
        rfp.addIfNotIn(fe1) # after entry point: will  be added
        rfp.addIfNotIn(fe3) # after entry point: will  be added
        self.assertEqual('C.f, B.j, (a, b), RetClass\nA.e, B.f, (a, b), RetClass\nA.e, C.f, (a, b), RetClass\n',str(rfp))
Example #4
0
 def testFlowEntryReturnTypeVaryingMaxArgNumAndMaxReturnTypeCharLen(self):
     fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', 'aaaa, bbbb, cccc')
     self.assertEqual(fe.createReturnType(2, 14), 'aaaa, ...')
     self.assertEqual(fe.createReturnType(2, 15), 'aaaa, bbbb, ...')
     self.assertEqual(fe.createReturnType(2, 16), 'aaaa, bbbb, ...')
     self.assertEqual(fe.createReturnType(3, 15), 'aaaa, bbbb, ...')
     self.assertEqual(fe.createReturnType(3, 16), 'aaaa, bbbb, cccc')
     self.assertEqual(fe.createReturnType(3, 17), 'aaaa, bbbb, cccc')
     self.assertEqual(fe.createReturnType(4, 15), 'aaaa, bbbb, ...')
     self.assertEqual(fe.createReturnType(4, 16), 'aaaa, bbbb, cccc')
     self.assertEqual(fe.createReturnType(4, 17), 'aaaa, bbbb, cccc')
 def testFlowEntryCreateSignatureVaryingMaxSigArgNumAndMaxSigCharLen(self):
     fe = FlowEntry('A', 'e', 'B', 'f', '95', '(aaaa, bbbb, cccc)', 'f_RetType')
     self.assertEqual(fe.createSignature(2, 16), '(aaaa, ...)')
     self.assertEqual(fe.createSignature(2, 17), '(aaaa, bbbb, ...)')
     self.assertEqual(fe.createSignature(2, 18), '(aaaa, bbbb, ...)')
     self.assertEqual(fe.createSignature(3, 17), '(aaaa, bbbb, ...)')
     self.assertEqual(fe.createSignature(3, 18), '(aaaa, bbbb, cccc)')
     self.assertEqual(fe.createSignature(3, 19), '(aaaa, bbbb, cccc)')
     self.assertEqual(fe.createSignature(4, 17), '(aaaa, bbbb, ...)')
     self.assertEqual(fe.createSignature(4, 18), '(aaaa, bbbb, cccc)')
     self.assertEqual(fe.createSignature(4, 19), '(aaaa, bbbb, cccc)')
    def testFlowEntryGetToMethodCallLineNumber(self):
        fe1 = FlowEntry( fromClass='fromClass',
                         fromMethod='fromMethod',
                         toClass='toClass',
                         toMethod='toMethod', toMethodCalledFromLineNumber='12-34-21')

        self.assertEqual(fe1.getToMethodCallLineNumber(), '21')

        fe2 = FlowEntry( fromClass='fromClass',
                         fromMethod='fromMethod',
                         toClass='toClass',
                         toMethod='toMethod', toMethodCalledFromLineNumber='12')

        self.assertEqual(fe2.getToMethodCallLineNumber(), '12')

        fe3 = FlowEntry( fromClass='fromClass',
                         fromMethod='fromMethod',
                         toClass='toClass',
                         toMethod='toMethod', toMethodCalledFromLineNumber='')

        self.assertEqual(fe3.getToMethodCallLineNumber(), '')
Example #7
0
    def testFlowEntryEq(self):
        fe1 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe2 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe3 = FlowEntry('A', 'e', 'f', '(a, b)', 'RetClass')
        fe4 = FlowEntry('C', 'f', 'f', '(a, b)', 'RetClass')
        fe5 = FlowEntry('A', 'e', 'g', '(a, b)', 'RetClass')
        fe6 = FlowEntry('A', 'e', 'f', '(a, w)', 'RetClass')
        fe7 = FlowEntry('A', 'e', 'f', '(a, b)', '')

        self.assertTrue(fe1 == fe2)
        self.assertTrue(fe1 == fe3)
        self.assertFalse(fe1 == fe4)
        self.assertFalse(fe1 == fe5)
        self.assertFalse(fe1 == fe6)
        self.assertFalse(fe1 == fe7)
Example #8
0
    def testFlowEntryCreateReturnTypeVaryingMaxReturnTypeCharLen(self):
        fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', 'aaa, bbb, ccc, ddd')
        self.assertEqual(fe.createReturnType(None, None), 'aaa, bbb, ccc, ddd')
        self.assertEqual(fe.createReturnType(None, 100), 'aaa, bbb, ccc, ddd')
        self.assertEqual(fe.createReturnType(None, 0), '...')
        self.assertEqual(fe.createReturnType(None, 8), 'aaa, ...')
        self.assertEqual(fe.createReturnType(None, 7), '...')
        self.assertEqual(fe.createReturnType(None, 13), 'aaa, bbb, ...')
        self.assertEqual(fe.createReturnType(None, 12), 'aaa, ...')

        fe = FlowEntry('A', 'e', 'B', 'f', '95', '', '')
        self.assertEqual(fe.createReturnType(None, None), '')
        self.assertEqual(fe.createReturnType(None, 100), '')
        self.assertEqual(fe.createReturnType(None, 0), '')
Example #9
0
    def testFlowEntryCreateSignatureVaryingMaxSigArgNum(self):
        fe = FlowEntry('A', 'e', 'B', 'f', '95', '(a, b, c, d)', 'f_RetType')
        self.assertEqual(fe.createSignature(None, None), '(a, b, c, d)')
        self.assertEqual(fe.createSignature(4, None), '(a, b, c, d)')
        self.assertEqual(fe.createSignature(5, None), '(a, b, c, d)')
        self.assertEqual(fe.createSignature(3, None), '(a, b, c, ...)')
        self.assertEqual(fe.createSignature(1, None), '(a, ...)')
        self.assertEqual(fe.createSignature(0, None), '(...)')

        fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', 'f_RetType')
        self.assertEqual(fe.createSignature(None, None), '()')
        self.assertEqual(fe.createSignature(0, None), '()')
        self.assertEqual(fe.createSignature(1, None), '()')
        self.assertEqual(fe.createSignature(2, None), '()')

        fe = FlowEntry('A', 'e', 'B', 'f', '95', '(a)', 'f_RetType')
        self.assertEqual(fe.createSignature(None, None), '(a)')
        self.assertEqual(fe.createSignature(0, None), '(...)')
        self.assertEqual(fe.createSignature(1, None), '(a)')
        self.assertEqual(fe.createSignature(2, None), '(a)')
Example #10
0
    def testFlowEntryCreateReturnTypeVaryingMaxArgNum(self):
        fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', 'a, b, c, d')
        self.assertEqual(fe.createReturnType(None, None), 'a, b, c, d')
        self.assertEqual(fe.createReturnType(4, None), 'a, b, c, d')
        self.assertEqual(fe.createReturnType(5, None), 'a, b, c, d')
        self.assertEqual(fe.createReturnType(3, None), 'a, b, c, ...')
        self.assertEqual(fe.createReturnType(1, None), 'a, ...')
        self.assertEqual(fe.createReturnType(0, None), '...')

        fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', '')
        self.assertEqual(fe.createReturnType(None, None), '')
        self.assertEqual(fe.createReturnType(0, None), '')
        self.assertEqual(fe.createReturnType(1, None), '')
        self.assertEqual(fe.createReturnType(2, None), '')

        fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', 'a')
        self.assertEqual(fe.createReturnType(None, None), 'a')
        self.assertEqual(fe.createReturnType(0, None), '...')
        self.assertEqual(fe.createReturnType(1, None), 'a')
        self.assertEqual(fe.createReturnType(2, None), 'a')
Example #11
0
 def testFlowEntryToString(self):
     fe1 = FlowEntry('A', 'e', 'B', 'f', '95', '(a, b)', 'f_RetType')
     self.assertEqual('A.e, B.f, 95, (a, b), f_RetType', str(fe1))
Example #12
0
    def testFlowEntryCreateSignatureVaryingMaxSigCharLen(self):
        fe = FlowEntry('A', 'e', 'B', 'f', '95', '(aaa, bbb, ccc, ddd)',
                       'f_RetType')
        self.assertEqual(fe.createSignature(None, None),
                         '(aaa, bbb, ccc, ddd)')
        self.assertEqual(fe.createSignature(None, 100), '(aaa, bbb, ccc, ddd)')
        self.assertEqual(fe.createSignature(None, 0), '(...)')
        self.assertEqual(fe.createSignature(None, 10), '(aaa, ...)')
        self.assertEqual(fe.createSignature(None, 9), '(...)')
        self.assertEqual(fe.createSignature(None, 15), '(aaa, bbb, ...)')
        self.assertEqual(fe.createSignature(None, 14), '(aaa, ...)')

        fe = FlowEntry('A', 'e', 'B', 'f', '95', '()', 'f_RetType')
        self.assertEqual(fe.createSignature(None, None), '()')
        self.assertEqual(fe.createSignature(None, 100), '()')
        self.assertEqual(fe.createSignature(None, 0), '()')