|
1 |
| -func roughly_equal(n1, n2): |
2 |
| - return abs(n1 - n2) <= 0.01 |
| 1 | +func _round(value): |
| 2 | + return snappedf(value, 0.01) |
3 | 3 |
|
4 | 4 |
|
5 | 5 | func test_age_on_Earth(solution_script):
|
6 | 6 | var age = solution_script.on_planet('Earth', 1000000000)
|
7 |
| - var expected = 31.69 |
8 |
| - return [roughly_equal(age, expected), true] |
| 7 | + return [_round(age), _round(31.69)] |
9 | 8 |
|
10 | 9 |
|
11 | 10 | func test_age_on_Mercury(solution_script):
|
12 | 11 | var age = solution_script.on_planet('Mercury', 2134835688)
|
13 |
| - var expected = 280.88 |
14 |
| - return [roughly_equal(age, expected), true] |
| 12 | + return [_round(age), _round(280.88)] |
15 | 13 |
|
16 | 14 |
|
17 | 15 | func test_age_on_Venus(solution_script):
|
18 | 16 | var age = solution_script.on_planet('Venus', 189839836)
|
19 |
| - var expected = 9.78 |
20 |
| - return [roughly_equal(age, expected), true] |
| 17 | + return [_round(age), _round(9.78)] |
21 | 18 |
|
22 | 19 |
|
23 | 20 | func test_age_on_Mars(solution_script):
|
24 | 21 | var age = solution_script.on_planet('Mars', 2129871239)
|
25 |
| - var expected = 35.88 |
26 |
| - return [roughly_equal(age, expected), true] |
| 22 | + return [_round(age), _round(35.88)] |
27 | 23 |
|
28 | 24 |
|
29 | 25 | func test_age_on_Jupiter(solution_script):
|
30 | 26 | var age = solution_script.on_planet('Jupiter', 901876382)
|
31 |
| - var expected = 2.41 |
32 |
| - return [roughly_equal(age, expected), true] |
| 27 | + return [_round(age), _round(2.41)] |
33 | 28 |
|
34 | 29 |
|
35 | 30 | func test_age_on_Saturn(solution_script):
|
36 | 31 | var age = solution_script.on_planet('Saturn', 2000000000)
|
37 |
| - var expected = 2.15 |
38 |
| - return [roughly_equal(age, expected), true] |
| 32 | + return [_round(age), _round(2.15)] |
39 | 33 |
|
40 | 34 |
|
41 | 35 | func test_age_on_Uranus(solution_script):
|
42 | 36 | var age = solution_script.on_planet('Uranus', 1210123456)
|
43 |
| - var expected = 0.46 |
44 |
| - return [roughly_equal(age, expected), true] |
| 37 | + return [_round(age), _round(0.46)] |
45 | 38 |
|
46 | 39 |
|
47 | 40 | func test_age_on_Neptune(solution_script):
|
48 | 41 | var age = solution_script.on_planet('Neptune', 1821023456)
|
49 |
| - var expected = 0.35 |
50 |
| - return [roughly_equal(age, expected), true] |
| 42 | + return [_round(age), _round(0.35)] |
0 commit comments