~mna/snow

0c14ebbf22b23fbfbd6afc2a92cded4766d656fb — Martin Angers 1 year, 9 months ago 893bd95
pkg/parser: add if/guard tests
A pkg/parser/testdata/guard_else.snow => pkg/parser/testdata/guard_else.snow +4 -0
@@ 0,0 1,4 @@
fn test() {
  var x: bool
  guard x else {}
}

A pkg/parser/testdata/guard_else.snow.err => pkg/parser/testdata/guard_else.snow.err +0 -0
A pkg/parser/testdata/guard_else.snow.want => pkg/parser/testdata/guard_else.snow.want +13 -0
@@ 0,0 1,13 @@
file [1, #0] [0:45]
  fn [0:45]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [2] [10:45]
      var: [14:25]
        ident [x] [18:19]
        ident [bool] [21:25]
      guard [1] [28:43]
        item [34:35]
          ident [x] [34:35]
        else [36:43]
          block [0] [41:43]

A pkg/parser/testdata/guard_nested.snow => pkg/parser/testdata/guard_nested.snow +8 -0
@@ 0,0 1,8 @@
fn test() {
  var x: bool
  var y: bool 
  guard x else {
    guard y else {
    }
  }
}

A pkg/parser/testdata/guard_nested.snow.err => pkg/parser/testdata/guard_nested.snow.err +0 -0
A pkg/parser/testdata/guard_nested.snow.want => pkg/parser/testdata/guard_nested.snow.want +21 -0
@@ 0,0 1,21 @@
file [1, #0] [0:88]
  fn [0:88]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [3] [10:88]
      var: [14:25]
        ident [x] [18:19]
        ident [bool] [21:25]
      var: [28:39]
        ident [y] [32:33]
        ident [bool] [35:39]
      guard [1] [43:86]
        item [49:50]
          ident [x] [49:50]
        else [51:86]
          block [1] [56:86]
            guard [1] [62:82]
              item [68:69]
                ident [y] [68:69]
              else [70:82]
                block [0] [75:82]

A pkg/parser/testdata/guard_no_body.snow => pkg/parser/testdata/guard_no_body.snow +4 -0
@@ 0,0 1,4 @@
fn test() {
  var x: bool
  guard x else
}

A pkg/parser/testdata/guard_no_body.snow.err => pkg/parser/testdata/guard_no_body.snow.err +6 -0
@@ 0,0 1,6 @@
testdata/guard_no_body.snow:4:1: expected '{', found '}'
testdata/guard_no_body.snow:4:2: expected statement, found ';'
testdata/guard_no_body.snow:4:3: expected '}', found 'eof'
testdata/guard_no_body.snow:4:3: expected ';', found 'eof'
testdata/guard_no_body.snow:4:3: expected '}', found 'eof'
testdata/guard_no_body.snow:4:3: expected ';', found 'eof'

A pkg/parser/testdata/guard_no_body.snow.want => pkg/parser/testdata/guard_no_body.snow.want +14 -0
@@ 0,0 1,14 @@
file [1, #0] [0:43]
  fn [0:43]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [2] [10:43]
      var: [14:25]
        ident [x] [18:19]
        ident [bool] [21:25]
      guard [1] [28:43]
        item [34:35]
          ident [x] [34:35]
        else [36:43]
          block [1] [41:43]
            bad stmt [42:43]

A pkg/parser/testdata/guard_no_else.snow => pkg/parser/testdata/guard_no_else.snow +5 -0
@@ 0,0 1,5 @@
fn test() {
  var x: bool 
  guard x {
  }
}

A pkg/parser/testdata/guard_no_else.snow.err => pkg/parser/testdata/guard_no_else.snow.err +7 -0
@@ 0,0 1,7 @@
testdata/guard_no_else.snow:3:11: expected 'else', found '{'
testdata/guard_no_else.snow:4:3: expected '{', found '}'
testdata/guard_no_else.snow:4:4: expected statement, found ';'
testdata/guard_no_else.snow:5:3: expected '}', found 'eof'
testdata/guard_no_else.snow:5:3: expected ';', found 'eof'
testdata/guard_no_else.snow:5:3: expected '}', found 'eof'
testdata/guard_no_else.snow:5:3: expected ';', found 'eof'

A pkg/parser/testdata/guard_no_else.snow.want => pkg/parser/testdata/guard_no_else.snow.want +14 -0
@@ 0,0 1,14 @@
file [1, #0] [0:45]
  fn [0:45]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [2] [10:45]
      var: [14:25]
        ident [x] [18:19]
        ident [bool] [21:25]
      guard [1] [29:45]
        item [35:36]
          ident [x] [35:36]
        else [37:45]
          block [1] [41:45]
            bad stmt [42:45]

A pkg/parser/testdata/if_nested.snow => pkg/parser/testdata/if_nested.snow +10 -0
@@ 0,0 1,10 @@
fn test() {
  var x: bool
  var y: bool
  if x {
    if y {
    } else {
    }
  }
  return
}

A pkg/parser/testdata/if_nested.snow.err => pkg/parser/testdata/if_nested.snow.err +0 -0
A pkg/parser/testdata/if_nested.snow.want => pkg/parser/testdata/if_nested.snow.want +22 -0
@@ 0,0 1,22 @@
file [1, #0] [0:93]
  fn [0:93]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [4] [10:93]
      var: [14:25]
        ident [x] [18:19]
        ident [bool] [21:25]
      var: [28:39]
        ident [y] [32:33]
        ident [bool] [35:39]
      if [1] [42:82]
        item [45:46]
          ident [x] [45:46]
        block [1] [47:82]
          if [1] [53:78]
            item [56:57]
              ident [y] [56:57]
            block [0] [58:65]
            else [66:78]
              block [0] [71:78]
      return [85:91]

A pkg/parser/testdata/if_no_block.snow => pkg/parser/testdata/if_no_block.snow +4 -0
@@ 0,0 1,4 @@
fn test() {
  var x: bool
  if x
}

A pkg/parser/testdata/if_no_block.snow.err => pkg/parser/testdata/if_no_block.snow.err +3 -0
@@ 0,0 1,3 @@
testdata/if_no_block.snow:3:7: expected '{', found ';'
testdata/if_no_block.snow:4:3: expected '}', found 'eof'
testdata/if_no_block.snow:4:3: expected ';', found 'eof'

A pkg/parser/testdata/if_no_block.snow.want => pkg/parser/testdata/if_no_block.snow.want +12 -0
@@ 0,0 1,12 @@
file [1, #0] [0:35]
  fn [0:35]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [2] [10:35]
      var: [14:25]
        ident [x] [18:19]
        ident [bool] [21:25]
      if [1] [28:34]
        item [31:32]
          ident [x] [31:32]
        block [0] [32:34]

A pkg/parser/testdata/invalid_else.snow => pkg/parser/testdata/invalid_else.snow +4 -0
@@ 0,0 1,4 @@
fn test() {
  else {
  }
}

A pkg/parser/testdata/invalid_else.snow.err => pkg/parser/testdata/invalid_else.snow.err +3 -0
@@ 0,0 1,3 @@
testdata/invalid_else.snow:2:3: expected statement, found 'else'
testdata/invalid_else.snow:4:3: expected '}', found 'eof'
testdata/invalid_else.snow:4:3: expected ';', found 'eof'

A pkg/parser/testdata/invalid_else.snow.want => pkg/parser/testdata/invalid_else.snow.want +6 -0
@@ 0,0 1,6 @@
file [1, #0] [0:27]
  fn [0:27]
    ident [test] [3:7]
    sig [0->0] [7:9]
    block [1] [10:27]
      bad stmt [14:27]