Skip to content

Commit 6e9c76f

Browse files
committed
Add pytest for HdlDetect
1 parent 23b5311 commit 6e9c76f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/test_detect.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import pytest
2+
from hdltools.hdl_detect import HdlDetect
3+
4+
5+
code = {
6+
'vhdl': """
7+
library IEEE;
8+
use IEEE.STD_LOGIC_1164.ALL;
9+
10+
entity Example is
11+
Port (
12+
data_i : in STD_LOGIC;
13+
data_o : out STD_LOGIC
14+
);
15+
end Example;
16+
17+
architecture Behavioral of Example is
18+
begin
19+
data_o <= data_i;
20+
end Behavioral;
21+
""",
22+
'vlog': """
23+
module Example (
24+
input data_i,
25+
output data_o
26+
);
27+
assign data_o = data_i;
28+
endmodule
29+
""",
30+
'slog': """
31+
module Example (
32+
input logic data_i,
33+
output logic data_o
34+
);
35+
assign data_o = data_i;
36+
endmodule
37+
"""
38+
}
39+
40+
41+
@pytest.mark.parametrize("lang", ['vhdl', 'vlog', 'slog'])
42+
def test_detect(lang):
43+
obj = HdlDetect(code[lang])
44+
assert obj.get_lang() == lang

0 commit comments

Comments
 (0)