HS test generator: drop bogus then after else and catch X
process_hs_val replaces newlines with `then` to give the HS parser a statement separator, but `else then` and `catch foo then` are syntax errors — `else` and `catch <name>` already open new blocks. Strip the inserted `then` after them so multi-line if/try parses cleanly. No net pass-count delta on smoke-tested suites (the if-with-window-state tests fail for a separate reason: window setups all run before any click rather than being interleaved with state changes), but the source now parses correctly and matches what upstream HS sees. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1223,7 +1223,7 @@
|
|||||||
(deftest "rejected promise triggers catch block"
|
(deftest "rejected promise triggers catch block"
|
||||||
(hs-cleanup!)
|
(hs-cleanup!)
|
||||||
(let ((_el-button (dom-create-element "button")) (_el-out (dom-create-element "div")))
|
(let ((_el-button (dom-create-element "button")) (_el-out (dom-create-element "div")))
|
||||||
(dom-set-attr _el-button "_" "on click call failAsync() then put 'unreachable' into #out then catch e then put e.message into #out then")
|
(dom-set-attr _el-button "_" "on click call failAsync() then put 'unreachable' into #out then catch e put e.message into #out then")
|
||||||
(dom-set-inner-html _el-button "Go")
|
(dom-set-inner-html _el-button "Go")
|
||||||
(dom-set-attr _el-out "id" "out")
|
(dom-set-attr _el-out "id" "out")
|
||||||
(dom-append (dom-body) _el-button)
|
(dom-append (dom-body) _el-button)
|
||||||
@@ -4066,7 +4066,7 @@
|
|||||||
(dom-set-attr _el-input9 "type" "checkbox")
|
(dom-set-attr _el-input9 "type" "checkbox")
|
||||||
(dom-set-attr _el-input9 "checked" "")
|
(dom-set-attr _el-input9 "checked" "")
|
||||||
(dom-set-attr _el-master "id" "master")
|
(dom-set-attr _el-master "id" "master")
|
||||||
(dom-set-attr _el-master "_" "set :checkboxes to <input[type=checkbox]/> in the closest <table/> where it is not me then on change set checked of the :checkboxes to my checked then on change from the closest <table/> then if no :checkboxes where it is checked then set my indeterminate to false then set my checked to false then else if no :checkboxes where it is not checked then set my indeterminate to false then set my checked to true then else then set my indeterminate to true then end")
|
(dom-set-attr _el-master "_" "set :checkboxes to <input[type=checkbox]/> in the closest <table/> where it is not me then on change set checked of the :checkboxes to my checked then on change from the closest <table/> then if no :checkboxes where it is checked then set my indeterminate to false then set my checked to false then else if no :checkboxes where it is not checked then set my indeterminate to false then set my checked to true then else set my indeterminate to true then end")
|
||||||
(dom-set-attr _el-master "type" "checkbox")
|
(dom-set-attr _el-master "type" "checkbox")
|
||||||
(dom-append (dom-body) _el-table)
|
(dom-append (dom-body) _el-table)
|
||||||
(dom-append _el-table _el-tr)
|
(dom-append _el-table _el-tr)
|
||||||
@@ -7723,7 +7723,7 @@
|
|||||||
(host-set! (host-global "window") "tmp" false)
|
(host-set! (host-global "window") "tmp" false)
|
||||||
(host-set! (host-global "window") "tmp" true)
|
(host-set! (host-global "window") "tmp" true)
|
||||||
(let ((_el-div (dom-create-element "div")))
|
(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-set-attr _el-div "_" "on click if window.tmp then else if window.tmp then end put \"foo\" into me then end")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
(dom-dispatch _el-div "click" nil)
|
(dom-dispatch _el-div "click" nil)
|
||||||
@@ -7745,7 +7745,7 @@
|
|||||||
(host-set! (host-global "window") "tmp" false)
|
(host-set! (host-global "window") "tmp" false)
|
||||||
(host-set! (host-global "window") "tmp" true)
|
(host-set! (host-global "window") "tmp" true)
|
||||||
(let ((_el-div (dom-create-element "div")))
|
(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-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 // just here for the parsing... then")
|
||||||
(dom-append (dom-body) _el-div)
|
(dom-append (dom-body) _el-div)
|
||||||
(hs-activate! _el-div)
|
(hs-activate! _el-div)
|
||||||
(dom-dispatch _el-div "click" nil)
|
(dom-dispatch _el-div "click" nil)
|
||||||
@@ -8754,7 +8754,7 @@
|
|||||||
(deftest "async exceptions don't kill the event queue"
|
(deftest "async exceptions don't kill the event queue"
|
||||||
(hs-cleanup!)
|
(hs-cleanup!)
|
||||||
(let ((_el-button (dom-create-element "button")))
|
(let ((_el-button (dom-create-element "button")))
|
||||||
(dom-set-attr _el-button "_" "on click increment :x then if :x is 1 then wait 1ms then throw \"bar\" otherwise then put \"success\" into me end catch e then put e into me")
|
(dom-set-attr _el-button "_" "on click increment :x then if :x is 1 then wait 1ms then throw \"bar\" otherwise then put \"success\" into me end catch e put e into me")
|
||||||
(dom-append (dom-body) _el-button)
|
(dom-append (dom-body) _el-button)
|
||||||
(hs-activate! _el-button)
|
(hs-activate! _el-button)
|
||||||
(dom-dispatch _el-button "click" nil)
|
(dom-dispatch _el-button "click" nil)
|
||||||
@@ -9035,7 +9035,7 @@
|
|||||||
(deftest "exceptions in catch block don't kill the event queue"
|
(deftest "exceptions in catch block don't kill the event queue"
|
||||||
(hs-cleanup!)
|
(hs-cleanup!)
|
||||||
(let ((_el-button (dom-create-element "button")))
|
(let ((_el-button (dom-create-element "button")))
|
||||||
(dom-set-attr _el-button "_" "on click increment :x then if :x is 1 then throw \"bar\" otherwise then put \"success\" into me end catch e then put e into me then throw e")
|
(dom-set-attr _el-button "_" "on click increment :x then if :x is 1 then throw \"bar\" otherwise then put \"success\" into me end catch e put e into me then throw e")
|
||||||
(dom-append (dom-body) _el-button)
|
(dom-append (dom-body) _el-button)
|
||||||
(hs-activate! _el-button)
|
(hs-activate! _el-button)
|
||||||
(dom-dispatch _el-button "click" nil)
|
(dom-dispatch _el-button "click" nil)
|
||||||
|
|||||||
@@ -813,6 +813,10 @@ def process_hs_val(hs_val):
|
|||||||
hs_val = re.sub(r'(\bin (?:\[.*?\]|\S+)) then\b', r'\1 ', hs_val)
|
hs_val = re.sub(r'(\bin (?:\[.*?\]|\S+)) then\b', r'\1 ', hs_val)
|
||||||
hs_val = re.sub(r'\btimes then\b', 'times ', hs_val)
|
hs_val = re.sub(r'\btimes then\b', 'times ', hs_val)
|
||||||
hs_val = re.sub(r'\bend then\b', 'end ', hs_val)
|
hs_val = re.sub(r'\bend then\b', 'end ', hs_val)
|
||||||
|
# `else then` is invalid HS — `else` already opens a new block.
|
||||||
|
hs_val = re.sub(r'\belse then\b', 'else ', hs_val)
|
||||||
|
# Same for `catch <name> then` (try/catch syntax).
|
||||||
|
hs_val = re.sub(r'\bcatch (\w+) then\b', r'catch \1 ', hs_val)
|
||||||
return hs_val.strip()
|
return hs_val.strip()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user