Adding new stuff
This commit is contained in:
parent
a1687a2e5b
commit
f8f54ab17a
1580 changed files with 205558 additions and 0 deletions
46
bundle/jedi-vim/jedi/test/static_analysis/branches.py
Normal file
46
bundle/jedi-vim/jedi/test/static_analysis/branches.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# -----------------
|
||||
# Simple tests
|
||||
# -----------------
|
||||
|
||||
import random
|
||||
|
||||
if random.choice([0, 1]):
|
||||
x = ''
|
||||
else:
|
||||
x = 1
|
||||
if random.choice([0, 1]):
|
||||
y = ''
|
||||
else:
|
||||
y = 1
|
||||
|
||||
# A simple test
|
||||
if x != 1:
|
||||
x.upper()
|
||||
else:
|
||||
#! 2 attribute-error
|
||||
x.upper()
|
||||
pass
|
||||
|
||||
# This operation is wrong, because the types could be different.
|
||||
#! 6 type-error-operation
|
||||
z = x + y
|
||||
# However, here we have correct types.
|
||||
if x == y:
|
||||
z = x + y
|
||||
else:
|
||||
#! 6 type-error-operation
|
||||
z = x + y
|
||||
|
||||
# -----------------
|
||||
# With a function
|
||||
# -----------------
|
||||
|
||||
def addition(a, b):
|
||||
if type(a) == type(b):
|
||||
return a + b
|
||||
else:
|
||||
#! 9 type-error-operation
|
||||
return a + b
|
||||
|
||||
addition(1, 1)
|
||||
addition(1.0, '')
|
||||
Loading…
Add table
Add a link
Reference in a new issue