Move hy.core.reserved to hy.extra.reserved (#1231)

It was an odd one out by being in hy.core but needing to be called by a qualified name. It's at home in hy.extra.
This commit is contained in:
Kodi Arfer 2017-03-02 14:49:32 -08:00 committed by Ryan Gonzalez
parent ebfa636b50
commit 484daafa53
8 changed files with 35 additions and 37 deletions

1
NEWS
View File

@ -9,6 +9,7 @@ Changes from 0.12.1
* Commas and underscores are allowed in numeric literals
* with-decorator: Allow a `setv` form as the form to be decorated
* xor: If exactly one argument is true, return it
* hy.core.reserved is now hy.extra.reserved
[ Bug Fixes ]
* Shadowed comparison operators now use `and` instead of `&`

View File

@ -12,3 +12,4 @@ Contents:
:maxdepth: 3
anaphoric
reserved

19
docs/extra/reserved.rst Normal file
View File

@ -0,0 +1,19 @@
==============
Reserved Names
==============
names
=====
Usage: ``(names)``
This function can be used to get a list (actually, a ``frozenset``) of the
names of Hy's built-in functions, macros, and special forms. The output
also includes all Python reserved words. All names are in unmangled form
(e.g., ``list-comp`` rather than ``list_comp``).
.. code-block:: hy
=> (import hy.extra.reserved)
=> (in "defclass" (hy.extra.reserved.names))
True

View File

@ -1352,27 +1352,6 @@ Returns an iterator from *coll* as long as *pred* returns ``True``.
=> (list (take-while neg? [ 1 2 3 -4 5]))
[]
Other Built-Ins
===============
hy.core.reserved
----------------
Usage: ``(hy.core.reserved.names)``
This module can be used to get a list (actually, a ``frozenset``) of the
names of Hy's built-in functions, macros, and special forms. The output
also includes all Python reserved words. All names are in unmangled form
(e.g., ``list-comp`` rather than ``list_comp``).
.. code-block:: hy
=> (import hy)
=> (in "defclass" (hy.core.reserved.names))
True
Included itertools
==================

View File

@ -1,5 +1,3 @@
from . import reserved # noqa
STDLIB = [
"hy.core.language",
"hy.core.shadow"

View File

@ -621,20 +621,6 @@
(assert-equal (list (accumulate [1 -2 -3 -4 -5] -))
[1 3 6 10 15]))
(defn test-reserved []
(import [hy.core.reserved [names]])
(assert (is (type (names)) frozenset))
(assert (in "and" (names)))
(when PY3
(assert (in "False" (names))))
(assert (in "pass" (names)))
(assert (in "class" (names)))
(assert (in "defclass" (names)))
(assert (in "->" (names)))
(assert (in "keyword?" (names)))
(assert (not-in "foo" (names)))
(assert (not-in "hy" (names))))
(defn test-complement []
"NATIVE: test complement"
(def helper (complement identity))

View File

@ -0,0 +1,14 @@
(import [hy.extra.reserved [names] hy._compat [PY3]])
(defn test-reserved []
(assert (is (type (names)) frozenset))
(assert (in "and" (names)))
(when PY3
(assert (in "False" (names))))
(assert (in "pass" (names)))
(assert (in "class" (names)))
(assert (in "defclass" (names)))
(assert (in "->" (names)))
(assert (in "keyword?" (names)))
(assert (not-in "foo" (names)))
(assert (not-in "hy" (names))))