예제 #1
0
def of_reference(range_address, source=None):
    """Return the syntax for a reference"""
    reference = range_address.str
    if source is not None:
        reference = source + " " + reference
    reference = "[" + reference + "]"
    if type(range_address) is Cell:
        return CellReference(reference)
    elif type(range_address) is Range:
        return RangeReference(reference)
    else:
        raise TypeError, "Not a Cell or Range"
예제 #2
0
 def test_of_sqrtpi(self):
     self.assertEqual(of_sqrtpi(Number("2")), "SQRTPI(2)")
     self.assertEqual(of_sqrtpi(CellReference("[.A1]")), "SQRTPI([.A1])")
     self.assertRaises(TypeError, of_sqrtpi, 2)
예제 #3
0
 def test_of_seriessum(self):
     self.assertEqual(of_seriessum(Number("1"),CellReference("[.A1]"), Number("3"), RangeReference("[.A1:.B2]") ), "SERIESSUM(1 ; [.A1] ; 3 ; [.A1:.B2])")
     self.assertRaises(TypeError, of_seriessum, 2, 3, 4, 5)
예제 #4
0
 def test_of_degrees(self):
     self.assertEqual(of_degrees(Number("2")), "DEGREES(2)")
     self.assertEqual(of_degrees(CellReference("[.A1]")), "DEGREES([.A1])")
     self.assertRaises(TypeError, of_degrees, 2)
예제 #5
0
    def test_of_multiply(self):
        self.assertEqual(of_multiply(CellReference("[.A1]")), "[.A1]")
        self.assertEqual(of_multiply(Number("2"), CellReference("[.D4]")),
                         "2*[.D4]")

        self.assertRaises(TypeError, of_multiply, 2)
예제 #6
0
 def test_of_add(self):
     self.assertEqual(of_add(CellReference("[.A1]")), "[.A1]")
     self.assertEqual(of_add(Number("2"), CellReference("[.D4]")),
                      "2+[.D4]")
     self.assertRaises(TypeError, of_add, 2)
예제 #7
0
 def test_of_combina(self):
     self.assertEqual(of_combina(Number("1"), CellReference("[.A1]")), "COMBINA(1 ; [.A1])")
     self.assertRaises(TypeError, of_combina, 2, 3)
예제 #8
0
 def test_of_atan(self):
     self.assertEqual(of_atan(Number("2")), "ATAN(2)")
     self.assertEqual(of_atan(CellReference("[.A1]")), "ATAN([.A1])")
     self.assertRaises(TypeError, of_atan, 2)  
예제 #9
0
 def test_of_odd(self):
     self.assertEqual(of_odd(Number("2")), "ODD(2)")
     self.assertEqual(of_odd(CellReference("[.A1]")), "ODD([.A1])")
     self.assertRaises(TypeError, of_odd, 2)
예제 #10
0
 def test_of_abs(self):
     self.assertEqual(of_abs(Number("2")), "ABS(2)")
     self.assertEqual(of_abs(CellReference("[.A1]")), "ABS([.A1])")
     self.assertRaises(TypeError, of_abs, 2)
예제 #11
0
 def test_of_mround(self):
     self.assertEqual(of_mround(CellReference("[.B2]"),Number("3")), "MROUND([.B2] ; 3)")
     self.assertRaises(TypeError, of_mround, 2, 3)
예제 #12
0
 def test_of_log10(self):
     self.assertEqual(of_log10(Number("2")), "LOG10(2)")
     self.assertEqual(of_log10(CellReference("[.A1]")), "LOG10([.A1])")
     self.assertRaises(TypeError, of_log10, 2)
예제 #13
0
 def test_of_log(self):
     self.assertEqual(of_log(CellReference("[.B2]"),Number("3")), "LOG([.B2] ; 3)")
     self.assertRaises(TypeError, of_log, 2)
예제 #14
0
 def test_of_iseven(self):
     self.assertEqual(of_iseven(Number("2")), "ISEVEN(2)")
     self.assertEqual(of_iseven(CellReference("[.A1]")), "ISEVEN([.A1])")
     self.assertRaises(TypeError, of_iseven, 2)
예제 #15
0
 def test_of_exp(self):
     self.assertEqual(of_exp(Number("2")), "EXP(2)")
     self.assertEqual(of_exp(CellReference("[.A1]")), "EXP([.A1])")
     self.assertRaises(TypeError, of_exp, 2)
예제 #16
0
 def test_of_trunc(self):
     self.assertEqual(of_trunc(CellReference("[.B2]"),Number("3")), "TRUNC([.B2] ; 3)")
     self.assertRaises(TypeError, of_trunc, 2, 3)
예제 #17
0
 def test_of_acot(self):
     self.assertEqual(of_acot(Number("2")), "ACOT(2)")
     self.assertEqual(of_acot(CellReference("[.A1]")), "ACOT([.A1])")
     self.assertRaises(TypeError, of_acot, 2) 
예제 #18
0
 def test_of_power(self):
     self.assertEqual(of_power(CellReference("[.B2]"),Number("3")), "POWER([.B2] ; 3)")
     self.assertRaises(TypeError, of_power, 2, 3)
예제 #19
0
 def test_of_atan2(self):
     self.assertEqual(of_atan2(Number("1"), CellReference("[.A1]")), "ATAN2(1 ; [.A1])")
     self.assertRaises(TypeError, of_atan2, 2, 2)
예제 #20
0
 def test_of_quotient(self):
     self.assertEqual(of_quotient(CellReference("[.B2]"),Number("3")), "QUOTIENT([.B2] ; 3)")
     self.assertRaises(TypeError, of_quotient, 2, 3)
예제 #21
0
 def test_of_coth(self):
     self.assertEqual(of_coth(Number("2")), "COTH(2)")
     self.assertEqual(of_coth(CellReference("[.A1]")), "COTH([.A1])")
     self.assertRaises(TypeError, of_coth, 2)
예제 #22
0
 def test_of_radians(self):
     self.assertEqual(of_radians(Number("2")), "RADIANS(2)")
     self.assertEqual(of_radians(CellReference("[.A1]")), "RADIANS([.A1])")
     self.assertRaises(TypeError, of_radians, 2)
예제 #23
0
    def test_of_substract(self):
        self.assertEqual(of_substract(CellReference("[.A1]")), "[.A1]")
        self.assertEqual(of_substract(Number("2"), CellReference("[.D4]")),
                         "2-[.D4]")

        self.assertRaises(TypeError, of_substract, 2)
예제 #24
0
 def test_of_randbetween(self):
     self.assertEqual(of_randbetween(CellReference("[.B2]"),Number("3")), "RANDBETWEEN([.B2] ; 3)")
     self.assertRaises(TypeError, of_randbetween, 2, 3)
예제 #25
0
    def test_of_divide(self):
        self.assertEqual(of_divide(CellReference("[.A1]")), "[.A1]")
        self.assertEqual(of_divide(Number("2"), CellReference("[.D4]")),
                         "2/[.D4]")

        self.assertRaises(TypeError, of_divide, 2)
예제 #26
0
 def test_of_roundup(self):
     self.assertEqual(of_roundup(Number("1")), "ROUNDUP(1)")
     self.assertEqual(of_roundup(Number("1"), CellReference("[.A1]")), "ROUNDUP(1 ; [.A1])")
     self.assertRaises(TypeError, of_roundup, 2)