Brandon T. Willard
5d325a5156
Add a test for module docstrings
2018-08-27 01:02:29 -05:00
Brandon T. Willard
bbc66d0042
Add test for shadowed-basename imports
...
This test ensures that Hy will load a `.hy` instead of a `.py` counterpart.
2018-08-26 00:27:36 -05:00
Brandon T. Willard
1da29417fe
Add test for circular imports
...
Closes hylang/hy#1134 .
2018-08-26 00:27:36 -05:00
Brandon T. Willard
cbaba4a10a
Use Python cmdline file-relative sys.path
...
Closes hylang/hy#1457 .
2018-08-26 00:27:21 -05:00
Brandon T. Willard
c022abc831
Add Python cmdline bytecode option and set sys.executable
...
Closes hylang/hy#459 .
2018-08-26 00:17:12 -05:00
Brandon T. Willard
4839acadf7
Add tests for importing __main__.hy files
...
Closes hylang/hy#1466 .
2018-08-25 22:50:45 -05:00
Brandon T. Willard
e9e7171b56
Add module reloading tests
2018-08-25 22:50:45 -05:00
Brandon T. Willard
87a5b117a1
Implement new importer using PEP-302 semantics
...
Python 3.x is patched in a way that integrates `.hy` source files into
Pythons default `importlib` machinery. In Python 2.7, a PEP-302 "importer"
and "loader" is implemented according to the standard `import` logic (via
`pkgutil` and later pure-Python `imp` package code).
In both cases, the entry-point for the loaders is through `sys.path_hooks` only.
As well, the import semantics have been updated all throughout to utilize
`importlib` and follow aspects of PEP-420. This, along with some light
patches, should allow for basic use of `runpy`, `py_compile` and `reload`.
In all cases, if a `.hy` file is shadowed by a `.py`, Hy will silently use
`.hy`.
2018-08-25 22:50:38 -05:00
gilch
109c0b0f5b
Merge pull request #1664 from brandonwillard/require-in-macroexpand-all
...
Expand `require`d macros in `macroexpand-all`
2018-08-02 23:57:32 -06:00
Brandon T. Willard
65b2bd18ce
Add a test for require
in the body of a macro
2018-07-25 17:20:19 -05:00
Kodi Arfer
081a710b0f
Fix handling of unpacking in method calls and attribute lookups
2018-07-24 09:45:00 -07:00
Kodi Arfer
271f2846dc
Minor cleanup in test_ast
2018-07-24 09:37:19 -07:00
Kodi Arfer
1d2c73165d
Make HyKeyword callable
...
Co-authored-by: Simon Gomizelj <simon@vodik.xyz>
2018-07-24 09:19:37 -07:00
Kodi Arfer
03aafad657
Make empty expressions illegal at the top level
2018-07-24 08:59:52 -07:00
Kodi Arfer
9af738e56d
Add hy2py tests for empty data structures
2018-07-21 11:20:13 -07:00
gilch
0de8557fb5
Merge pull request #1647 from gilch/let-rebind
...
Fix let rebind bug.
2018-07-08 21:52:32 -06:00
Kodi Arfer
9c6714c176
Remove unused imports
2018-06-30 11:04:11 -07:00
gilch
8c79015b40
Fix let rebind bug.
2018-06-27 23:41:49 -06:00
gilch
9a8886a452
Proper special indent in let tests.
2018-06-27 23:38:06 -06:00
Kodi Arfer
7abd8ffc2a
Make importing a dotted name a syntax error, per Python
2018-06-27 10:24:22 -07:00
Oskar Kvist
edbe8e3b7f
Make defmacro! work with optional args
2018-06-25 11:45:23 -07:00
Kodi Arfer
14979edcab
Remove tests of the old comprehension forms
2018-06-13 17:31:08 -07:00
Kodi Arfer
cf0dafef9b
Update uses of the old comprehension forms
2018-06-13 17:31:08 -07:00
Kodi Arfer
df4e49ec94
Test comprehension scoping
2018-06-13 17:31:08 -07:00
Kodi Arfer
4754b152a9
Allow comprehensions with no looping parts
2018-06-13 17:31:08 -07:00
Kodi Arfer
e1972c535f
Remove for/a
, for*
, and for/a*
2018-06-13 17:31:08 -07:00
Kodi Arfer
3256932b13
Add a version of for
parallel to lfor
etc.
2018-06-13 17:31:08 -07:00
Kodi Arfer
ba1dc55e96
Implement lfor
, sfor
, gfor
, dfor
2018-06-13 17:31:08 -07:00
Kodi Arfer
d621d7c3ab
Update defmacro(/g)! tests for mangling
2018-06-11 21:05:29 -07:00
Kodi Arfer
65e620ed55
Remove an obsolete bug workaround in a test
2018-06-11 21:05:29 -07:00
gilch
29130212f0
Merge pull request #1631 from Kodiologist/py37-updates
...
Get Travis and Python 3.7 working again
2018-06-11 20:53:51 -06:00
Kodi Arfer
79bd4b019c
Merge pull request #1623 from Kodiologist/model-pattern-docs
...
Add tests and docs for model patterns
2018-06-11 16:35:02 -07:00
Kodi Arfer
16ec46a473
Update docstring handling for Python 3.7
...
See https://github.com/python/cpython/pull/7121 .
2018-06-05 17:35:48 -07:00
Kodi Arfer
74bf3e9e81
Work around a scoping bug in multi.defn ( #1630 )
2018-06-05 10:23:32 -07:00
Kodi Arfer
3204a9e8a3
Streamline auto-promotion and position spoofing
...
Auto-promotion now occurs in only two cases: when we start the compiler and when we expand a macro. It's fully recursive so even a non-model nested in a model will be promoted.
This change fixes some regressions induced by the stricter type checks of the pattern-matching compiler.
2018-06-05 09:23:21 -07:00
Kodi Arfer
a38c948ed2
Fix a regression with mangling module names
2018-06-03 15:38:49 -07:00
Kodi Arfer
6458f2d66f
Re-enable tests that were stymied by an astor bug
2018-05-29 09:18:42 -07:00
Kodi Arfer
8296a36e12
Add tests and docs for model patterns
2018-05-28 16:15:47 -07:00
Kodi Arfer
9f454f0228
Test complex numbers in test_hy2py
2018-05-20 14:11:35 -07:00
Kodi Arfer
906b470499
Move test assertions into a test function
2018-05-20 14:11:35 -07:00
Kodi Arfer
210086c7ca
Clean up the decorators used in the compiler
2018-05-20 14:11:35 -07:00
Kodi Arfer
57b5fa49b1
Unify illegal special forms
2018-05-20 14:11:31 -07:00
Kodi Arfer
45e8783997
Use model patterns for fn
2018-05-20 14:07:44 -07:00
Kodi Arfer
9368e4bc4e
Use model patterns for import
and require
...
In the process, I've banned the syntax `(import [foo])` in favor of `(import foo)`.
2018-05-20 14:07:44 -07:00
Kodi Arfer
79c02514b9
Introduce the use of model patterns
2018-05-20 14:07:44 -07:00
Philip Xu
8a83d0c1ea
Fixes #1605 : remove macros ap-pipe and ap-compose
...
Anaphoric macros do not work well with point-free style programming, in
which case both threading macros and `comp` are more adequate.
2018-05-20 13:52:51 -07:00
gilch
049c78f5d5
Fix bug in let's handle-dot.
2018-05-18 10:40:59 -07:00
Kodi Arfer
a2aeca2338
Remove tuple unpacking in lambda lists
2018-05-04 10:40:22 -07:00
Simon Gomizelj
7c3477e738
Fix a bug where the compiler doesn't properly handle unquote-splice
...
Added test coverage as well
2018-04-30 09:38:57 -07:00
Kodi Arfer
c7ac4c60c4
Fix a bug that caused try
to drop expressions
2018-04-30 09:18:01 -07:00
Kodi Arfer
ec1c92bf4e
Allow for
with an empty body
2018-04-29 19:51:00 -07:00
Kodi Arfer
b7e5c5f17a
Allow while
with an empty body
2018-04-29 19:51:00 -07:00
Kodi Arfer
a8fe95c5b6
Update test_preprocessor_exceptions
...
This test has been passing since b023ebd0b5
, so I removed the xfail. I also rewrote the test to use pytest.raises.
2018-04-29 19:29:17 -07:00
Kodi Arfer
87aced2370
Don't let HyExpression etc. inherit from HyList
...
This means the compiler no longer allows e.g. `(fn (x) ...)` in place of `(fn [x] ...)`.
2018-04-29 19:17:47 -07:00
Simon Gomizelj
032247e380
Merge pull request #1588 from Kodiologist/no-amp-key
...
Remove &key
2018-04-27 00:21:11 -04:00
Ryan Gonzalez
fbeff8d25c
Merge pull request #1587 from Kodiologist/no-empty-catchers
...
Ban `(except)`
2018-04-23 21:50:56 -05:00
Kodi Arfer
c1a487cdf7
Move logic from macroexpand_1 to macroexpand
...
By ending macro-expansion immediately when appropriate, this change fixes a bug arising from the fact that NaN != NaN.
2018-04-21 12:25:29 -07:00
Kodi Arfer
4a6b633ad2
Add some missing imports
2018-04-21 12:25:29 -07:00
Kodi Arfer
a605936651
Remove &key
...
It's redundant with &optional.
2018-04-19 09:26:02 -07:00
Kodi Arfer
7bf2901364
Ban (except)
...
It's rarely useful, because it catches all exceptions, but it doesn't let you do anything other than return `None`. You can still get the same effect with `(except [])`.
2018-04-16 19:34:50 -07:00
Simon Gomizelj
fa54884131
Fix unit tests when run with PYTHONDONTWRITEBYTECODE
...
When set, it will conflict with any tests that generate bytecode
because they don't expect it to be set.
Fixable by sanitize the environment before forking, but we can't do
anything about import tests.
This is a pipenv default, and possibly a sane flag to set while doing
Hy development, so lets not let it be a hazard for developers to trip
over.
2018-04-14 12:12:01 -07:00
Kodi Arfer
097647bf6f
Remove tests of cons cells
2018-04-12 16:45:17 -07:00
Kodi Arfer
f332ad2eae
Improve testing of hy2py
...
Instead of just checking that hy2py outputs a nonempty string and doesn't crash, we check that a hy2py-generated Python program works the same as the original Hy program.
This test suggests my plan to make hy2py output real Python has succeeded, so I updated NEWS accordingly.
2018-04-08 15:35:57 -07:00
Simon Gomizelj
291847af15
Make HyKeyword constructor consistent
...
The colon is now only part of its string representation and no longer
accepted as part of the constructor:
:foobar == HyKeyword("foobar")
2018-04-07 22:29:20 -07:00
Simon Gomizelj
1b7dfd2839
Make HyKeyword a first class objects
...
HyKeywords are no longer an instances of string with a particular
prefix, but a completely separate object.
This means keywords no longer trip isinstance str checks, adding a
little bit of type safety to the compiler.
It also means that HyKeywords evaluate to themselves.
Closes #1352
2018-04-07 22:29:20 -07:00
Yigong Wang
564c030950
Raise LexException when codec can't decode some bytes
2018-04-07 11:47:06 -07:00
Simon Gomizelj
4d98cde663
Merge pull request #1560 from waigx/feat/results-shortcuts
...
Add recent REPL results globals *i and most recent error *e
2018-04-04 19:27:35 -04:00
gilch
be06741e03
Fix indent
2018-04-04 12:04:34 -06:00
Kodi Arfer
f17a21be63
Use X
as the mangle delimiter on Python 3
2018-04-04 10:50:33 -07:00
Yigong Wang
be8537c0cf
Add recent REPL results globals *i and most recent error *e
...
This comment add *1, *2, *3 as globals for recent REPL results.
*e global is also added for the most recent error object.
2018-04-02 00:21:13 -04:00
Yigong Wang
4073c78069
Add -E support for Hy REPL
...
This commit adds -E support for Hy. Similar to Python, hy will ignore
all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME,
that might be set.
2018-03-31 15:16:40 -07:00
Simon Gomizelj
b27cdfed69
Fix defclass
construction
...
Python Class AST expects a body which is a list of ast.Expr. Force
every entry to be stored as a statement. This means we'll preserve
print statements.
Python also doesn't construct docstrings in classes by setting a
__doc__ attribute, it does it by inspecting the first ast.Expr node of
the class. But this means we can remove the special handler for it.
2018-03-31 02:43:53 -04:00
Simon Gomizelj
84e1c65bcd
Improve checks inside defclass
...
We need to make sure we're looking at HyExpression when trying to
determine if we're rewriting an __init__ expression.
Fixes #1533
2018-03-31 02:43:53 -04:00
Kodi Arfer
268eba93fe
Update a disassembly test for Python 3.7
2018-03-24 12:34:43 -07:00
Kodi Arfer
cf60dc7a13
Fix a hy-repr test for Python 3.7
2018-03-24 12:34:43 -07:00
Kodi Arfer
e3058b5cf5
Handle module docstrings on Python 3.7
2018-03-24 12:34:43 -07:00
Kodi Arfer
cfb042304c
Test module docstrings
2018-03-24 12:34:43 -07:00
Kodi Arfer
ad59fd7ff6
In -> and ->>, don't modify the arguments
2018-03-23 13:57:19 -07:00
Simon Gomizelj
c663d38e33
Add metaclass support, support PEP 3115 and PEP 487
2018-03-22 13:28:22 -07:00
Simon Gomizelj
75af667fa1
Fix test_hy2py not respecting 'only_py36'
2018-03-22 13:27:56 -07:00
Tuukka Turto
cb72a8c155
Merge pull request #1530 from vodik/pytest-cleanups
...
Use pytest.raises for asserting compiler exceptions
2018-03-15 08:14:09 +02:00
Kodi Arfer
3c97d2982c
Use *1
instead of _
for REPL history
...
`_`, as a variable, is now the shadow subtraction operator.
2018-03-13 14:56:47 -04:00
Kodi Arfer
85968e70dd
Add mangle
and unmangle
as core functions
2018-03-13 14:55:55 -04:00
Kodi Arfer
ebc9bda7ee
Remove an obsolete test
2018-03-13 14:55:55 -04:00
Kodi Arfer
0c8c5dc830
Mangle special forms
2018-03-13 14:55:55 -04:00
Kodi Arfer
ccb3ba6092
Mangle macro names
2018-03-13 14:55:55 -04:00
Kodi Arfer
0c816f2e83
Mangle keyword arguments
2018-03-13 14:55:55 -04:00
Kodi Arfer
d252bb0e94
Mangle names that coincide with Python keywords
2018-03-13 14:55:55 -04:00
Kodi Arfer
52edad28e2
Overhaul mangling rules
2018-03-13 14:55:53 -04:00
Kodi Arfer
d501d4d806
Mangle symbols at compile-time instead of parse-time
...
This means that a HySymbol remembers its original name. That is, `a-b` and `a_b` are different symbols although `(setv a-b 1)` and `(setv a_b 1)` set the same variable (namely, `a_b`).
Most of the edits in this commit are to switch underscores to hyphens in places where mangling hasn't happened yet.
I removed some lexer tests since the lexer no longer does any mangling.
2018-03-13 14:55:15 -04:00
Kodi Arfer
7fcc7ac4b6
Make unary comparison ops evaluate their argument
2018-03-13 14:38:36 -04:00
Kodi Arfer
9f0911161d
Fix tests with =
-and-parentheses errors
2018-03-13 14:38:36 -04:00
Simon Gomizelj
e3f4fc8481
Use pytest.raises for asserting compiler exceptions
2018-03-12 01:44:57 -04:00
Kodi Arfer
0574e275b5
Make hy-repr support some collections
classes
2018-03-10 18:11:07 -08:00
Kodi Arfer
38f461890d
Make hy-repr support DateTime objects
2018-03-10 18:11:07 -08:00
Kodi Arfer
3dbe05302e
Make hy-repr support regex match objects
2018-03-10 18:11:07 -08:00
Kodi Arfer
f7ab9a6e7c
Make hy-repr support dictionary views
2018-03-10 18:11:07 -08:00
Kodi Arfer
90a09b5b44
Make hy-repr use double spaces for dictionaries
2018-03-10 18:11:07 -08:00
Kodi Arfer
199bb70150
Add a hy-repr test for keyword-like bytes objects
2018-03-10 18:11:07 -08:00
Kodi Arfer
4f2706e18e
Test a case where hy-repr shouldn't round-trip
2018-03-10 18:11:07 -08:00