diff options
Diffstat (limited to 'tests/test_am_expression.py')
-rw-r--r-- | tests/test_am_expression.py | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/tests/test_am_expression.py b/tests/test_am_expression.py index 6786cc3..0f064e6 100644 --- a/tests/test_am_expression.py +++ b/tests/test_am_expression.py @@ -27,8 +27,8 @@ class TestAMConstantExpression(unittest.TestCase): self.assertEqual(ov.value, self.const_float_value) def test_to_gerber(self): - self.assertEqual(self.const_int.to_gerber(), '7') - self.assertEqual(self.const_float.to_gerber(), '1.2345') + self.assertEqual(self.const_int.to_gerber(), '7.000000') + self.assertEqual(self.const_float.to_gerber(), '1.234500') def test_to_instructions(self): self.const_int.to_instructions() @@ -120,15 +120,15 @@ class TestAMOperatorExpression(unittest.TestCase): def test_to_gerber(self): for op, expression in self.cc_exps: self.assertEqual(expression.to_gerber(), - '({0}){1}({2})'.format(self.c1, op, self.c2)) + '(%.6f)%s(%.6f)' % (self.c1, op, self.c2)) for op, expression in self.cv_exps: self.assertEqual(expression.to_gerber(), - '({0}){1}(${2})'.format(self.c1, op, self.v2)) + '(%.6f)%s($%d)' % (self.c1, op, self.v2)) for op, expression in self.vc_exps: self.assertEqual(expression.to_gerber(), - '(${0}){1}({2})'.format(self.v1, op, self.c2)) + '($%d)%s(%.6f)' % (self.v1, op, self.c2)) self.assertEqual(self.composition.to_gerber(), - '(({0})+({1}))+(({2})+({3}))'.format( + '((%.6f)+(%.6f))+((%.6f)+(%.6f))' % ( self.c1, self.c2, self.c1, self.c2 )) @@ -168,28 +168,29 @@ class TestAMExpression(unittest.TestCase): class TestEvalMacro(unittest.TestCase): def test_eval_macro(self): macros = [ - '$1=5.5*', - '$2=$3*', - '$3=(1.23)+(4.56)*', - '$3=(1.23)-(4.56)*', - '$3=(1.23)X(4.56)*', - '$3=(1.23)/(4.56)*', - '$3=(10.2)X($2)*', - '1,1.2*', - '1,$2*', - '1,($2)+($3)*', - #'1,(2.0)-($3)*', # This doesn't pass due to pcb-tools bug - '1,($2)X($3)*', - '1,($2)/($3)*', - '1,2.1,3.2*2,(3.1)/($1),$2*' + ('$1=5.5*', '$1=5.500000*'), + ('$1=0.0000001*', '$1=0.000000*'), + ('$2=$3*', '$2=$3*'), + ('$3=(1.23)+(4.56)*', '$3=(1.230000)+(4.560000)*'), + ('$3=(1.23)-(4.56)*', '$3=(1.230000)-(4.560000)*'), + ('$3=(1.23)X(4.56)*', '$3=(1.230000)X(4.560000)*'), + ('$3=(1.23)/(4.56)*', '$3=(1.230000)/(4.560000)*'), + ('$3=(10.2)X($2)*', '$3=(10.200000)X($2)*'), + ('1,1.2*', '1,1.200000*'), + ('1,$2*', '1,$2*'), + ('1,($2)+($3)*', '1,($2)+($3)*'), + #('1,(2.0)-($3)*', '1,(2.0)-($3)*'), # This doesn't pass due to pcb-tools bug + ('1,($2)X($3)*', '1,($2)X($3)*'), + ('1,($2)/($3)*', '1,($2)/($3)*'), + ('1,2.1,3.2*2,(3.1)/($1),$2*', '1,2.100000,3.200000*2,(3.100000)/($1),$2*'), ] - for macro in macros: - self._eval_macro_string(macro) + for macro, expected in macros: + self._eval_macro_string(macro, expected) - def _eval_macro_string(self, macro): + def _eval_macro_string(self, macro, expected): expressions = eval_macro(read_macro(macro)) gerber = self._to_gerber(expressions) - self.assertEqual(macro, gerber) + self.assertEqual(gerber, expected) def _to_gerber(self, expressions_list): gerber = '' |