예제 #1
0
 def test_power_root(self):
     power = A.Power('1', '2')
     root = A.Root('1', '2')
     self.assertEqual(power, '1 ^ 2')
     self.assertEqual(root, r'\sqrt[\leftroot{-1}\uproot{1}2]{1}')
     self.assertEqual(power, (~A.Root)('1', '2'))
     self.assertEqual(root, (~A.Power)('1', '2'))
예제 #2
0
 def test_mult_frac(self):
     mult = A.Multiply("1", "2")
     frac = A.Fraction("1", "2")
     self.assertEqual(mult, "1 * 2")
     self.assertEqual(frac, r"\frac{1}{2}")
     self.assertEqual(mult, (~A.Fraction)("1", "2"))
     self.assertEqual(frac, (~A.Multiply)("1", "2"))
예제 #3
0
 def test_add_minus(self):
     plus = A.Plus("1", "2")
     minus = A.Minus("1", "2")
     self.assertEqual(plus, "1 + 2")
     self.assertEqual(minus, "1 - 2")
     self.assertEqual(plus, (~A.Minus)("1", "2"))
     self.assertEqual(minus, (~A.Plus)("1", "2"))
예제 #4
0
 def test_negate(self):
     negated = A.Negate('1')
     still_negated = A.Negate('-1')
     unnegated = (~A.Negate)('-1')
     still_unnegated = (~A.Negate)('1')
     self.assertEqual(negated, '-1')
     self.assertEqual(unnegated, '1')
     self.assertEqual(still_negated, '-1')
     self.assertEqual(still_unnegated, '1')
예제 #5
0
파일: test_ast.py 프로젝트: narang99/nbtex
 def test_comparison_operators(self):
     a, b = makeVar("a", "b")
     c = a < b
     self.assertEqual(c.build(), A.LessThan("a", "b"))
     c = a > b
     self.assertEqual(c.build(), A.GreaterThan("a", "b"))
     c = a <= b
     self.assertEqual(c.build(), A.LessThanEqual("a", "b"))
     c = a >= b
     self.assertEqual(c.build(), A.GreaterThanEqual("a", "b"))
     c = a.equals(b)
     self.assertEqual(c.build(), A.Equal("a", "b"))
     c = a.not_equals(b)
     self.assertEqual(c.build(), (~A.Equal)("a", "b"))
예제 #6
0
파일: test_ast.py 프로젝트: narang99/nbtex
 def test_inverted_basic_arithmatic(self):
     a, b = makeVar("a", "b")
     c = a + b
     self.assertIsNot(c, a)
     self.assertIsNot(c, b)
     self.assertEqual((~c).build(), A.Minus("a", "b"))
     c = a - b
     self.assertEqual((~c).build(), A.Plus("a", "b"))
     c = a * b
     self.assertEqual((~c).build(), A.Fraction("a", "b"))
     c = a / b
     self.assertEqual((~c).build(), A.Multiply("a", "b"))
     c = a**b
     self.assertEqual((~c).build(), A.Root("a", "b"))
     c = a.root(b)
     self.assertEqual((~c).build(), A.Power('a', 'b'))
예제 #7
0
 def test_space(self):
     space = A.Space('1', '2')
     self.assertEqual(space, r'1 \hspace{1mm} 2')