diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-08-04 09:52:35 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-08-04 09:52:35 -0500 |
commit | e0db26b5cbc05df73f7917ffeb8f1d3144e74ec1 (patch) | |
tree | 00bf06406ebebb0fac5a212f473e29e6ccbf3a58 /unitTests.py | |
parent | 36aa91c4f603ddb15054b0ff9f5daf5044b1dd31 (diff) | |
download | pyparsing-git-e0db26b5cbc05df73f7917ffeb8f1d3144e74ec1.tar.gz |
fourFn.py updates - handle leading '+' and '-' unary signs for parenthesized expressions; and real numbers with no leading digit before the decimal
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/unitTests.py b/unitTests.py index 4e27776..330afe1 100644 --- a/unitTests.py +++ b/unitTests.py @@ -127,8 +127,9 @@ class PyparsingTestInit(ParseTestCase): class ParseFourFnTest(ParseTestCase): def runTest(self): import examples.fourFn as fourFn + import math def test(s, ans): - fourFn.exprStack = [] + fourFn.exprStack[:] = [] results = fourFn.BNF().parseString(s) try: resultValue = fourFn.evaluate_stack(fourFn.exprStack) @@ -138,10 +139,6 @@ class ParseFourFnTest(ParseTestCase): self.assertTrue(resultValue == ans, "failed to evaluate %s, got %f" % (s, resultValue)) print_(s, "->", resultValue) - - import math - e = math.exp(1) - test("9", 9) test("-9", -9) test("--9", 9) @@ -183,6 +180,8 @@ class ParseFourFnTest(ParseTestCase): test("sgn(cos(PI/4))", 1) test("sgn(cos(PI/2))", 0) test("sgn(cos(PI*3/4))", -1) + test("+(sgn(cos(PI/4)))", 1) + test("-(sgn(cos(PI/4)))", -1) class ParseSQLTest(ParseTestCase): def runTest(self): |