本文整理汇总了Python中vimcalc.parse函数的典型用法代码示例。如果您正苦于以下问题:Python parse函数的具体用法?Python parse怎么用?Python parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"
示例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"
示例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"
示例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"
示例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"
示例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"
示例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"
示例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"
示例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"
示例10: testComplicatedNested
def testComplicatedNested(self):
assert vimcalc.parse("sin(sqrt(((pi/2)*2)**2)/2-(3-3))") == "ans = 1.0"
示例11: testPow
def testPow(self):
assert vimcalc.parse("pow(2,5)") == "ans = 32.0", 'test pow(x,y)'
示例12: testPerms
def testPerms(self):
assert vimcalc.parse("perms(3,2)") == "ans = 6", 'test perms(n,k)'
示例13: testNrt
def testNrt(self):
assert vimcalc.parse("nrt(27,3)") == "ans = 3.0", 'test nrt(x,n)'
示例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)'
示例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)'