Skip to content

Commit

Permalink
more imprecision
Browse files Browse the repository at this point in the history
  • Loading branch information
renancaraujo committed Dec 16, 2024
1 parent 9a08369 commit 451a8c6
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void main() {

const dt = 0.11;
for (var i = 0; i < 20; i++) {
expect(followTarget, closeToVector(Vector2(3, 1 + i * dt), 1e-14));
expect(followTarget, closeToVector(Vector2(3, 1 + i * dt), 1e-6));
game.update(dt);
}
});
Expand All @@ -91,7 +91,7 @@ void main() {
game.update(0.01);
expect(
pursuer.position,
closeToVector(target.position, 1e-12),
closeToVector(target.position, 1e-4),
);
}
});
Expand All @@ -111,7 +111,7 @@ void main() {
final distance = speed * i * dt;
expect(
pursuer.position,
closeToVector(Vector2(distance * 0.6, distance * 0.8), 1e-12),
closeToVector(Vector2(distance * 0.6, distance * 0.8), 1e-3),
);
game.update(dt);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/flame/test/camera/viewfinder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ void main() {
for (var t = 0.0; t < 1.0; t += 0.1) {
expect(
camera.viewfinder.position,
closeToVector(Vector2(5 * t, 13 * t), 1e-14),
closeToVector(Vector2(5 * t, 13 * t), 1e-6),
);
expect(
camera.viewport.position,
closeToVector(Vector2(40 * t, -77 * t), 1e-12),
closeToVector(Vector2(40 * t, -77 * t), 1e-5),
);
game.update(0.1);
}
Expand Down Expand Up @@ -174,7 +174,7 @@ void main() {
await game.ready();

for (var t = 0.0; t < 1.0; t += 0.1) {
expect(camera.viewfinder.zoom, closeTo(1 + t, 1e-14));
expect(camera.viewfinder.zoom, closeTo(1 + t, 1e-6));
game.update(0.1);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void main() {
final width = random.nextDouble() * 1000.0 + 10.0;
final height = random.nextDouble() * 1000.0 + 10.0;
game.onGameResize(Vector2(width, height));
expect(viewport.size.x == width || viewport.size.y == height, true);
expect(viewport.size.x / viewport.size.y, closeTo(2.0, 1e-10));

expect(viewport.size.x / viewport.size.y, closeTo(2.0, 1e-6));
if (viewport.size.x == width) {
expect(viewport.position.x, 0);
expect(
Expand Down
8 changes: 4 additions & 4 deletions packages/flame/test/effects/anchor_by_effect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ void main() {
AnchorEffect.by(Vector2(0.3, 0.5), EffectController(duration: 1)),
);
for (var t = 0.0; t <= 1.0; t += 0.1) {
expect(component.anchor.x, closeTo(0.5 + 0.3 * t, 1e-15));
expect(component.anchor.y, closeTo(0.5 + 0.5 * t, 1e-15));
expect(component.anchor.x, closeTo(0.5 + 0.3 * t, 13-6));
expect(component.anchor.y, closeTo(0.5 + 0.5 * t, 13-6));
game.update(0.1);
}
});
Expand All @@ -37,8 +37,8 @@ void main() {
await game.ready();

for (var t = 0.0; t <= 1.0; t += 0.1) {
expect(component.anchor.x, closeTo(0.5 - 0.2 * t, 1e-15));
expect(component.anchor.y, closeTo(0.0 + 0.6 * t, 1e-15));
expect(component.anchor.x, closeTo(0.5 - 0.2 * t, 13-6));
expect(component.anchor.y, closeTo(0.0 + 0.6 * t, 13-6));
game.update(0.1);
}
});
Expand Down
12 changes: 6 additions & 6 deletions packages/flame/test/effects/scale_effect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ void main() {
);

game.update(1);
expect(component.scale.x, closeTo(0.7, 1e-15)); // (1 + 0.4) * 0.5
expect(component.scale.y, closeTo(-0.7, 1e-15));
expect(component.scale.x, closeTo(0.7, 1e-6)); // (1 + 0.4) * 0.5
expect(component.scale.y, closeTo(-0.7, 1e-6));
game.update(1);
expect(component.scale.x, closeTo(1.8, 1e-15)); // (1 + 2*0.4) * 1
expect(component.scale.y, closeTo(-1.8, 1e-15));
expect(component.scale.x, closeTo(1.8, 1e-6)); // (1 + 2*0.4) * 1
expect(component.scale.y, closeTo(-1.8, 1e-6));
for (var i = 0; i < 8; i++) {
game.update(1);
}
expect(component.scale.x, closeTo(5, 1e-15));
expect(component.scale.y, closeTo(-5, 1e-15));
expect(component.scale.x, closeTo(5, 1e-6));
expect(component.scale.y, closeTo(-5, 1e-6));
game.update(0);
expect(component.children.length, 0);
});
Expand Down
14 changes: 7 additions & 7 deletions packages/flame/test/effects/sequence_effect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void main() {
);
expect(
effect.controller.duration,
closeTo(randomEffect.controller.duration! * 2000, 1e-15),
closeTo(randomEffect.controller.duration! * 2000, 1e-6),
);
expect(effect.controller.isRandom, true);
});
Expand Down Expand Up @@ -105,7 +105,7 @@ void main() {
Vector2(30, 40),
];
for (final p in expectedPositions) {
expect(component.position, closeToVector(p, 1e-12));
expect(component.position, closeToVector(p, 1e-5));
game.update(0.1);
}
});
Expand Down Expand Up @@ -171,7 +171,7 @@ void main() {
for (var i = 10.0; i > 0; i--) Vector2(i, 0),
];
for (final p in expectedPath) {
expect(component.position, closeToVector(p, 1e-14));
expect(component.position, closeToVector(p, 1e-6));
game.update(0.1);
}
game.update(0.001);
Expand Down Expand Up @@ -205,11 +205,11 @@ void main() {
...forwardPath.reversed,
];
for (final p in expectedPath) {
expect(component.position, closeToVector(p, 1e-14));
expect(component.position, closeToVector(p, 1e-5));
game.update(0.1);
}
game.update(0.001);
expect(component.position, closeToVector(Vector2.zero()));
expect(component.position, closeToVector(Vector2.zero(), 1e-5));
expect(effect.controller.completed, true);
});

Expand All @@ -233,7 +233,7 @@ void main() {
testWithFlameGame('sequence in sequence', (game) async {
EffectController duration(double t) => EffectController(duration: t);
const dt = 0.01;
const x0 = 0.0;
const x0 = 0.0;S

Check notice on line 236 in packages/flame/test/effects/sequence_effect_test.dart

View workflow job for this annotation

GitHub Actions / analyze-latest

Unnecessary statement.

Try completing the statement or breaking it up. See https://dart.dev/diagnostics/unnecessary_statements to learn more about this problem.

Check failure on line 236 in packages/flame/test/effects/sequence_effect_test.dart

View workflow job for this annotation

GitHub Actions / analyze-latest

Undefined name 'S'.

Try correcting the name to one that is defined, or defining the name. See https://dart.dev/diagnostics/undefined_identifier to learn more about this problem.

Check notice on line 236 in packages/flame/test/effects/sequence_effect_test.dart

View workflow job for this annotation

GitHub Actions / analyze

Unnecessary statement.

Try completing the statement or breaking it up. See https://dart.dev/diagnostics/unnecessary_statements to learn more about this problem.

Check failure on line 236 in packages/flame/test/effects/sequence_effect_test.dart

View workflow job for this annotation

GitHub Actions / analyze

Undefined name 'S'.

Try correcting the name to one that is defined, or defining the name. See https://dart.dev/diagnostics/undefined_identifier to learn more about this problem.
const y0 = 0.0;
const x1 = 10.0;
const y1 = 10.0;
Expand Down Expand Up @@ -314,7 +314,7 @@ void main() {
...forwardPath.reversed,
];
for (final p in expectedPath) {
expect(component.position, closeToVector(p, 1e-12));
expect(component.position, closeToVector(p, 1e-3));
game.update(dt);
}
game.update(1e-5);
Expand Down
2 changes: 1 addition & 1 deletion packages/flame/test/effects/size_effect_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void main() {
game.update(1000 - totalTime);
// Typically, `component.size` could accumulate numeric discrepancy on the
// order of 1e-11 .. 1e-12 by now.
expect(component.size, closeToVector(Vector2(0, 0), 1e-10));
expect(component.size, closeToVector(Vector2(0, 0), 1e-6));
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void main() {
final expected = rect.support(direction) + circle.support(direction);
expect(
rrect.support(direction),
closeToVector(expected, 1e-14),
closeToVector(expected, 1e-5),
);
}
});
Expand Down Expand Up @@ -238,7 +238,7 @@ void main() {
);
expect(
rrect.nearestPoint(Vector2(0, -10)),
Vector2(5.52786404500042, 1.0557280900008408),
Vector2(5.52786404500042, 1.0557279586791992),
);
expect(rrect.nearestPoint(Vector2(10, -10)), Vector2(10, 0));
expect(rrect.nearestPoint(Vector2(30, -10)), Vector2(30, 0));
Expand Down

0 comments on commit 451a8c6

Please sign in to comment.