 ;;; Error parsing
 
 (defconst err-brace-str
-  (mapconcat
-     'identity
-     '("DATA: errors"
-       "[9:0-9:2] WARNING Possible incorrect indentation: this token is offside of context started at position (2:16)."
-       "Try indenting this token further or using standard formatting conventions."
-       "[11:0-11:2] ERROR Unexpected symbol '[<' in expression"
-       "Followed by more stuff on this line"
-       "[12:0-12:3] WARNING Possible incorrect indentation: this token is offside of context started at position (2:16).
-Try indenting this token further or using standard formatting conventions."
-       "<<EOF>>"
-       "")
-     "\n")
+  "{\"Kind\":\"errors\",\"Data\":[{\"FileName\":\"/Users/robnea/dev/rneatherway-fsharpbinding/FSharp.AutoComplete/test/integration/Test1Json/Program.fs\",\"StartLine\":11,\"EndLine\":11,\"StartColumn\":0,\"EndColumn\":2,\"Severity\":\"Warning\",\"Message\":\"Possible incorrect indentation: this token is offside of context started at position (8:1). Try indenting this token further or using standard formatting conventions.\",\"Subcategory\":\"parse\"},{\"FileName\":\"/Users/robnea/dev/rneatherway-fsharpbinding/FSharp.AutoComplete/test/integration/Test1Json/Program.fs\",\"StartLine\":11,\"EndLine\":11,\"StartColumn\":0,\"EndColumn\":2,\"Severity\":\"Error\",\"Message\":\"Unexpected symbol '[<' in expression\",\"Subcategory\":\"parse\"},{\"FileName\":\"/Users/robnea/dev/rneatherway-fsharpbinding/FSharp.AutoComplete/test/integration/Test1Json/Program.fs\",\"StartLine\":12,\"EndLine\":12,\"StartColumn\":0,\"EndColumn\":3,\"Severity\":\"Warning\",\"Message\":\"Possible incorrect indentation: this token is offside of context started at position (8:1). Try indenting this token further or using standard formatting conventions.\",\"Subcategory\":\"parse\"}]}"
   "A list of errors containing a square bracket to check the parsing")
 
 (check "parses errors from given string"

     (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"

    (flet ((display-graphic-p () t))
      (stub-fn pos-tip-show tip
        (fsharp-ac/show-tooltip-at-point)
        (fsharp-ac-filter-output nil tooltip-msg)
        (should-match "foo" tip)))))

(check-handler "does not show popup if typesig is requested"
  (let ((fsharp-ac-use-popup t))
    (stub-fn popup-tip called
      (fsharp-ac/show-typesig-at-point)
      (fsharp-ac-filter-output nil tooltip-msg)
      (should-not called))))

(check-handler "does not show popup if use-popup is nil"
  (let ((fsharp-ac-use-popup nil))
    (stub-fn popup-tip called
      (fsharp-ac/show-tooltip-at-point)
      (fsharp-ac-filter-output nil tooltip-msg)
      (should-not called))))

(check-handler "displays tooltip in info window if use-popup is nil"
