; status: formatter-stability-v1
; Scope: Slovo v1 formatter stability contract for supported comments, nested promoted forms, and long inline forms.

(module stability)

; before top-level struct

(struct Pair
  (left i32)
  (right i32))

; before top-level function

(fn sum_pair ((pair Pair)) -> i32
  ; before function body expression
  (+ (. pair left) (. pair right))
  ; after final function body expression
)

(fn choose ((value i32)) -> i32
  (if (< value 10)
    (if (< value 5)
      (+ value 1)
      (+ value 2))
    (unsafe
      (if (< value 20)
        (+ value 3)
        (+ value 4)))))

(fn loop_sum () -> i32
  (var i i32 0)
  (var total i32 0)
  (while (< i 3)
    (set total (unsafe
      (if (< i 2)
        (+ total i)
        (+ total 1))))
    (set i (+ i 1)))
  total)

(fn accept_many ((a i32) (b i32) (c i32) (d i32) (e i32) (f i32) (g i32) (h i32) (i i32) (j i32)) -> i32
  (+ a j))

(fn long_inline_call () -> i32
  (accept_many 100000001 100000002 100000003 100000004 100000005 100000006 100000007 100000008 100000009 100000010))

(test "comments stay"
  ; before test setup
  (let value i32 42)
  ; before test final expression
  (= value 42)
  ; after test final expression
)

; after last top-level form
