From 87ac61140d7fd1b83c9b61cf5ba43cde29fcd435 Mon Sep 17 00:00:00 2001 From: Ryszard Rozak Date: Fri, 25 Oct 2024 17:06:32 +0200 Subject: [PATCH] Tests: Don't use indices in check_rand (#5561) Signed-off-by: Ryszard Rozak --- test_regress/t/t_constraint_dist.v | 7 +++++-- test_regress/t/t_constraint_foreach.v | 7 +++++-- test_regress/t/t_constraint_inheritance.v | 7 +++++-- test_regress/t/t_constraint_inheritance_with.v | 7 +++++-- test_regress/t/t_randomize_array.v | 6 ++++-- test_regress/t/t_randomize_array_constraints.v | 6 ++++-- test_regress/t/t_randomize_method.v | 6 ++++-- test_regress/t/t_randomize_method_with.v | 6 ++++-- test_regress/t/t_randomize_queue_constraints.v | 7 +++++-- 9 files changed, 41 insertions(+), 18 deletions(-) diff --git a/test_regress/t/t_constraint_dist.v b/test_regress/t/t_constraint_dist.v index ce695844c..343a7aad5 100644 --- a/test_regress/t/t_constraint_dist.v +++ b/test_regress/t/t_constraint_dist.v @@ -8,12 +8,15 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + if (!bit'(cl.randomize())) $stop; \ + prev_result = longint'(field); \ + if (!(cond)) $stop; \ + repeat(9) begin \ longint result; \ if (!bit'(cl.randomize())) $stop; \ result = longint'(field); \ if (!(cond)) $stop; \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_constraint_foreach.v b/test_regress/t/t_constraint_foreach.v index fd243ebed..a2c7f9f93 100644 --- a/test_regress/t/t_constraint_foreach.v +++ b/test_regress/t/t_constraint_foreach.v @@ -8,12 +8,15 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + if (!bit'(cl.randomize())) $stop; \ + prev_result = longint'(field); \ + if (!(cond)) $stop; \ + repeat(9) begin \ longint result; \ if (!bit'(cl.randomize())) $stop; \ result = longint'(field); \ if (!(cond)) $stop; \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_constraint_inheritance.v b/test_regress/t/t_constraint_inheritance.v index e37040c4d..081d1cb0a 100644 --- a/test_regress/t/t_constraint_inheritance.v +++ b/test_regress/t/t_constraint_inheritance.v @@ -8,12 +8,15 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + if (!bit'(cl.randomize())) $stop; \ + prev_result = longint'(field); \ + if (!(cond)) $stop; \ + repeat(9) begin \ longint result; \ if (!bit'(cl.randomize())) $stop; \ result = longint'(field); \ if (!(cond)) $stop; \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_constraint_inheritance_with.v b/test_regress/t/t_constraint_inheritance_with.v index 2a1e4a020..b5e949dd6 100644 --- a/test_regress/t/t_constraint_inheritance_with.v +++ b/test_regress/t/t_constraint_inheritance_with.v @@ -8,12 +8,15 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + if (!bit'(cl.randomize() with { constr; })) $stop; \ + prev_result = longint'(field); \ + if (!(cond)) $stop; \ + repeat(9) begin \ longint result; \ if (!bit'(cl.randomize() with { constr; })) $stop; \ result = longint'(field); \ if (!(cond)) $stop; \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_randomize_array.v b/test_regress/t/t_randomize_array.v index 521b7cea4..fd6b5f853 100755 --- a/test_regress/t/t_randomize_array.v +++ b/test_regress/t/t_randomize_array.v @@ -8,11 +8,13 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + void'(cl.randomize()); \ + prev_result = longint'(field); \ + repeat(9) begin \ longint result; \ void'(cl.randomize()); \ result = longint'(field); \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_randomize_array_constraints.v b/test_regress/t/t_randomize_array_constraints.v index 7a56edc45..f56cab447 100755 --- a/test_regress/t/t_randomize_array_constraints.v +++ b/test_regress/t/t_randomize_array_constraints.v @@ -8,11 +8,13 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + void'(cl.randomize()); \ + prev_result = longint'(field); \ + repeat(9) begin \ longint result; \ void'(cl.randomize()); \ result = longint'(field); \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_randomize_method.v b/test_regress/t/t_randomize_method.v index 9db38279b..1663f26ad 100644 --- a/test_regress/t/t_randomize_method.v +++ b/test_regress/t/t_randomize_method.v @@ -8,11 +8,13 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + void'(cl.randomize()); \ + prev_result = longint'(field); \ + repeat(9) begin \ longint result; \ void'(cl.randomize()); \ result = longint'(field); \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_randomize_method_with.v b/test_regress/t/t_randomize_method_with.v index 63f6ac6ce..d6436baf2 100644 --- a/test_regress/t/t_randomize_method_with.v +++ b/test_regress/t/t_randomize_method_with.v @@ -8,11 +8,13 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + void'(cl.randomize()); \ + prev_result = longint'(field); \ + repeat(9) begin \ longint result; \ void'(cl.randomize()); \ result = longint'(field); \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \ diff --git a/test_regress/t/t_randomize_queue_constraints.v b/test_regress/t/t_randomize_queue_constraints.v index ab8230354..b88bace7b 100644 --- a/test_regress/t/t_randomize_queue_constraints.v +++ b/test_regress/t/t_randomize_queue_constraints.v @@ -8,12 +8,15 @@ begin \ longint prev_result; \ int ok = 0; \ - for (int i = 0; i < 10; i++) begin \ + if (!bit'(cl.randomize())) $stop; \ + prev_result = longint'(field); \ + if (!(cond)) $stop; \ + repeat(9) begin \ longint result; \ if (!bit'(cl.randomize())) $stop; \ result = longint'(field); \ if (!(cond)) $stop; \ - if (i > 0 && result != prev_result) ok = 1; \ + if (result != prev_result) ok = 1; \ prev_result = result; \ end \ if (ok != 1) $stop; \