     ;; with-help-window is a macro and macrolet and labels don't seem to work.
     (stub-fn help-window-setup win
       (fsharp-ac/show-tooltip-at-point)
-      (fsharp-ac-filter-output nil (format-output "DATA: tooltip" "foo"))
+      (fsharp-ac-filter-output nil tooltip-msg)
       (should-match "fsharp info" (buffer-name (window-buffer win))))))
 
 (check-handler "displays typesig in minibuffer if typesig is requested"
   (stub-fn message sig
     (fsharp-ac/show-typesig-at-point)
-    (fsharp-ac-filter-output nil (format-output "DATA: tooltip" "foo"))
+    (fsharp-ac-filter-output nil tooltip-msg)
     (should= "foo" sig)))

     (flet ((,sym (x &rest xs) (setq ,var x)))
       ,@body)))

(defun format-output (header &optional content)
  (concat header "\n" content
          fsharp-ac-eom))

(check-handler "prints message on error"
  (stub-fn message err
    (fsharp-ac-filter-output nil (format-output "ERROR: foo"))
    (should-match "foo" err)))

(check-handler "does not print message on type information error"
  (stub-fn message called
    (fsharp-ac-filter-output nil (format-output "ERROR: could not get type information"))
    (should-not called)))

;;; Tooltips and typesigs

(check-handler "uses popup in terminal if tooltip is requested"
  (let ((fsharp-ac-use-popup t))
    (flet ((display-graphic-p () nil))
      (stub-fn popup-tip tip
        (fsharp-ac/show-tooltip-at-point)
        (fsharp-ac-filter-output nil (format-output "DATA: tooltip" "foo"))
        (should-match "foo" tip)))))

(check-handler "uses pos-tip in GUI if tooltip is requested"

    (should (equal text
                   (concat "Possible incorrect indentation: "
                           "this token is offside of context started at "
                           "position (8:1)."
                           "\nTry indenting this token further or using standard "
                           "formatting conventions.")))))

