-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2556 from Kodiologist/misplaced-tracebacks
Fix some traceback positions
- Loading branch information
Showing
6 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'''Check that positioning attributes for AST nodes (which Python | ||
ultimately uses for tracebacks) are set correctly.''' | ||
|
||
import ast | ||
from hy import read_many | ||
from hy.compiler import hy_compile | ||
|
||
|
||
def cpl(string): | ||
'''Compile the Hy `string` and get its final body element. A | ||
newline is prepended so that line 1 is guaranteed to be the wrong | ||
position for generated nodes.''' | ||
return hy_compile(read_many('\n' + string), __name__).body[-1] | ||
|
||
|
||
def test_do_mac(): | ||
# https://github.com/hylang/hy/issues/2424 | ||
x = cpl("(do-mac '9)") | ||
assert isinstance(x, ast.Expr) | ||
assert x.lineno == 2 | ||
|
||
|
||
def test_defmacro_raise(): | ||
# https://github.com/hylang/hy/issues/2424 | ||
x = cpl("(defmacro m [] '(do (raise)))\n(m)") | ||
assert isinstance(x, ast.Raise) | ||
assert x.lineno == 3 |