Michael Goderbauer 5491c8c146
Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
2024-12-19 20:06:21 +00:00

63 lines
1.8 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/physics.dart';
import 'package:flutter_test/flutter_test.dart';
class TestSimulation extends Simulation {
@override
double x(double t) => 0.0;
@override
double dx(double t) => 0.0;
@override
bool isDone(double t) => true;
}
void main() {
test('Simulation.toString', () {
expect(
ClampedSimulation(
TestSimulation(),
xMin: -1.0,
xMax: 2.0,
dxMin: -3.0,
dxMax: 4.0,
).toString(),
'ClampedSimulation(simulation: TestSimulation, x: -1.0..2.0, dx: -3.0..4.0)',
);
expect(TestSimulation().toString(), 'TestSimulation');
expect(
GravitySimulation(1.0, -2.0, 3.0, -4.0).toString(),
'GravitySimulation(g: 1.0, x₀: -2.0, dx₀: -4.0, xₘₐₓ: ±3.0)',
);
expect(
FrictionSimulation(1.0, -2.0, 3.0).toString(),
'FrictionSimulation(cₓ: 1.0, x₀: -2.0, dx₀: 3.0)',
);
expect(
BoundedFrictionSimulation(1.0, -2.0, 3.0, -4.0, 5.0).toString(),
'BoundedFrictionSimulation(cₓ: 1.0, x₀: -2.0, dx₀: 3.0, x: -4.0..5.0)',
);
expect(
const SpringDescription(mass: 1.0, stiffness: -2.0, damping: 3.0).toString(),
'SpringDescription(mass: 1.0, stiffness: -2.0, damping: 3.0)',
);
expect(
SpringDescription.withDampingRatio(mass: 1.0, stiffness: 9.0).toString(),
'SpringDescription(mass: 1.0, stiffness: 9.0, damping: 6.0)',
);
expect(
SpringSimulation(
const SpringDescription(mass: 1.0, stiffness: 2.0, damping: 3.0),
0.0,
1.0,
2.0,
).toString(),
'SpringSimulation(end: 1.0, SpringType.overDamped)',
);
});
}