本文整理汇总了Python中vimcalc.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testXorAssign
def testXorAssign(self):
vimcalc.parse("x = 5")
vimcalc.parse("y = 3")
assert vimcalc.parse("let x ^= y") == "x = 6"
vimcalc.parse("x = 2")
vimcalc.parse("y = 10")
assert vimcalc.parse("let x ^= y") == "x = 8"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:7,代码来源:tests.py
示例2: testModAssign
def testModAssign(self):
vimcalc.parse("x = 4")
vimcalc.parse("y = 5")
assert vimcalc.parse("let x %= y") == "x = 4.0"
vimcalc.parse("x = 4")
vimcalc.parse("y = 5")
assert vimcalc.parse("let y %= x") == "y = 1.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:7,代码来源:tests.py
示例3: testChangeMode
def testChangeMode(self):
vimcalc.parse(":dec")
assert vimcalc.parse(":vars") == "VARIABLES:\n----------\n ans : 0\n e : 2.71828182846\n phi : 1.61803398875\n pi : 3.14159265359\n"
vimcalc.parse(":hex")
assert vimcalc.parse(":vars") == "VARIABLES:\n----------\n ans : 0x0\n e : 0x2\n phi : 0x1\n pi : 0x3\n"
vimcalc.parse(":oct")
assert vimcalc.parse(":vars") == "VARIABLES:\n----------\n ans : 0\n e : 02\n phi : 01\n pi : 03\n"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:7,代码来源:tests.py
示例4: testParseError
def testParseError(self):
assert vimcalc.parse("9**5/)") == "Parse error: the expression is invalid."
assert vimcalc.parse("4//5") == "Parse error: the expression is invalid."
assert vimcalc.parse("--1") == "Parse error: the expression is invalid."
assert vimcalc.parse("!4") == "Parse error: the expression is invalid."
assert vimcalc.parse("2***3") == "Parse error: the expression is invalid."
assert vimcalc.parse("sin(2,)") == "Parse error: apply() arg 2 expected sequence, found int"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:7,代码来源:tests.py
示例5: testSubtraction
def testSubtraction(self):
assert vimcalc.parse("4-3-2") == "ans = -1.0"
assert vimcalc.parse("(4-3)-2") == "ans = -1.0"
assert vimcalc.parse("4-(3-2)") == "ans = 3.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:4,代码来源:tests.py
示例6: testAddition
def testAddition(self):
assert vimcalc.parse("(2+3)+4") == "ans = 9.0"
assert vimcalc.parse("2+(3+4)") == "ans = 9.0"
assert vimcalc.parse("2+3+4") == "ans = 9.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:4,代码来源:tests.py
示例7: testRightShift
def testRightShift(self):
assert vimcalc.parse("(16>>2)>>1") == "ans = 2"
assert vimcalc.parse("16>>(2>>1)") == "ans = 8"
assert vimcalc.parse("16>>1>>2") == "ans = 2"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:4,代码来源:tests.py
示例8: testModulo
def testModulo(self):
assert vimcalc.parse("(5%4)%3") == "ans = 1.0"
assert vimcalc.parse("5%(4%3)") == "ans = 0.0"
assert vimcalc.parse("5%4%3") == "ans = 1.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:4,代码来源:tests.py
示例9: testMultiplication
def testMultiplication(self):
assert vimcalc.parse("2*2*2") == "ans = 8.0"
assert vimcalc.parse("(2*2)*2") == "ans = 8.0"
assert vimcalc.parse("2*(2*2)") == "ans = 8.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:4,代码来源:tests.py
示例10: testComplicatedNested
def testComplicatedNested(self):
assert vimcalc.parse("sin(sqrt(((pi/2)*2)**2)/2-(3-3))") == "ans = 1.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例11: testPow
def testPow(self):
assert vimcalc.parse("pow(2,5)") == "ans = 32.0", 'test pow(x,y)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例12: testPerms
def testPerms(self):
assert vimcalc.parse("perms(3,2)") == "ans = 6", 'test perms(n,k)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例13: testNrt
def testNrt(self):
assert vimcalc.parse("nrt(27,3)") == "ans = 3.0", 'test nrt(x,n)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例14: testMin
def testMin(self):
assert vimcalc.parse("min(3,7)") == "ans = 3.0", 'test min(x,y)'
assert vimcalc.parse("min(3.2,7.6)") == "ans = 3.2", 'test min(x,y)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:3,代码来源:tests.py
示例15: testMax
def testMax(self):
assert vimcalc.parse("max(3,7)") == "ans = 7.0", 'test max(x,y)'
assert vimcalc.parse("max(3.2,7.6)") == "ans = 7.6", 'test max(x,y)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:3,代码来源:tests.py
示例16: testFactorial
def testFactorial(self):
assert vimcalc.parse("5!") == "ans = 120", 'factorial'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例17: runTest
def runTest(self):
assert vimcalc.parse("5*4") == "ans = 20.0", 'sanity check.'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例18: testRad
def testRad(self):
assert vimcalc.parse("rad(0)") == "ans = 0.0", 'test rad(x)'
assert vimcalc.parse("rad(180)") == "ans = 3.14159265359", 'test rad(x)'
assert vimcalc.parse("rad(360)") == "ans = 6.28318530718", 'test rad(x)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:4,代码来源:tests.py
示例19: testAllPrecedenceAtOnce
def testAllPrecedenceAtOnce(self):
assert vimcalc.parse("5*4+2/sin(pi/2)**2+-1") == "ans = 21.0"
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:2,代码来源:tests.py
示例20: testRound
def testRound(self):
assert vimcalc.parse("round(4.2)") == "ans = 4.0", 'test round(x)'
assert vimcalc.parse("round(4.7)") == "ans = 5.0", 'test round(x)'
开发者ID:Hans-Guenter,项目名称:VimCalc,代码行数:3,代码来源:tests.py
注:本文中的vimcalc.parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论