Function: projectile-test-at-point-fsharp-name

projectile-test-at-point-fsharp-name is a byte-compiled function defined in projectile.el.

Signature

(projectile-test-at-point-fsharp-name NODE)

Documentation

Return the test name for the F# function_or_value_defn\= NODE.

Return nil unless the binding carries a test attribute - xUnit's
[<Fact>]\= or [<Theory>]\=, NUnit's [<Test>]\= or FsCheck's
[<Property>]\=. The attributes are a sibling of the definition under
its enclosing declaration_expression\=, not a child of it.

A name written between double backticks - which is how F# tests usually get readable names - is returned without them, since that is what the test framework sees.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-test-at-point-fsharp-name (node)
  "Return the test name for the F# `function_or_value_defn\\=' NODE.

Return nil unless the binding carries a test attribute - xUnit\\='s
`[<Fact>]\\=' or `[<Theory>]\\=', NUnit\\='s `[<Test>]\\=' or FsCheck\\='s
`[<Property>]\\='.  The attributes are a sibling of the definition under
its enclosing `declaration_expression\\=', not a child of it.

A name written between double backticks - which is how F# tests usually
get readable names - is returned without them, since that is what the
test framework sees."
  (when-let* ((parent (treesit-node-parent node))
              ;; `attributes' is a positional child of the enclosing
              ;; `declaration_expression', not a field of it.
              (attributes
               (seq-find (lambda (child)
                           (equal (treesit-node-type child) "attributes"))
                         (treesit-node-children parent t))))
    (when (projectile--test-at-point-annotated-p
           (treesit-node-text attributes t)
           '("Fact" "Theory" "Test" "TestCase" "Property"))
      (when-let* ((left (treesit-node-child node 0 t))
                  (name (treesit-node-text (treesit-node-child left 0 t) t)))
        (if (and (string-prefix-p "``" name) (string-suffix-p "``" name))
            (substring name 2 -2)
          name)))))