Skip to content

Commit

Permalink
add tests for parser error messages. Fixes #208
Browse files Browse the repository at this point in the history
  • Loading branch information
rachitnigam committed Dec 8, 2020
1 parent 2bc9560 commit c97db4d
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 1 deletion.
5 changes: 4 additions & 1 deletion runt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ flags=$(head -n 1 {} | cut -c 3-)
## checking.
[[tests]]
name = "errors"
paths = [ "tests/errors/*.futil" ]
paths = [
"tests/errors/*.futil",
"tests/errors/parser/*.futil"
]
cmd = """
./target/debug/futil {} -p well-formed -p papercut
"""
Expand Down
9 changes: 9 additions & 0 deletions tests/errors/parser/cell-missing-semi.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---CODE---
1
---STDERR---
Error: FuTIL Parser: --> 3:5
|
3 | r = prim std_reg(32)␊
| ^---
|
= expected cell
7 changes: 7 additions & 0 deletions tests/errors/parser/cell-missing-semi.futil
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
component main() -> () {
cells {
r = prim std_reg(32)
}
wires { }
control { }
}
9 changes: 9 additions & 0 deletions tests/errors/parser/num-without-bitwidth.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---CODE---
1
---STDERR---
Error: FuTIL Parser: --> 4:12
|
4 | r.in = 1;␊
| ^
|
= Expected number with bitwidth (like 32'd10).
7 changes: 7 additions & 0 deletions tests/errors/parser/num-without-bitwidth.futil
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
component main() -> () {
cells { }
wires {
r.in = 1;
}
control { }
}
11 changes: 11 additions & 0 deletions tests/errors/parser/while-without-body.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---CODE---
1
---STDERR---
Error: FuTIL Parser: --> 5:27
|
5 | while r.out with cond {␊
| ...
9 | }␊
| ^---------------------^
|
= Sequence of control statements should be enclosed in `seq` or `par`.
11 changes: 11 additions & 0 deletions tests/errors/parser/while-without-body.futil
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
component main() -> () {
cells { }
wires { }
control {
while r.out with cond {
upd0;
upd1;
upd2;
}
}
}
9 changes: 9 additions & 0 deletions tests/errors/parser/wrong-binary-num.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---CODE---
1
---STDERR---
Error: FuTIL Parser: --> 4:16
|
4 | r.in = 10'b22;␊
| ^^
|
= Expected binary number
7 changes: 7 additions & 0 deletions tests/errors/parser/wrong-binary-num.futil
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
component main() -> () {
cells { }
wires {
r.in = 10'b22;
}
control { }
}

0 comments on commit c97db4d

Please sign in to comment.