1- use  aiken/ math/ rational.{Rational , int_power, new}
21use  aiken/ fuzz.{both, either, map}
2+ use  aiken/ math/ rational.{Rational , new, pow}
33
4- fn  positive_rational_fuzz () ->  Fuzzer < Rational > {
5-   map (
6-     both (fuzz.int_at_least (1 ), fuzz.int_at_least (1 )), 
7-     fn ((num,den)){
8-       expect  Some (new_fraction) =  new (num,den)
9-       new_fraction
10-     }
4+ const  any_positive_rational:  Fuzzer < Rational >  = 
5+   either (
6+     map (
7+       both (fuzz.int_at_least (1 ), fuzz.int_at_least (1 )),
8+       fn ((num, den)) {
9+         expect  Some (new_fraction) =  new (num, den)
10+         new_fraction
11+       },
12+     ),
13+     map (
14+       both (fuzz.int_at_most (- 1 ), fuzz.int_at_most (- 1 )),
15+       fn ((num, den)) {
16+         expect  Some (new_fraction) =  new (num, den)
17+         new_fraction
18+       },
19+     ),
1120  )
12- }
1321
14- fn  negative_rational_fuzz () ->  Fuzzer < Rational > {
15-   map (both (fuzz.int_at_most (- 1 ),fuzz.int_at_least (1 )),
16-     fn ((num,den)){
17-       expect  Some (new_fraction) =  new (num,den)
18-       new_fraction
19-     }
22+ const  any_negative_rational:  Fuzzer < Rational >  = 
23+   either (
24+     map (
25+       both (fuzz.int_at_most (- 1 ), fuzz.int_at_least (1 )),
26+       fn ((num, den)) {
27+         expect  Some (new_fraction) =  new (num, den)
28+         new_fraction
29+       },
30+     ),
31+     map (
32+       both (fuzz.int_at_least (1 ), fuzz.int_at_most (- 1 )),
33+       fn ((num, den)) {
34+         expect  Some (new_fraction) =  new (num, den)
35+         new_fraction
36+       },
37+     ),
2038  )
21- }
2239
23- fn  rational_fuzz () ->  Fuzzer < Rational >  {
24-   either (negative_rational_fuzz (),positive_rational_fuzz ())
25- }
40+ const  any_non_zero_rational:  Fuzzer < Rational >  = 
41+   either (any_negative_rational, any_positive_rational)
2642
27- test  prop_power_of_zero_returns_one (rational via  rational_fuzz ()) {
28-   expect  Some (calculated_result) =  int_power (rational, 0 )
29-   expect  Some (expected_result) =  new (1 ,1 )
43+ test  prop_power_of_zero_returns_one (rational via  any_non_zero_rational)  {
44+   expect  Some (calculated_result) =  pow (rational, 0 )
45+   expect  Some (expected_result) =  new (1 ,  1 )
3046  calculated_result ==  expected_result
3147}
3248
33- test  prop_power_of_one_returns_same_fraction (rational via  rational_fuzz ()) {
34-   expect  Some (calculated_result) =  int_power (rational, 1 )
49+ test  prop_power_of_one_returns_same_fraction (rational via  any_non_zero_rational)  {
50+   expect  Some (calculated_result) =  pow (rational, 1 )
3551  calculated_result ==  rational
3652}
3753
38- test  prop_power_numerator_zero_exponent_negative_returns_none ((denominator,exponent) via  both (fuzz.int_at_least (1 ),fuzz.int_at_most (- 1 ))){
54+ test  prop_power_numerator_zero_exponent_negative_returns_none (
55+   (denominator, exponent) via  both (fuzz.int_at_least (1 ), fuzz.int_at_most (- 1 )),
56+ ) {
3957  expect  Some (fraction) =  new (0 , denominator)
40-   expect  None  =  int_power (fraction,exponent)
58+   expect  None  =  pow (fraction,  exponent)
4159}
4260
43- 
4461test  prop_power_unit_fraction_is_immutable (exponent via  fuzz.int ()) {
45-   expect  Some (unit) =  new (1 ,1 )
46-   expect  Some (calculated_result) =  int_power (unit, exponent)
62+   expect  Some (unit) =  new (1 ,  1 )
63+   expect  Some (calculated_result) =  pow (unit, exponent)
4764  calculated_result ==  unit
48- }
65+ }
0 commit comments