HS: sourceInfo (+4 tests)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 19:18:44 +00:00
parent cc2a296306
commit 8e2a633b7f
2 changed files with 60 additions and 4 deletions

View File

@@ -2467,13 +2467,28 @@
;; ── core/sourceInfo (4 tests) ──
(defsuite "hs-upstream-core/sourceInfo"
(deftest "debug"
(error "SKIP (untranslated): debug"))
(assert= (hs-src "<button.foo/>") "<button.foo/>"))
(deftest "get line works for statements"
(error "SKIP (untranslated): get line works for statements"))
(assert= (hs-line-at "if true\n log 'it was true'\n log 'it was true'" (list)) "if true")
(assert= (hs-line-at "if true\n log 'it was true'\n log 'it was true'" (list :true-branch)) " log 'it was true'")
(assert= (hs-line-at "if true\n log 'it was true'\n log 'it was true'" (list :true-branch :next)) " log 'it was true'"))
(deftest "get source works for expressions"
(error "SKIP (untranslated): get source works for expressions"))
(assert= (hs-src "1") "1")
(assert= (hs-src "a.b") "a.b")
(assert= (hs-src-at "a.b" (list :root)) "a")
(assert= (hs-src "a.b()") "a.b()")
(assert= (hs-src-at "a.b()" (list :root)) "a.b")
(assert= (hs-src-at "a.b()" (list :root :root)) "a")
(assert= (hs-src "<button.foo/>") "<button.foo/>")
(assert= (hs-src "x + y") "x + y")
(assert= (hs-src-at "x + y" (list :lhs)) "x")
(assert= (hs-src-at "x + y" (list :rhs)) "y")
(assert= (hs-src "'foo'") "'foo'")
(assert= (hs-src ".foo") ".foo")
(assert= (hs-src "#bar") "#bar"))
(deftest "get source works for statements"
(error "SKIP (untranslated): get source works for statements"))
(assert= (hs-src "if true log 'it was true'") "if true log 'it was true'")
(assert= (hs-src "for x in [1, 2, 3] log x then log x end") "for x in [1, 2, 3] log x then log x end"))
)
;; ── core/tokenizer (17 tests) ──