;; AUTO-GENERATED from spec/tests/hyperscript-upstream-tests.json
;; DO NOT EDIT — regenerate with:
;;   python3 tests/playwright/generate-sx-tests.py --emit-pages

(defcomp ()
  (~docs/page :title "Hyperscript: if (19 tests — 18 runnable)"
    (p :style "color:#57534e;margin-bottom:1rem" "Live cards for the upstream if tests. 18 of 19 are reproducible in-browser; the remainder show their source for reference.")
    (p :style "color:#78716c;font-size:0.875rem;margin-bottom:1rem"
      "Theme: " (a :href "/sx/(applications.(hyperscript.gallery-control))"
        :style "color:#7c3aed" "control"))
    (div :style "display:flex;flex-direction:column"
      (~hyperscript/hs-test-card
  :name "basic true branch works"
  :html "<div _='on click if true put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if true put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic true branch works with multiple commands"
  :html "<div _='on click if true log me then                                   put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if true log me then put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic true branch works with end"
  :html "<div _='on click if true put \"foo\" into me.innerHTML end'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if true put \\\"foo\\\" into me.innerHTML end\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic true branch works with naked else"
  :html "<div _='on click if true put \"foo\" into me.innerHTML else'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if true put \\\"foo\\\" into me.innerHTML else\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic true branch works with naked else end"
  :html "<div _='on click if true put \"foo\" into me.innerHTML else end'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if true put \\\"foo\\\" into me.innerHTML else end\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic else branch works"
  :html "<div _='on click if false else put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic else branch works with end"
  :html "<div _='on click if false else put \"foo\" into me.innerHTML end'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else put \\\"foo\\\" into me.innerHTML end\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic else if branch works"
  :html "<div _='on click if false else if true put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else if true put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic else if branch works with end"
  :html "<div _='on click if false                                   else if true put \"foo\" into me.innerHTML end'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else if true put \\\"foo\\\" into me.innerHTML end\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "otherwise alias works"
  :html "<div _='on click if false otherwise put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false otherwise put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "triple else if branch works"
  :html "<div _='on click if false else if false else put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else if false else put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "triple else if branch works with end"
  :html "<div _='on click if false                                   else if false                                  else put \"foo\" into me.innerHTML end'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else if false else put \\\"foo\\\" into me.innerHTML end\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "basic else branch works with multiple commands"
  :html "<div _='on click if false put \"bar\" into me.innerHTML                                  else log me then                                       put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false put \\\"bar\\\" into me.innerHTML else log me then put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "true branch with a wait works"
  :html "<div _='on click if true wait 10 ms then put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"\") && d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if true wait 10 ms then put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "false branch with a wait works"
  :html "<div _='on click if false else wait 10 ms then put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"\") && d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false else wait 10 ms then put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "if properly passes execution along if child is not executed"
  :html "<div _='on click if false end put \"foo\" into me.innerHTML'></div>"
  :action "d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click if false end put \\\"foo\\\" into me.innerHTML\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "if properly supports nested if statements and end block"
  :html "<div _='on click \\n                      if window.tmp then\\n                        put \"foo\" into me\\n                      else if not window.tmp then\\n                        // do nothing\\n                      end\\n                  catch e\\n                      // just here for the parsing...\\n'</div>"
  :action "d1.click(); d1.click()"
  :check "d1.innerHTML.should.equal(\"\") && d1.innerHTML.should.equal(\"foo\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click  if window.tmp then put \\\"foo\\\" into me then else if not window.tmp then // do nothing then end  catch e then // just here for the parsing... then\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"foo\")
  ))")
(~hyperscript/hs-test-card
  :name "if on new line does not join w/ else"
  :html "<div _='on click \\n                      if window.tmp then\\n                      else\\n                        if window.tmp then                        end\\n                        put \"foo\" into me\\n                      end\\n                  '</div>"
  :action "d1.click(); d1.click()"
  :check "d1.innerHTML.should.equal(\"foo\") && d1.innerHTML.should.equal(\"\")"
  :run-src "(fn (sandbox)
  (let ((_el-div (dom-create-element \"div\")))
    (dom-set-attr _el-div \"_\" \"on click  if window.tmp then else then if window.tmp then end  put \\\"foo\\\" into me then end\")
    (dom-append sandbox _el-div)
    (hs-activate! _el-div)
    (dom-dispatch _el-div \"click\" nil)
    (dom-dispatch _el-div \"click\" nil)
    (assert= (dom-inner-html _el-div) \"\")
  ))")
(~hyperscript/hs-test-card
  :name "passes the sieve test"
  :html "(no make() call)"
  :action "(see body)"
  :check "evalHyperScript(str, {locals: {x: 1}}).should.equal(1) && evalHyperScript(str, {locals: {x: 2}}).should.equal(2) && evalHyperScript(str, {locals: {x: 3}}).should.equal(3) && evalHyperScript(str, {locals: {x: 4}}).should.equal(4) && evalHyperScript(str, {locals: {x: 5}}).should.equal(5) && evalHyperScript(str, {locals: {x: 6}}).should.equal(6) && evalHyperScript(str, {locals: {x: 6}}).should.equal(6) && evalHyperScript(str, {locals: {x: 7}}).should.equal(6) && evalHyperScript(str, {locals: {x: 8}}).should.equal(6) && evalHyperScript(str, {locals: {x: 9}}).should.equal(6) && evalHyperScript(str, {locals: {x: 10}}).should.equal(10) && evalHyperScript(str, {locals: {x: 11}}).should.equal(10)"
  :run-src "(fn (sandbox) (error \"not yet runnable in gallery — see test suite\"))"))))
