File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 764
764
Use ``require`` to make other macros available.
765
765
766
766
Use ``(help foo)`` instead for help with runtime objects."
767
- `(help (.get __macros__ (mangle '~symbol) None )))
767
+ (setv symbol (str symbol))
768
+ (setv mangled (mangle symbol))
769
+ (setv builtins (gensym " builtins" ))
770
+ `(do (import [builtins :as ~builtins])
771
+ (help (or (.get __macros__ ~mangled)
772
+ (.get (. ~builtins __macros__ ) ~mangled)
773
+ (raise (NameError f" macro {~symbol !r} is not defined" ))))))
768
774
769
775
770
776
(defmacro cfor [f #* generator]
Original file line number Diff line number Diff line change 4
4
5
5
;;;; some simple helpers
6
6
7
+ (import pytest)
8
+
7
9
(defn assert-true [x]
8
10
(assert (= True x)))
9
11
@@ -699,6 +701,17 @@ result['y in globals'] = 'y' in globals()")
699
701
<p> Move along. (Nothing to see here.)</p>)))
700
702
701
703
(defn test-doc [capsys]
704
+ ;; https://github.com/hylang/hy/issues/1970
705
+ ;; Let's first make sure we can doc the builtin macros
706
+ ;; before we create the user macros.
707
+ (doc doc)
708
+ (setv [out err] (.readouterr capsys))
709
+ (assert (in " Gets help for a macro function" out))
710
+
711
+ (doc " #@" )
712
+ (setv [out err] (.readouterr capsys))
713
+ (assert (in " with-decorator tag macro" out))
714
+
702
715
(defmacro <-mangle-> []
703
716
" a fancy docstring"
704
717
'(+ 2 2 ))
@@ -716,7 +729,12 @@ result['y in globals'] = 'y' in globals()")
716
729
(doc " #pillgrums" )
717
730
(setv [out err] (.readouterr capsys))
718
731
(assert (in " Look at the quality of that picture!" out))
719
- (assert (empty? err)))
732
+ (assert (empty? err))
733
+
734
+ ;; make sure doc raises an error instead of
735
+ ;; presenting a default value help screen
736
+ (with [(pytest.raises NameError)]
737
+ (doc does-not-exist)))
720
738
721
739
722
740
(defn test-do-n []
You can’t perform that action at this time.
0 commit comments