Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(754)

Unified Diff: samples/third_party/pop-pop-win/test/ppw/test_field.dart

Issue 200723008: samples/poppopwin: upgrade to first-class sample (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed pkgbuild.status for rename Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: samples/third_party/pop-pop-win/test/ppw/test_field.dart
diff --git a/samples/third_party/pop-pop-win/test/ppw/test_field.dart b/samples/third_party/pop-pop-win/test/ppw/test_field.dart
deleted file mode 100644
index 7ddacbed9aa7c8e0857a795145f2beb4cd743417..0000000000000000000000000000000000000000
--- a/samples/third_party/pop-pop-win/test/ppw/test_field.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-part of ppw_test;
-
-class TestField {
- // This grid
- // XXXXX2
- // X7X8X3
- // X5XXX2
- // X32321
- // 110000
-
- static const sample = const
- [null, null, null, null, null, 2,
- null, 7, null, 8, null, 3,
- null, 5, null, null, null, 2,
- null, 3, 2, 3, 2, 1,
- 1, 1, 0, 0, 0, 0];
-
-
- static Field getSampleField() {
- final bools = new List<bool>.from(sample.map((x) => x == null));
-
- return new Field.fromSquares(6, 5, bools);
- }
-
- static void run() {
- group('Field', () {
- test('defaults', _testDefaults);
- test('bombCount', _testBombCount);
- test('fromSquares', _testFromSquares);
- test('adjacent', _testAdjacent);
- });
- }
-
- static void _testDefaults() {
- final f = new Field();
-
- expect(f.bombCount, equals(40));
- expect(f.height, equals(16));
- expect(f.width, equals(16));
- }
-
- static void _testBombCount() {
- final f = new Field();
-
- int bombCount = 0;
- for(int x = 0; x < 16; x++) {
- for(int y = 0; y < 16; y++) {
- if(f.get(x, y)) {
- bombCount++;
- }
- }
- }
- expect(bombCount, equals(f.bombCount));
- }
-
- static void _testFromSquares() {
- final f = new Field.fromSquares(2, 2, [true, true, true, false]);
- expect(f.height, equals(2));
- expect(f.width, equals(2));
- expect(f.bombCount, equals(3));
- }
-
- static void _testAdjacent() {
- final f = getSampleField();
-
- expect(f.bombCount, equals(13));
-
- for(int x = 0; x < f.width; x++) {
- for(int y = 0; y < f.height; y++) {
- final i = x + y * f.width;
- final adj = f.getAdjacentCount(x, y);
- expect(adj, equals(sample[i]));
- }
- }
- }
-}
« no previous file with comments | « samples/third_party/pop-pop-win/test/ppw/_ppw_runner.dart ('k') | samples/third_party/pop-pop-win/test/ppw/test_game.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698