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)); 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) { void begin(Ball ball, BottomWall wall, Contact contact) {
ball.lost(); ball.lost();
} }
@override
void end(_, __, ___) {}
} }

@ -1,5 +1,6 @@
import 'dart:math' as math; 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. /// Calculates all [Vector2]s of a circumference.
/// ///

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

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

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

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

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

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

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

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

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

@ -1,13 +1,14 @@
import 'package:flame_test/flame_test.dart'; import 'package:flame_test/flame_test.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
import 'package:pinball_theme/pinball_theme.dart';
import 'helpers.dart';
FlameTester<PinballGame> flameBlocTester({ FlameTester<PinballGame> flameBlocTester({
required GameBloc gameBloc, required GameBloc gameBloc,
}) { }) {
return FlameTester<PinballGame>( return FlameTester<PinballGame>(
PinballGameX.initial, PinballGameTest.create,
pumpWidget: (gameWidget, tester) async { pumpWidget: (gameWidget, tester) async {
await tester.pumpWidget( await tester.pumpWidget(
BlocProvider.value( 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 // 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://opensource.org/licenses/MIT.
// https://verygood.ventures
// license that can be found in the LICENSE file or at
export 'builders.dart'; export 'builders.dart';
export 'extensions.dart';
export 'key_testers.dart'; export 'key_testers.dart';
export 'mocks.dart'; export 'mocks.dart';
export 'pump_app.dart'; export 'pump_app.dart';

Loading…
Cancel
Save