===========================================================================================
if_inline
===========================================================================================

if foo
if foo then bar
if a == b then 'hello' else 'bye'

---

(module
  (if condition: (identifier))
  (if condition: (identifier) then: (identifier))
  (if
    condition: (comparison_op (identifier) (identifier))
    then: (string)
    else: (string)
  )
)

===========================================================================================
if_multi_line
===========================================================================================

if x

if 1 + 1 == 2
  foo
  bar
else if 3 + 4 == 5
  baz
else
  'hello'

---

(module
  (if 
    condition: (identifier)
  )
  (if
    condition: (comparison_op
      (binary_op (number) (number))
      (number)
    )
    then: (block (identifier) (identifier))
  )
  (else_if
    condition: (comparison_op
      (binary_op (number) (number))
      (number)
    )
    then: (block (identifier))
  )
  (else (block (string)))
)

===========================================================================================
if_nested
===========================================================================================

if 1 + 1 == 2
  if 2 + 3 == 4
    foo
  else if 5 + 6 == 7
    bar
else if true
  'hello'
else
  baz

---

(module
  (if
    condition: (comparison_op
      (binary_op (number) (number))
      (number)
    )
    then: (block
      (if
        condition: (comparison_op
          (binary_op (number) (number))
          (number)
        )
        then: (block (identifier))
      )
      (else_if
        condition: (comparison_op
          (binary_op (number) (number))
          (number)
        )
        then: (block (identifier))
      )
    )
  )
  (else_if
    condition: (true)
    then: (block (string))
  )
  (else (block (identifier)))
)

===========================================================================================
if_block_followed_by_expression
===========================================================================================

if foo
  bar
99

---

(module
  (if
    condition: (identifier)
    then: (block (identifier))
  )
  (number)
)

===========================================================================================
switch_single_arm
===========================================================================================

switch
  n == 1 then 'foo'

---

(module
  (switch
    (switch_arm
      condition: (comparison_op (identifier) (number))
      then: (string)
    )
  )
)

===========================================================================================
switch_simple_arms
===========================================================================================

switch
  n <= 0 then 0
  n == 1 then 1
  else 2

---

(module
  (switch
    (switch_arm
      condition: (comparison_op (identifier) (number))
      then: (number)
    )
    (switch_arm
      condition: (comparison_op (identifier) (number))
      then: (number)
    )
    else: (number)
  )
)


===========================================================================================
switch_arms_with_bodies
===========================================================================================

switch
  n <= 0 then
    foo
    bar
  n == 1 then
    'hello'
    42
  else
    99

---

(module
  (switch
    (switch_arm
      condition: (comparison_op (identifier) (number))
      then: (block
        (identifier)
        (identifier)
      )
    )
    (switch_arm
      condition: (comparison_op (identifier) (number))
      then: (block
        (string)
        (number)
      )
    )
    else: (block (number))
  )
)

===========================================================================================
switch_followed_by_expression
===========================================================================================

switch
  foo then
    bar
  else
    99
123

---

(module
  (switch
    (switch_arm
      condition: (identifier)
      then: (block
        (identifier)
      )
    )
    else: (block (number))
  )
  (number)
)


===========================================================================================
match_no_arms
===========================================================================================

match foo

match foo, bar

match 1 + 1

match foo.bar

---

(module
  (match
    (match_conditions (identifier))
  )
  (match
    (match_conditions
      (identifier)
      (identifier)
    )
  )
  (match
    (match_conditions (binary_op (number) (number)))
  )
  (match
    (match_conditions (chain
      start: (identifier)
      lookup: (identifier)
    ))
  )
)

===========================================================================================
match_single_line_arms
===========================================================================================

match foo
  'hello' then 0
  other if other > 1 then 1
  1 or -1 then 2
  x, y: String then x + y
  else 2

---

(module
  (match
    (match_conditions (identifier))
    (match_arm
      (match_patterns (string))
      then: (number)
    )
    (match_arm
      (match_patterns (variable (identifier)))
      condition: (comparison_op (identifier) (number))
      then: (number)
    )
    (match_arm
      (match_patterns (number) (negate (number)))
      then: (number)
    )
    (match_arm
      (match_patterns (match_terms
        (variable (identifier))
        (variable (identifier) type: (identifier))
      ))
      then: (binary_op (identifier) (identifier))
    )
    else: (number)
  )
)

===========================================================================================
match_arms_with_bodies
===========================================================================================

match foo, bar
  'hello' then
    foo
  2 or 3 then
    bar
  else
    'baz'

---

(module
  (match
    (match_conditions (identifier) (identifier))
    (match_arm
      (match_patterns (string))
      then: (block (identifier))
    )
    (match_arm
      (match_patterns (number) (number))
      then: (block (identifier))
    )
    else: (block (string))
  )
)
