Skip to content

Commit 8717ff6

Browse files
munificentCommit Queue
authored andcommitted
Format tests/lib/math/ using 3.8 style.
Change-Id: Ib34bac4962df8927cf2952a4cc5e388c84dcea79 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425984 Auto-Submit: Bob Nystrom <[email protected]> Reviewed-by: Lasse Nielsen <[email protected]> Commit-Queue: Lasse Nielsen <[email protected]>
1 parent 4e8a4a3 commit 8717ff6

File tree

8 files changed

+108
-53
lines changed

8 files changed

+108
-53
lines changed

tests/lib/math/coin_test.dart

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ main() {
2020
tails++;
2121
}
2222
}
23-
print("Heads: $heads\n"
24-
"Tails: $tails\n"
25-
"Ratio: ${heads / tails}\n");
23+
print(
24+
"Heads: $heads\n"
25+
"Tails: $tails\n"
26+
"Ratio: ${heads / tails}\n",
27+
);
2628
Expect.approxEquals(1.0, heads / tails, 0.1);
2729

2830
heads = 0;
@@ -35,9 +37,11 @@ main() {
3537
tails++;
3638
}
3739
}
38-
print("Heads: $heads\n"
39-
"Tails: $tails\n"
40-
"Ratio: ${heads / tails}\n");
40+
print(
41+
"Heads: $heads\n"
42+
"Tails: $tails\n"
43+
"Ratio: ${heads / tails}\n",
44+
);
4145
Expect.approxEquals(1.0, heads / tails, 0.1);
4246

4347
// A sequence of newly allocated Random number generators should have fair
@@ -52,8 +56,10 @@ main() {
5256
tails++;
5357
}
5458
}
55-
print("Heads: $heads\n"
56-
"Tails: $tails\n"
57-
"Ratio: ${heads / tails}\n");
59+
print(
60+
"Heads: $heads\n"
61+
"Tails: $tails\n"
62+
"Ratio: ${heads / tails}\n",
63+
);
5864
Expect.approxEquals(1.0, heads / tails, 0.1);
5965
}

tests/lib/math/double_pow_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var samples = [
5252
1.5, // Non-integer, magnitude > 1
5353
2.0, // Even integer
5454
3.0, // Odd integer
55-
Infinity
55+
Infinity,
5656
];
5757

5858
test() {

tests/lib/math/implement_rectangle_test.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ class Rectangle<T extends num> implements math.MutableRectangle<T> {
5959
T rRight = max(right, other.right);
6060
T rBottom = max(bottom, other.bottom);
6161
return new Rectangle<T>(
62-
rLeft, rTop, (rRight - rLeft) as T, (rBottom - rTop) as T);
62+
rLeft,
63+
rTop,
64+
(rRight - rLeft) as T,
65+
(rBottom - rTop) as T,
66+
);
6367
}
6468

6569
/// Tests whether `this` entirely contains [another].
@@ -77,6 +81,10 @@ class Rectangle<T extends num> implements math.MutableRectangle<T> {
7781
T rRight = min(right, rect.right);
7882
T rBottom = min(bottom, rect.bottom);
7983
return new Rectangle<T>(
80-
rLeft, rTop, (rRight - rLeft) as T, (rBottom - rTop) as T);
84+
rLeft,
85+
rTop,
86+
(rRight - rLeft) as T,
87+
(rBottom - rTop) as T,
88+
);
8189
}
8290
}

tests/lib/math/math2_test.dart

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,37 @@ class MathLibraryTest {
1414
static void testConstants() {
1515
// Source for mathematical constants is Wolfram Alpha.
1616
Expect.equals(
17-
2.7182818284590452353602874713526624977572470936999595749669, math.e);
18-
Expect.equals(2.3025850929940456840179914546843642076011014886287729760333,
19-
math.ln10);
17+
2.7182818284590452353602874713526624977572470936999595749669,
18+
math.e,
19+
);
2020
Expect.equals(
21-
0.6931471805599453094172321214581765680755001343602552541206, math.ln2);
22-
Expect.equals(1.4426950408889634073599246810018921374266459541529859341354,
23-
math.log2e);
24-
Expect.equals(0.4342944819032518276511289189166050822943970058036665661144,
25-
math.log10e);
21+
2.3025850929940456840179914546843642076011014886287729760333,
22+
math.ln10,
23+
);
2624
Expect.equals(
27-
3.1415926535897932384626433832795028841971693993751058209749, math.pi);
28-
Expect.equals(0.7071067811865475244008443621048490392848359376884740365883,
29-
math.sqrt1_2);
30-
Expect.equals(1.4142135623730950488016887242096980785696718753769480731766,
31-
math.sqrt2);
25+
0.6931471805599453094172321214581765680755001343602552541206,
26+
math.ln2,
27+
);
28+
Expect.equals(
29+
1.4426950408889634073599246810018921374266459541529859341354,
30+
math.log2e,
31+
);
32+
Expect.equals(
33+
0.4342944819032518276511289189166050822943970058036665661144,
34+
math.log10e,
35+
);
36+
Expect.equals(
37+
3.1415926535897932384626433832795028841971693993751058209749,
38+
math.pi,
39+
);
40+
Expect.equals(
41+
0.7071067811865475244008443621048490392848359376884740365883,
42+
math.sqrt1_2,
43+
);
44+
Expect.equals(
45+
1.4142135623730950488016887242096980785696718753769480731766,
46+
math.sqrt2,
47+
);
3248
}
3349

3450
static checkClose(double a, double b, EPSILON) {
@@ -130,8 +146,10 @@ class MathLibraryTest {
130146
checkVeryClose(math.sqrt2, math.sqrt(2.0));
131147
checkVeryClose(math.sqrt1_2, math.sqrt(0.5));
132148
checkVeryClose(1e50, math.sqrt(1e100));
133-
checkVeryClose(1.1111111061110855443054405046358901279277111935183977e56,
134-
math.sqrt(12345678901234e99));
149+
checkVeryClose(
150+
1.1111111061110855443054405046358901279277111935183977e56,
151+
math.sqrt(12345678901234e99),
152+
);
135153
}
136154

137155
static void testExp() {

tests/lib/math/math_parse_double_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final TESTS = [
6363
// Same, without exponential.
6464
[
6565
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625,
66-
"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625"
66+
"0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625",
6767
],
6868
[0.0, "2e-324"], // underflow 0.0
6969
[0.9999999999999999, "0.9999999999999999"], // max below 1

tests/lib/math/math_test.dart

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,37 @@ class MathTest {
1111
static void testConstants() {
1212
// Source for mathematical constants is Wolfram Alpha.
1313
Expect.equals(
14-
2.7182818284590452353602874713526624977572470936999595749669, e);
14+
2.7182818284590452353602874713526624977572470936999595749669,
15+
e,
16+
);
1517
Expect.equals(
16-
2.3025850929940456840179914546843642076011014886287729760333, ln10);
18+
2.3025850929940456840179914546843642076011014886287729760333,
19+
ln10,
20+
);
1721
Expect.equals(
18-
0.6931471805599453094172321214581765680755001343602552541206, ln2);
22+
0.6931471805599453094172321214581765680755001343602552541206,
23+
ln2,
24+
);
1925
Expect.equals(
20-
1.4426950408889634073599246810018921374266459541529859341354, log2e);
26+
1.4426950408889634073599246810018921374266459541529859341354,
27+
log2e,
28+
);
2129
Expect.equals(
22-
0.4342944819032518276511289189166050822943970058036665661144, log10e);
30+
0.4342944819032518276511289189166050822943970058036665661144,
31+
log10e,
32+
);
2333
Expect.equals(
24-
3.1415926535897932384626433832795028841971693993751058209749, pi);
34+
3.1415926535897932384626433832795028841971693993751058209749,
35+
pi,
36+
);
2537
Expect.equals(
26-
0.7071067811865475244008443621048490392848359376884740365883, sqrt1_2);
38+
0.7071067811865475244008443621048490392848359376884740365883,
39+
sqrt1_2,
40+
);
2741
Expect.equals(
28-
1.4142135623730950488016887242096980785696718753769480731766, sqrt2);
42+
1.4142135623730950488016887242096980785696718753769480731766,
43+
sqrt2,
44+
);
2945
}
3046

3147
static checkClose(double a, double b, EPSILON) {
@@ -127,8 +143,10 @@ class MathTest {
127143
checkVeryClose(sqrt2, sqrt(2.0));
128144
checkVeryClose(sqrt1_2, sqrt(0.5));
129145
checkVeryClose(1e50, sqrt(1e100));
130-
checkVeryClose(1.1111111061110855443054405046358901279277111935183977e56,
131-
sqrt(12345678901234e99));
146+
checkVeryClose(
147+
1.1111111061110855443054405046358901279277111935183977e56,
148+
sqrt(12345678901234e99),
149+
);
132150
}
133151

134152
static void testExp() {

tests/lib/math/random_test.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void checkSeed() {
145145
39797,
146146
50801,
147147
22184,
148-
58686
148+
58686,
149149
];
150150
var negative_seed_expectations = [
151151
12170,
@@ -222,7 +222,7 @@ void checkSeed() {
222222
7935,
223223
51459,
224224
36766,
225-
50711
225+
50711,
226226
];
227227
for (var i = 0, m = 1; i < 75; i++) {
228228
if (rawSeed * m < 0) {
@@ -231,7 +231,9 @@ void checkSeed() {
231231
}
232232
Expect.equals(expectations[i], new Random(rawSeed * m).nextInt(65536));
233233
Expect.equals(
234-
negative_seed_expectations[i], new Random(rawSeed * -m).nextInt(65536));
234+
negative_seed_expectations[i],
235+
new Random(rawSeed * -m).nextInt(65536),
236+
);
235237
m *= 2;
236238
}
237239
// And test zero seed too.

tests/lib/math/rectangle_test.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ testIntersection() {
4343
[
4444
[10, 10, 20, 20],
4545
[15, 15, 25, 25],
46-
[15, 15, 20, 20]
46+
[15, 15, 20, 20],
4747
],
4848
[
4949
[10, 10, 20, 20],
5050
[20, 0, 30, 10],
51-
[20, 10, 20, 10]
51+
[20, 10, 20, 10],
5252
],
5353
[
5454
[0, 0, 1, 1],
5555
[10, 11, 12, 13],
56-
null
56+
null,
5757
],
5858
[
5959
[11, 12, 98, 99],
6060
[22, 23, 34, 35],
61-
[22, 23, 34, 35]
62-
]
61+
[22, 23, 34, 35],
62+
],
6363
];
6464

6565
for (var test in tests) {
@@ -89,23 +89,23 @@ testBoundingBox() {
8989
[
9090
[10, 10, 20, 20],
9191
[15, 15, 25, 25],
92-
[10, 10, 25, 25]
92+
[10, 10, 25, 25],
9393
],
9494
[
9595
[10, 10, 20, 20],
9696
[20, 0, 30, 10],
97-
[10, 0, 30, 20]
97+
[10, 0, 30, 20],
9898
],
9999
[
100100
[0, 0, 1, 1],
101101
[10, 11, 12, 13],
102-
[0, 0, 12, 13]
102+
[0, 0, 12, 13],
103103
],
104104
[
105105
[11, 12, 98, 99],
106106
[22, 23, 34, 35],
107-
[11, 12, 98, 99]
108-
]
107+
[11, 12, 98, 99],
108+
],
109109
];
110110

111111
for (var test in tests) {
@@ -122,8 +122,11 @@ testContainsRectangle() {
122122
var r = Rectangle(-10, 0, 20, 10);
123123
Expect.isTrue(r.containsRectangle(r));
124124

125-
Expect.isFalse(r.containsRectangle(
126-
Rectangle(double.nan, double.nan, double.nan, double.nan)));
125+
Expect.isFalse(
126+
r.containsRectangle(
127+
Rectangle(double.nan, double.nan, double.nan, double.nan),
128+
),
129+
);
127130

128131
var r2 = Rectangle(0, 2, 5, 5);
129132
Expect.isTrue(r.containsRectangle(r2));

0 commit comments

Comments
 (0)