Closed sageserpent-open closed 2 years ago
This has gone out in release 1.8.0, Git commit 9f2ef3f0a49ce266a6a0fdca8706a71128f12ea1 .
NOTE: The behaviour of the overload of TrialsApi.doubles
as not changed - so the distribution of its cases is non-uniform, covering a range of exponents. The new overloads on the other hand are uniformly distributed between the specified lower and upper bounds - so if the bounds are large in magnitude, expect to cases of predominantly large magnitude too.
Evidence using release 1.8.1, run in JShell:
import com.sageserpent.americium.java.Trials;
import com.sageserpent.americium.java.TrialsApi;
import com.sageserpent.americium.java.TrialsFactoring;
final TrialsApi api = Trials.api();
api.doubles(0, 0).withLimit(10).supplyTo(System.out::println);
System.out.println("-----------------");
api.doubles(0, 10.2).withLimit(10).supplyTo(System.out::println);
System.out.println("-----------------");
api.doubles(-10.2, 0).withLimit(10).supplyTo(System.out::println);
System.out.println("-----------------");
api.doubles(-8.9, 134.5).withLimit(10).supplyTo(System.out::println);
System.out.println("-----------------");
try {
api.doubles(8.9, 134.5, 56.823).withLimit(10).supplyTo(unused -> {
throw new RuntimeException();
});
} catch (TrialsFactoring.TrialException exception){
System.out.format("Minimised case: %f\n", (double)exception.provokingCase());
}
System.out.println("-----------------");
Results:
import com.sageserpent.americium.java.Trials
import com.sageserpent.americium.java.TrialsApi
import com.sageserpent.americium.java.TrialsFactoring
field TrialsApi api = com.sageserpent.americium.TrialsApis$$anon$1@3abfe836
api.doubles(0, 0).withLimit(10).supplyTo(System.out::println)
0.0
System.out.println("-----------------")
-----------------
api.doubles(0, 10.2).withLimit(10).supplyTo(System.out::println)
6.994608737954958
0.4563400558950503
10.153976805119154
8.737995963229698
6.613168719796081
9.390197164176328
5.7636264041747305
9.819120613614727
0.669064841098104
6.603374800246225
System.out.println("-----------------")
-----------------
api.doubles(-10.2, 0).withLimit(10).supplyTo(System.out::println)
-3.2053912620450418
-9.74365994410495
-0.04602319488084645
-1.462004036770301
-3.586831280203919
-0.8098028358236717
-4.43637359582527
-0.38087938638527385
-9.530935158901896
-3.5966251997537744
System.out.println("-----------------")
-----------------
api.doubles(-8.9, 134.5).withLimit(10).supplyTo(System.out::println)
89.4359699041903
-2.4843956847695874
133.85296802491044
113.9459432477587
84.07337200183903
123.11512483753779
72.12980650575062
129.1452839208188
0.506264530732168
83.93568101522635
System.out.println("-----------------")
-----------------
try {
api.doubles(8.9, 134.5, 56.823).withLimit(10).supplyTo(unused -> {
throw new RuntimeException();
});
} catch (TrialsFactoring.TrialException exception){
System.out.format("Minimised case: %f\n", (double)exception.provokingCase());
}
Minimised case: 56.823000
System.out.println("-----------------")
-----------------
TrialsApi.doubles
currently has one declaration - this is implemented to yield double vales that are right across the permitted range of values.The object here is to deliver overloads that specify lower and upper bounds for the generated values, and a shrinkage target - like
TrialsApi.integers
,TrialsApi.longs
andTrialsApi.characters
.