Merge branch 'main' into feat/add-plunger

pull/25/head^2
Alejandro Santiago 4 years ago committed by GitHub
commit 8b82cd8d45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,18 @@
name: geometry
on:
push:
paths:
- "packages/geometry/**"
- ".github/workflows/geometry.yaml"
pull_request:
paths:
- "packages/geometry/**"
- ".github/workflows/geometry.yaml"
jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_package.yml@v1
with:
working_directory: packages/geometry

@ -22,9 +22,4 @@ class BallScorePointsCallback extends ContactCallback<Ball, ScorePoints> {
) {
ball.gameRef.read<GameBloc>().add(Scored(points: scorePoints.points));
}
// TODO(alestiago): remove once this issue is closed.
// https://github.com/flame-engine/flame/issues/1414
@override
void end(Ball _, ScorePoints __, Contact ___) {}
}

@ -77,7 +77,4 @@ class BottomWallBallContactCallback extends ContactCallback<Ball, BottomWall> {
void begin(Ball ball, BottomWall wall, Contact contact) {
ball.lost();
}
@override
void end(_, __, ___) {}
}

@ -1,5 +1,6 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
import 'package:vector_math/vector_math_64.dart';
/// Calculates all [Vector2]s of a circumference.
///

@ -7,13 +7,9 @@ environment:
sdk: ">=2.16.0 <3.0.0"
dependencies:
flame: ^1.0.0
flutter:
sdk: flutter
vector_math: ^2.1.1
dev_dependencies:
flutter_test:
sdk: flutter
mocktail: ^0.2.0
test: ^1.19.2
very_good_analysis: ^2.4.0

@ -1,7 +1,8 @@
// ignore_for_file: prefer_const_constructors, cascade_invocations
import 'package:flame/extensions.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:geometry/geometry.dart';
import 'package:test/test.dart';
import 'package:vector_math/vector_math_64.dart';
class Binomial {
Binomial({required this.n, required this.k});
@ -42,18 +43,18 @@ void main() {
],
step: 2,
),
throwsAssertionError,
throwsA(isA<AssertionError>()),
);
});
test('fails if not enough control points', () {
expect(
() => calculateBezierCurve(controlPoints: [Vector2.zero()]),
throwsAssertionError,
throwsA(isA<AssertionError>()),
);
expect(
() => calculateBezierCurve(controlPoints: []),
throwsAssertionError,
throwsA(isA<AssertionError>()),
);
});
@ -81,15 +82,24 @@ void main() {
group('binomial', () {
test('fails if k is negative', () {
expect(() => binomial(1, -1), throwsAssertionError);
expect(
() => binomial(1, -1),
throwsA(isA<AssertionError>()),
);
});
test('fails if n is negative', () {
expect(() => binomial(-1, 1), throwsAssertionError);
expect(
() => binomial(-1, 1),
throwsA(isA<AssertionError>()),
);
});
test('fails if n < k', () {
expect(() => binomial(1, 2), throwsAssertionError);
expect(
() => binomial(1, 2),
throwsA(isA<AssertionError>()),
);
});
test('for a specific input gives a correct value', () {
@ -131,7 +141,7 @@ void main() {
group('factorial', () {
test('fails if negative number', () {
expect(() => factorial(-1), throwsAssertionError);
expect(() => factorial(-1), throwsA(isA<AssertionError>()));
});
test('for a specific input gives a correct value', () {

@ -11,7 +11,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('Anchor', () {
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
flameTester.test(
'loads correctly',

@ -13,7 +13,7 @@ void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('Ball', () {
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
flameTester.test(
'loads correctly',

@ -12,7 +12,7 @@ import '../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
group(
'Flipper',
() {

@ -10,7 +10,7 @@ import '../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
group('Pathway', () {
const width = 50.0;

@ -13,7 +13,7 @@ import '../../helpers/helpers.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
group('Plunger', () {
const compressionDistance = 0.0;

@ -32,7 +32,7 @@ void main() {
},
);
});
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
flameTester.test(
'loads correctly',

@ -10,7 +10,7 @@ import '../helpers/helpers.dart';
void main() {
group('PinballGame', () {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(PinballGameX.initial);
final flameTester = FlameTester(PinballGameTest.create);
// TODO(alestiago): test if [PinballGame] registers
// [BallScorePointsCallback] once the following issue is resolved:

@ -1,13 +1,14 @@
import 'package:flame_test/flame_test.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball_theme/pinball_theme.dart';
import 'helpers.dart';
FlameTester<PinballGame> flameBlocTester({
required GameBloc gameBloc,
}) {
return FlameTester<PinballGame>(
PinballGameX.initial,
PinballGameTest.create,
pumpWidget: (gameWidget, tester) async {
await tester.pumpWidget(
BlocProvider.value(
@ -18,11 +19,3 @@ FlameTester<PinballGame> flameBlocTester({
},
);
}
extension PinballGameX on PinballGame {
static PinballGame initial() => PinballGame(
theme: const PinballTheme(
characterTheme: DashTheme(),
),
);
}

@ -0,0 +1,12 @@
import 'package:pinball/game/game.dart';
import 'package:pinball_theme/pinball_theme.dart';
/// [PinballGame] extension to reduce boilerplate in tests.
extension PinballGameTest on PinballGame {
/// Create [PinballGame] with default [PinballTheme].
static PinballGame create() => PinballGame(
theme: const PinballTheme(
characterTheme: DashTheme(),
),
);
}

@ -1,11 +1,11 @@
// Copyright (c) 2021, Very Good Ventures
// https://verygood.ventures
//
// Copyright (c) 2021, Very Good Ventures
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
// https://verygood.ventures
// license that can be found in the LICENSE file or at
export 'builders.dart';
export 'extensions.dart';
export 'key_testers.dart';
export 'mocks.dart';
export 'pump_app.dart';

Loading…
Cancel
Save