Skip to content

Commit

Permalink
Merge branch 'eyraud/153' into 'master'
Browse files Browse the repository at this point in the history
[TGen] Fix interval size computation in floating point generation

Closes #153

See merge request eng/ide/libadalang-tools!196
  • Loading branch information
Jugst3r committed Mar 13, 2024
2 parents 7f16dfd + 1e57ef5 commit 6b8c52a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tgen/tgen_rts/tgen-random.adb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ package body TGen.Random is

Nb_Values_Between :=
Unsigned_Type
(HB_Sign * Int_Type (HB_Exp) - LB_Sign * Int_Type (LB_Exp))
(HB_Sign * Int_Type (HB_Exp) - LB_Sign * Int_Type (LB_Exp) - 1)
* MS_Part;

Nb_Values :=
Expand Down
6 changes: 6 additions & 0 deletions testsuite/tests/test/153-floating-point-tgen/pkg.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package body Pkg is
procedure Foo (P1 : My_Float) is
begin
null;
end Foo;
end Pkg;
7 changes: 7 additions & 0 deletions testsuite/tests/test/153-floating-point-tgen/pkg.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
with Ada.Numerics; use Ada.Numerics;

package Pkg is
type Precision_6 is digits 6;
subtype My_Float is Precision_6 range -Pi .. Pi;
procedure Foo (P1 : My_Float);
end Pkg;
4 changes: 4 additions & 0 deletions testsuite/tests/test/153-floating-point-tgen/test.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project Test is
for Source_Dirs use (".");
for Object_Dir use "obj";
end Test;
4 changes: 4 additions & 0 deletions testsuite/tests/test/153-floating-point-tgen/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Set the seed to a known crashing seed
export TGEN_RANDOM_SEED=389810392
gnattest -P test.gpr --gen-test-vectors -q --gen-test-num 200

8 changes: 8 additions & 0 deletions testsuite/tests/test/153-floating-point-tgen/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description:
This is a regression test case checking that TGen creates floating
point values in the range of a floating point type with a range
constraint.

driver: shell_script
control:
- [XFAIL, 'x86', 'Marshalling not working for 32bits (UB03-008)']

0 comments on commit 6b8c52a

Please sign in to comment.