Example #1
0
    def testUsageOfTypeSystemCheckVariableOnPrimitiveType(self):
        '''When the sequence item is convertible to an integer -1 is returned, or -2 if its not convertible.'''
        ic = InjectCode()
        values = (1, 2, 3, 4, '5', 6.7)
        result = ic.arrayMethod(values)

        fixedValues = [v for v in values if isinstance(v, int)]\
                    + [-1 for v in values if isinstance(v, float)]\
                    + [-2 for v in values if not isinstance(v, int) and not isinstance(v, float)]
        self.assertEqual(result, sum(fixedValues))
Example #2
0
    def testUsageOfTypeSystemCheckVariableOnPrimitiveType(self):
        '''When the sequence item is convertible to an integer -1 is returned, or -2 if its not convertible.'''
        ic = InjectCode()
        values = (1, 2, 3, 4, '5', 6.7)
        result = ic.arrayMethod(values)

        fixedValues = [v for v in values if isinstance(v, int)]\
                    + [-1 for v in values if isinstance(v, float)]\
                    + [-2 for v in values if not isinstance(v, int) and not isinstance(v, float)]
        self.assertEqual(result, sum(fixedValues))
Example #3
0
 def testArgumentRemovalAndArgumentTypeModification(self):
     '''A method has its first argument removed and the second modified.'''
     ic = InjectCode()
     values = (1, 2, 3, 4, 5)
     result = ic.arrayMethod(values)
     self.assertEqual(result, sum(values))
Example #4
0
 def testArgumentRemovalAndArgumentTypeModification(self):
     '''A method has its first argument removed and the second modified.'''
     ic = InjectCode()
     values = (1, 2, 3, 4, 5)
     result = ic.arrayMethod(values)
     self.assertEqual(result, sum(values))