Skip to content

Commit 80031ce

Browse files
committed
test for spec manager
1 parent e56e7e7 commit 80031ce

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from grape.automaton.spec_manager import despecialize, specialize
2+
from grape.automaton_generator import grammar_by_saturation
3+
from grape.dsl import DSL
4+
5+
6+
dsl = DSL(
7+
{
8+
"1": ("int", 1),
9+
"0": ("int", 0),
10+
"+": ("int -> int -> int", lambda x, y: x + y),
11+
"*": ("int -> int -> int", lambda x, y: x * y),
12+
"-": ("int -> int", lambda x: -x),
13+
}
14+
)
15+
16+
17+
def test():
18+
type_req = "int->int->int"
19+
grammar = grammar_by_saturation(dsl, type_req)
20+
prev = despecialize(grammar, type_req)
21+
spec = specialize(prev, type_req, dsl)
22+
assert spec.trees_until_size(100) == grammar.trees_until_size(100)

0 commit comments

Comments
 (0)