emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/haskell-tng-mode b59ce04 356/385: improve testing


From: ELPA Syncer
Subject: [nongnu] elpa/haskell-tng-mode b59ce04 356/385: improve testing
Date: Wed, 6 Oct 2021 00:00:03 -0400 (EDT)

branch: elpa/haskell-tng-mode
commit b59ce04ccde383df86776fd59ec6e89755e359b3
Author: Tseen She <ts33n.sh3@gmail.com>
Commit: Tseen She <ts33n.sh3@gmail.com>

    improve testing
---
 Cask                             | 15 +++++++-------
 haskell-tng-extra-company.el     | 10 +++++++---
 haskell-tng-hsinspect.el         | 16 +++++++++++++--
 test/haskell-tng-dynamic-test.el |  9 +++++----
 test/src/hsinspect.hs            | 32 +++++++++++++++++++-----------
 test/src/hsinspect.hs.dynamic    | 42 ++++++++++++++++++++++++++--------------
 6 files changed, 83 insertions(+), 41 deletions(-)

diff --git a/Cask b/Cask
index 8861f08..2bcba39 100644
--- a/Cask
+++ b/Cask
@@ -27,15 +27,16 @@
 (package-file "haskell-tng-mode.el")
 
 (development
- (depends-on "company")
- (depends-on "popup")
+ (depends-on "company" "0.9.12")
+ (depends-on "popup") ;; version defined in -pkg.el
  ;;(depends-on "elsa") ;; cask exec elsa FILE
- (depends-on "faceup")
- (depends-on "ert-runner")
+ (depends-on "faceup") ;; no stable release
+ (depends-on "ert-runner" "0.7.0")
+ (depends-on "shut-up" "0.3.2")
  ;; FIXME set up coverage
  ;;(depends-on "undercover")
- (depends-on "projectile")
- (depends-on "smartparens")
- (depends-on "yasnippet"))
+ (depends-on "projectile" "2.1.0")
+ (depends-on "smartparens" "1.11.0")
+ (depends-on "yasnippet" "0.14.0"))
 
 ;;; Cask ends here
diff --git a/haskell-tng-extra-company.el b/haskell-tng-extra-company.el
index 5051b13..23e742b 100644
--- a/haskell-tng-extra-company.el
+++ b/haskell-tng-extra-company.el
@@ -70,11 +70,15 @@
  'company-keywords-alist
  `(haskell-tng-mode ,@haskell-tng--keywords))
 
+(defun haskell-tng-extra-company-hook ()
+  "Enable `company-mode' with `haskell-tng' backends for buffer"
+  (interactive)
+  (setq-local company-backends haskell-tng-company-backends)
+  (company-mode 1))
+
 (add-hook
  'haskell-tng-mode-hook
- (lambda ()
-   (setq-local company-backends haskell-tng-company-backends)
-   (company-mode 1)))
+ #'haskell-tng-extra-company-hook)
 
 (provide 'haskell-tng-extra-company)
 ;;; haskell-tng-extra-company.el ends here
diff --git a/haskell-tng-hsinspect.el b/haskell-tng-hsinspect.el
index a44f422..4120a35 100644
--- a/haskell-tng-hsinspect.el
+++ b/haskell-tng-hsinspect.el
@@ -46,7 +46,7 @@ A prefix argument ensures that caches are flushes."
                     sym)))
       ;; TODO multiple hits
       ;; TODO add type information from the index when available
-      (popup-tip (format "%s" found)))
+      (haskell-tng--hsinspect-popup-tip (format "%s" found)))
   (user-error "Not found"))
 
 ;;;###autoload
@@ -343,9 +343,21 @@ ability to follow any further."
     ;; TODO special case one hit
     ;; TODO show more context, like the type
     (when-let* ((entries (mapcar (lambda (el) (alist-get 'module el)) hits))
-                (selected (popup-menu* entries)))
+                (selected (haskell-tng--hsinspect-popup-menu entries)))
       (seq-find (lambda (el) (equal (alist-get 'module el) selected)) hits))))
 
+(defvar-local haskell-tng--hsinspect-popup-menu nil)
+(defun haskell-tng--hsinspect-popup-menu (entries)
+  (or
+   haskell-tng--hsinspect-popup-menu ;; testing feature
+   (popup-menu* entries)))
+
+(defvar-local haskell-tng--hsinspect-popup-tip nil)
+(defun haskell-tng--hsinspect-popup-tip (tip)
+  (if haskell-tng--hsinspect-popup-tip ;; testing feature
+      tip
+    (popup-tip tip)))
+
 ;; TODO when the same name is reused as a type and data constructor we show 
dupe
 ;; entries to the user. We should dedupe that to just the cons unless we have a
 ;; way to make the choice clearer.
diff --git a/test/haskell-tng-dynamic-test.el b/test/haskell-tng-dynamic-test.el
index 8da74d3..80a141c 100644
--- a/test/haskell-tng-dynamic-test.el
+++ b/test/haskell-tng-dynamic-test.el
@@ -13,6 +13,7 @@
 
 (require 'ert)
 (require 's)
+(require 'shut-up)
 
 (require 'haskell-tng-mode)
 
@@ -34,10 +35,10 @@
 
   (while (re-search-forward (rx word-start "RUN" word-end) nil t)
     (when (is-comment-at-point)
-      (let ((start (point))
-            (command (read (current-buffer))))
-        (eval command)
-        (goto-char start))))
+      (push-mark (point) t)
+      (shut-up
+       (eval (read (current-buffer))))
+      (pop-mark)))
   (buffer-substring-no-properties (point-min) (point-max)))
 
 (provide 'haskell-tng-dynamic-test)
diff --git a/test/src/hsinspect.hs b/test/src/hsinspect.hs
index 906f760..f722aa2 100644
--- a/test/src/hsinspect.hs
+++ b/test/src/hsinspect.hs
@@ -1,29 +1,39 @@
+-- RUN (require 'haskell-tng-hsinspect)
+-- RUN (setq haskell-tng--hsinspect-popup-tip t)
+-- RUN (require 'haskell-tng-extra-company)
+-- RUN (haskell-tng-extra-company-hook)
 -- RUN (setq haskell-tng--hsinspect-imports (haskell-tng--util-read 
"test/data/hsinspect-0.0.8-imports.sexp.gz"))
---
 -- RUN (setq haskell-tng--hsinspect-index (haskell-tng--util-read 
"test/data/hsinspect-0.0.9-index.sexp.gz"))
+
 module Medley.Wibble where
 
 import Data.Functor.Contravariant as C
 import Medley.Wobble
+-- FIXME (progn (next-line) (move-to-column 18) (let ((fqn 
(haskell-tng-fqn-at-point))) (next-line) (insert (concat "-- " fqn))))
 import Prelude (zip)
 
--- FIXME commands
--- COMPLETE 11
+-- RUN (progn (next-line) (company-complete))
 foo = C.pha
 
--- COMPLETE 9
+-- RUN (progn (next-line) (company-complete))
 bar = wob
 
--- IMPORT 9 "Data.List"
+-- RUN (progn (next-line) (move-to-column 9) (let 
((haskell-tng--hsinspect-popup-menu "Data.List")) 
(haskell-tng-import-symbol-at-point)))
 baz = nubBy bar zipped
 
--- IMPORT- 9 "Data.List"
+-- RUN (progn (next-line) (move-to-column 9) (let 
((haskell-tng--hsinspect-popup-menu "Data.List")) 
(haskell-tng-import-symbol-at-point '-)))
 bag = nubBy bag' zipped
-  -- COMPLETE 21
-  where bag' = L.part
+  where
+    -- RUN (progn (next-line) (company-complete))
+    bag' = L.part
 
--- IMPORT 11
+-- RUN (progn (next-line) (move-to-column 11) (let 
((haskell-tng--hsinspect-popup-menu "Data.List.NonEmpty")) 
(haskell-tng-import-symbol-at-point)))
 zaz = NEL.fromList bag
 
--- JUMP 17 "base/4.13.0.0/base-4.13.0.0.tar.gz" "GHC/List.hs"
-zipped = [1,2,3] zip "abc"
+-- RUN (progn (next-line) (move-to-column 20) (let ((this-buffer 
(current-buffer))) (haskell-tng-jump-to-definition) (kill-ring-save 
(line-beginning-position) (line-end-position)) (kill-append (concat "\n-- " 
(buffer-name)) nil) (switch-to-buffer this-buffer) (next-line) (insert "-- ") 
(yank)))
+zipped = [1, 2, 3] zip "abc"
+
+
+-- Local Variables:
+--   haskell-tng--compile-command: "cd ../.. && cask exec ert-runner 
test/haskell-tng-dynamic-test.el"
+-- End:
diff --git a/test/src/hsinspect.hs.dynamic b/test/src/hsinspect.hs.dynamic
index 906f760..1e14db1 100644
--- a/test/src/hsinspect.hs.dynamic
+++ b/test/src/hsinspect.hs.dynamic
@@ -1,29 +1,43 @@
+-- RUN (require 'haskell-tng-hsinspect)
+-- RUN (setq haskell-tng--hsinspect-popup-tip t)
+-- RUN (require 'haskell-tng-extra-company)
+-- RUN (haskell-tng-extra-company-hook)
 -- RUN (setq haskell-tng--hsinspect-imports (haskell-tng--util-read 
"test/data/hsinspect-0.0.8-imports.sexp.gz"))
---
 -- RUN (setq haskell-tng--hsinspect-index (haskell-tng--util-read 
"test/data/hsinspect-0.0.9-index.sexp.gz"))
+
 module Medley.Wibble where
 
+import qualified Data.List.NonEmpty as NEL
+import qualified Data.List as L
+import Data.List (nubBy)
 import Data.Functor.Contravariant as C
 import Medley.Wobble
+-- FIXME (progn (next-line) (move-to-column 18) (let ((fqn 
(haskell-tng-fqn-at-point))) (next-line) (insert (concat "-- " fqn))))
 import Prelude (zip)
 
--- FIXME commands
--- COMPLETE 11
-foo = C.pha
+-- RUN (progn (next-line) (company-complete))
+foo = C.phantom
 
--- COMPLETE 9
-bar = wob
+-- RUN (progn (next-line) (company-complete))
+bar = wobble
 
--- IMPORT 9 "Data.List"
+-- RUN (progn (next-line) (move-to-column 9) (let 
((haskell-tng--hsinspect-popup-menu "Data.List")) 
(haskell-tng-import-symbol-at-point)))
 baz = nubBy bar zipped
 
--- IMPORT- 9 "Data.List"
-bag = nubBy bag' zipped
-  -- COMPLETE 21
-  where bag' = L.part
+-- RUN (progn (next-line) (move-to-column 9) (let 
((haskell-tng--hsinspect-popup-menu "Data.List")) 
(haskell-tng-import-symbol-at-point '-)))
+bag = L.nubBy bag' zipped
+  where
+    -- RUN (progn (next-line) (company-complete))
+    bag' = L.partition
 
--- IMPORT 11
+-- RUN (progn (next-line) (move-to-column 11) (let 
((haskell-tng--hsinspect-popup-menu "Data.List.NonEmpty")) 
(haskell-tng-import-symbol-at-point)))
 zaz = NEL.fromList bag
 
--- JUMP 17 "base/4.13.0.0/base-4.13.0.0.tar.gz" "GHC/List.hs"
-zipped = [1,2,3] zip "abc"
+-- RUN (progn (next-line) (move-to-column 20) (let ((this-buffer 
(current-buffer))) (haskell-tng-jump-to-definition) (kill-ring-save 
(line-beginning-position) (line-end-position)) (kill-append (concat "\n-- " 
(buffer-name)) nil) (switch-to-buffer this-buffer) (next-line) (insert "-- ") 
(yank)))
+zipped = [1, 2, 3] zip "abc"
+-- zip :: [a] -> [b] -> [(a,b)]
+-- List.hs (base-4.12.0.0.tar.gz)
+
+-- Local Variables:
+--   haskell-tng--compile-command: "cd ../.. && cask exec ert-runner 
test/haskell-tng-dynamic-test.el"
+-- End:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]