Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check equal for character #721

Merged
merged 3 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def find_all_files(directory, endings=None):
python_requires=">=3.6",
install_requires=["colorama"],
requires=["colorama"],
license=["Mozilla Public License 2.0 (MPL 2.0)"],
license="Mozilla Public License 2.0 (MPL 2.0)",
author="Lars Asplund",
author_email="[email protected]",
description="VUnit is an open source unit testing framework for VHDL/SystemVerilog.",
Expand Down
4 changes: 2 additions & 2 deletions vunit/ostools.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, args, cwd=None, env=None):
# Sending a signal to a process group will send it to all children
# Hopefully this way no orphaned processes will be left behind
if IS_WINDOWS_SYSTEM: # Windows
self._process = subprocess.Popen(
self._process = subprocess.Popen( # pylint: disable=consider-using-with
args,
bufsize=0,
cwd=cwd,
Expand All @@ -114,7 +114,7 @@ def __init__(self, args, cwd=None, env=None):
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
)
else:
self._process = subprocess.Popen(
self._process = subprocess.Popen( # pylint: disable=consider-using-with
args,
bufsize=0,
cwd=cwd,
Expand Down
4 changes: 3 additions & 1 deletion vunit/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def _run_test_suite(
if write_stdout:
self._local.output = Tee([self._stdout_ansi, output_file])
else:
color_output_file = open(color_output_file_name, "w")
color_output_file = open( # pylint: disable=consider-using-with
color_output_file_name, "w"
)
self._local.output = Tee([color_output_file, output_file])

def read_output():
Expand Down
120 changes: 120 additions & 0 deletions vunit/vhdl/check/src/check.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,14 @@ package body check_pkg is
return time'image(data);
end function to_string;

function to_string (
constant data : character)
return string is
constant full_string : string(1 to 3) := character'image(data);
begin
return full_string(2 to 2);
end function to_string;

function max (
constant value_1 : integer;
constant value_2 : integer)
Expand Down Expand Up @@ -4212,6 +4220,118 @@ package body check_pkg is
return pass;
end;

procedure check_equal(
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "") is
variable pass : boolean;
begin
-- pragma translate_off
check_equal(default_checker, pass, got, expected, msg, level, line_num, file_name);
-- pragma translate_on
end;

procedure check_equal(
variable pass : out boolean;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "") is
begin
-- pragma translate_off
check_equal(default_checker, pass, got, expected, msg, level, line_num, file_name);
-- pragma translate_on
end;

procedure check_equal(
constant checker : in checker_t;
variable pass : out boolean;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "") is
begin
-- pragma translate_off
if got = expected then
pass := true;
if is_pass_visible(checker) then
passing_check(
checker,
std_msg(
"Equality check passed", msg,
"Got " & to_string(got) & "."),
line_num, file_name);
else
passing_check(checker);
end if;
else
pass := false;
failing_check(
checker,
std_msg(
"Equality check failed", msg,
"Got " & to_string(got) & ". " &
"Expected " & to_string(expected) & "."),
level, line_num, file_name);
end if;
-- pragma translate_on
end;

procedure check_equal(
constant checker : in checker_t;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "") is
variable pass : boolean;
begin
-- pragma translate_off
check_equal(checker, pass, got, expected, msg, level, line_num, file_name);
-- pragma translate_on
end;

impure function check_equal(
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "")
return boolean is
variable pass : boolean;
begin
-- pragma translate_off
check_equal(default_checker, pass, got, expected, msg, level, line_num, file_name);
-- pragma translate_on
return pass;
end;

impure function check_equal(
constant checker : in checker_t;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "")
return boolean is
variable pass : boolean;
begin
-- pragma translate_off
check_equal(checker, pass, got, expected, msg, level, line_num, file_name);
-- pragma translate_on
return pass;
end;

procedure check_equal(
constant got : in time;
constant expected : in time;
Expand Down
55 changes: 55 additions & 0 deletions vunit/vhdl/check/src/check_api.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,61 @@ package check_pkg is
constant file_name : in string := "")
return boolean;

procedure check_equal(
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "");

procedure check_equal(
variable pass : out boolean;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "");

procedure check_equal(
constant checker : in checker_t;
variable pass : out boolean;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "");

procedure check_equal(
constant checker : in checker_t;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "");

impure function check_equal(
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "")
return boolean;

impure function check_equal(
constant checker : in checker_t;
constant got : in character;
constant expected : in character;
constant msg : in string := check_result_tag;
constant level : in log_level_t := null_log_level;
constant line_num : in natural := 0;
constant file_name : in string := "")
return boolean;

procedure check_equal(
constant got : in time;
constant expected : in time;
Expand Down
34 changes: 24 additions & 10 deletions vunit/vhdl/check/tools/generate_check_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,25 +436,25 @@
(
"std_logic",
"std_logic",
"'1'",
"'1'",
"'0'",
"'0'",
"'1'",
"'1'",
"'0'",
"std_logic'('1')",
"std_logic'('1')",
"std_logic'('0')",
"std_logic'('0')",
"std_logic'('1')",
"std_logic'('1')",
"std_logic'('0')",
"1",
"1",
"0",
),
(
"std_logic",
"boolean",
"'1'",
"std_logic'('1')",
"true",
"'0'",
"std_logic'('0')",
"false",
"'1'",
"std_logic'('1')",
"true",
"false",
"1",
Expand Down Expand Up @@ -503,6 +503,20 @@
"test",
"tests",
),
(
"character",
"character",
"character'('x')",
"character'('x')",
"character'val(0)",
"character'val(0)",
"character'val(255)",
"character'val(255)",
"character'('y')",
"x",
"x",
"y",
),
(
"time",
"time",
Expand Down