コード例 #1
0
 def test_evaluate_function_name_substring(self):
     from arithmetic import evaluate
     res = evaluate('f', variables={'af':'1'}, functions={'f': 'af'})
     self.assertEqual( res, '1' )
コード例 #2
0
 def test_evaluate_function_recursive_no_initial_value(self):
     from arithmetic import evaluate
     res = evaluate('f', functions={'f': 'f+1'})
     self.assertEqual( res, '0' )
コード例 #3
0
 def test_evaluate_variable_plus(self):
     from arithmetic import evaluate
     res = evaluate('f+1', variables={'f':'1'})
     self.assertEqual( res, '2' )
コード例 #4
0
 def test_evaluate_function(self):
     from arithmetic import evaluate
     res = evaluate('f', variables={'a':'1'}, functions={'f': 'a+1'})
     self.assertEqual( res, '2' )
コード例 #5
0
 def test_evaluate_numeric(self):
     from arithmetic import evaluate
     res = evaluate('5+2')
     self.assertEqual( res, '7' )
コード例 #6
0
 def test_evaluate_variable(self):
     from arithmetic import evaluate
     res = evaluate('a', variables={'a':'1'})
     self.assertEqual( res, '1' )
コード例 #7
0
ファイル: tests.py プロジェクト: ppaez/arithmetic
 def test_evaluate_factors(self):
     from arithmetic import evaluate
     res = evaluate('5**2')
     self.assertEqual( res, '25' )
コード例 #8
0
ファイル: tests.py プロジェクト: ppaez/arithmetic
 def test_evaluate_factor_multiple_word_identifier(self):
     from arithmetic import evaluate
     res = evaluate('avg val', variables={'avg val':'5'})
     self.assertEqual( res, '5' )
コード例 #9
0
ファイル: tests.py プロジェクト: ppaez/arithmetic
 def test_evaluate_factor_open_parenthesis(self):
     from arithmetic import evaluate
     res = evaluate('(1)')
     self.assertEqual( res, '1' )
コード例 #10
0
ファイル: tests.py プロジェクト: ppaez/arithmetic
 def test_evaluate_factor_percentage(self):
     from arithmetic import evaluate
     res = evaluate('50%')
     self.assertEqual( res, '0.5' )
コード例 #11
0
ファイル: tests.py プロジェクト: ppaez/arithmetic
 def test_evaluate_negative_factor(self):
     from arithmetic import evaluate
     res = evaluate('5*-2')
     self.assertEqual( res, '-10' )