Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
97a01674
Commit
97a01674
authored
Feb 09, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update test cases for recent compiler changes: exec/import * in nested
functinos and cell vars with */** parameters
parent
6492bf71
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
23 deletions
+65
-23
Lib/test/output/test_grammar
Lib/test/output/test_grammar
+0
-1
Lib/test/output/test_scope
Lib/test/output/test_scope
+1
-0
Lib/test/test_grammar.py
Lib/test/test_grammar.py
+0
-1
Lib/test/test_scope.py
Lib/test/test_scope.py
+64
-21
No files found.
Lib/test/output/test_grammar
View file @
97a01674
...
...
@@ -38,7 +38,6 @@ continue + try/finally ok
return_stmt
raise_stmt
import_stmt
SyntaxError expected for "def f(): from sys import *"
global_stmt
exec_stmt
if_stmt
...
...
Lib/test/output/test_scope
View file @
97a01674
...
...
@@ -12,3 +12,4 @@ test_scope
11. unoptimized namespaces
12. lambdas
13. UnboundLocal
14. complex definitions
Lib/test/test_grammar.py
View file @
97a01674
...
...
@@ -386,7 +386,6 @@ import time, sys
from
time
import
time
from
sys
import
*
from
sys
import
path
,
argv
check_syntax
(
"def f(): from sys import *"
)
print
'global_stmt'
# 'global' NAME (',' NAME)*
def
f
():
...
...
Lib/test/test_scope.py
View file @
97a01674
...
...
@@ -185,44 +185,64 @@ def check_syntax(s):
else
:
raise
TestFailed
# XXX for now, it is easiest to call this a syntax error:
# explicit is better than implicit...
test1
=
\
"""def unoptimized_clash1(strip):
check_syntax
(
"""def unoptimized_clash1(strip):
def f(s):
from string import *
return strip(s) # ambiguity: free or local
return f
"""
check_syntax
(
test1
)
"""
)
# a little harder to reject this one, but possible...
test2
=
\
"""def unoptimized_clash2():
check_syntax
(
"""def unoptimized_clash2():
from string import *
def f(s):
return strip(s) # ambiguity: global or local
return f
"""
# check_syntax(test2)
"""
)
check_syntax
(
"""def unoptimized_clash2():
from string import *
def g():
def f(s):
return strip(s) # ambiguity: global or local
return f
"""
)
# XXX could allow this for exec with const argument, but what's the point
test3
=
\
"""def error(y):
check_syntax
(
"""def error(y):
exec "a = 1"
def f(x):
return x + y
return f
"""
check_syntax
(
test3
)
"""
)
test4
=
\
"""def f(x):
check_syntax
(
"""def f(x):
def g():
return x
del x
"""
check_syntax
(
test4
)
del x # can't del name
"""
)
check_syntax
(
"""def f():
def g():
from string import *
return strip # global or local?
"""
)
# and verify a few cases that should work
def
noproblem1
():
from
string
import
*
f
=
lambda
x
:
x
def
noproblem2
():
from
string
import
*
def
f
(
x
):
return
x
+
1
def
noproblem3
():
from
string
import
*
def
f
(
x
):
global
y
y
=
x
print
"12. lambdas"
...
...
@@ -275,3 +295,26 @@ except UnboundLocalError:
pass
else
:
raise
TestFailed
print
"14. complex definitions"
def
makeReturner
(
*
lst
):
def
returner
():
return
lst
return
returner
verify
(
makeReturner
(
1
,
2
,
3
)()
==
(
1
,
2
,
3
))
def
makeReturner2
(
**
kwargs
):
def
returner
():
return
kwargs
return
returner
verify
(
makeReturner2
(
a
=
11
)()[
'a'
]
==
11
)
def
makeAddPair
((
a
,
b
)):
def
addPair
((
c
,
d
)):
return
(
a
+
c
,
b
+
d
)
return
addPair
verify
(
makeAddPair
((
1
,
2
))((
100
,
200
))
==
(
101
,
202
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment