def testConvertCodeToAnything(self): testCode = "return 0" x = SLRC(testCode) x.kind = "scalar" self.assertEqual(x.value, 0) x = SLRC(testCode) x.kind = "list" self.assertEqual(x.value, [0]) x = SLRC(testCode) x.kind = "range" self.assertEqual(x.value, [0, 1])
def testConvertRangeToList(self): testRange = {'start': 0, 'end': 5, 'num': 6} x = SLRC(testRange) x.kind = 'list' self.assertEqual(x.value, [0, 1, 2, 3, 4, 5])
def testConvertListToCode(self): x = SLRC([1, 2, 3]) x.kind = 'code' self.assertEqual(x(), 1)
def testConvertRangeToScalar(self): testRange = {'start': 0, 'end': 5, 'num': 6} x = SLRC(testRange) x.kind = 'scalar' self.assertEqual(x.value, 0)
def testConvertListToScalar(self): x = SLRC([1, 2, 3]) x.kind = 'scalar' self.assertEqual(x.value, 1)
def testConvertListToRange(self): x = SLRC([1, 4, 5]) x.kind = 'range' self.assertEqual(x.value, [1, 3, 5])
def testConvertScalarToRange(self): x = SLRC(5) x.kind = 'range' self.assertEqual(x.value, [5])
def testConvertScalarToCode(self): x = SLRC(5) x.kind = 'code' self.assertEqual(x(), 5)
def testConvertRangeToCode(self): testRange = {'start': 0, 'end': 5, 'num': 6} x = SLRC(testRange) x.kind = 'code' self.assertEqual(x(), 0)
def testConvertScalarToList(self): x = SLRC(5) x.kind = 'list' self.assertEqual(x.value, [5])