Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
croyzor committed Oct 10, 2024
1 parent 26b8def commit 5ed5e9c
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 3 deletions.
5 changes: 5 additions & 0 deletions brat/examples/fanout.brat
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ swap_vec(qs) = [\/](swap(Qubit, Qubit)([/\](qs)))

pack_mid(Nat, Nat, Nat, Nat) -> Nat, Vec(Nat, 2), Nat
pack_mid = { (x=>x), [\/], .. }

ext "" f :: { Vec(Qubit, 2) -o Bit }

g(Qubit, Qubit) -o Bit
g = [\/]; f
9 changes: 9 additions & 0 deletions brat/test/golden/error/fanin-diff-types.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Error in test/golden/error/fanin-diff-types.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [\/] }
^^^^^^^^

Type mismatch when checking [\/]
Expected: Qubit
But got: Bit


6 changes: 6 additions & 0 deletions brat/test/golden/error/fanin-dynamic-length.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error in test/golden/error/fanin-dynamic-length.brat@FC {start = Pos {line = 2, col = 8}, end = Pos {line = 2, col = 16}}:
f(n) = { [\/] }
^^^^^^^^

Type error: Can't fanout a Vec with non-constant length: VPar Ex checking_check_defs_1_f_f.box_2_lambda_fake_source 0

2 changes: 1 addition & 1 deletion brat/test/golden/error/fanin-list.brat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
f(Bool, Bool) -> List(Bool
f(Bool, Bool) -> List(Bool)
f = { [\/] }
6 changes: 6 additions & 0 deletions brat/test/golden/error/fanin-list.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error in test/golden/error/fanin-list.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [\/] }
^^^^^^^^

Type error: Fanin ([\/]) only applies to Vec

6 changes: 6 additions & 0 deletions brat/test/golden/error/fanin-not-enough-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error in test/golden/error/fanin-not-enough-overs.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [\/] }
^^^^^^^^

Type error: Not enough inputs to make a vector of size 3

7 changes: 7 additions & 0 deletions brat/test/golden/error/fanin-too-many-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error in test/golden/error/fanin-too-many-overs.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [\/] }
^^^^^^^^

Internal error: Expected empty thunk leftovers, got:
(z :: Nat)

9 changes: 9 additions & 0 deletions brat/test/golden/error/fanout-diff-types.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Error in test/golden/error/fanout-diff-types.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [/\] }
^^^^^^^^

Type mismatch when checking [/\]
Expected: (b1 :: Bit)
But got: (head :: Qubit)


2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-dynamic-length.brat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
f(n :: #, Vec(Qubit, n)) -> { Qubit, Qubit }
f(n :: #) -> { Vec(Qubit, n) -o Qubit, Qubit }
f(n) = { [/\] }
6 changes: 6 additions & 0 deletions brat/test/golden/error/fanout-dynamic-length.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error in test/golden/error/fanout-dynamic-length.brat@FC {start = Pos {line = 2, col = 8}, end = Pos {line = 2, col = 16}}:
f(n) = { [/\] }
^^^^^^^^

Type error: Can't fanout a Vec with non-constant length: VPar Ex checking_check_defs_1_f_f.box_2_lambda_fake_source 0

6 changes: 6 additions & 0 deletions brat/test/golden/error/fanout-list.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error in test/golden/error/fanout-list.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [/\] }
^^^^^^^^

Type error: Fanout ([/\]) only applies to Vec

2 changes: 1 addition & 1 deletion brat/test/golden/error/fanout-not-enough-overs.brat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
f(Vec(Nat, 2) -> Nat, Nat, Nat
f(Vec(Nat, 2)) -> Nat, Nat, Nat
f = { [/\] }
7 changes: 7 additions & 0 deletions brat/test/golden/error/fanout-not-enough-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error in test/golden/error/fanout-not-enough-overs.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [/\] }
^^^^^^^^

Internal error: Expected empty thunk leftunders, got:
(c1 :: Nat)

6 changes: 6 additions & 0 deletions brat/test/golden/error/fanout-too-many-overs.brat.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Error in test/golden/error/fanout-too-many-overs.brat@FC {start = Pos {line = 2, col = 5}, end = Pos {line = 2, col = 13}}:
f = { [/\] }
^^^^^^^^

Type error: No unders but overs: (head :: Nat) for [/\]

0 comments on commit 5ed5e9c

Please sign in to comment.