Make clear map function name more concise

Renam resetting the grid to clearMap.
This commit is contained in:
Unknown 2018-10-21 14:00:01 +02:00
parent 66c273c783
commit e115ed2f48
3 changed files with 10 additions and 10 deletions

View file

@ -18,7 +18,7 @@ class SimulationService {
}
void reset() {
_sim.reset();
_sim.clearMap();
}
void addRandomPattern() {

View file

@ -30,12 +30,12 @@ class Simulation {
}
Simulation(int w, int h) : this.map = new Grid(w, h) {
this.map = reset();
this.map = clearMap();
}
Simulation.fromGrid(Grid<bool> map) : this.map = map;
Grid<bool> reset([Grid<bool> map]) {
Grid<bool> clearMap(Grid<bool> map) {
map ??= this.map;
// dirty = true;
// map.setAll(0, List.filled(map.length, false));

View file

@ -1,9 +1,9 @@
import 'dart:math';
import 'package:mockito/mockito.dart';
import 'package:rules_of_living/src/Grid.dart';
import 'package:test/test.dart';
import 'package:rules_of_living/src/Simulation.dart';
import 'package:test/test.dart';
class MockGrid extends Mock implements Grid<bool> {}
@ -25,20 +25,20 @@ void main() {
var oldMap = sut.map;
sut.gridSize = Point(10, 10);
expect(sut.map, isNot(same(oldMap)));
});
}, tags: "nobrowser");
});
group("resetMap", () {
test("sets the internal map filled with 'false' ", () {
sut.map.set(1, 1, true);
sut.reset();
sut.clearMap();
expect(sut.map, allOf(TypeMatcher<Grid>(), isNot(contains(true))));
});
test("sets the simulation to need re-rendering", () {
sut.dirty = false;
sut.reset();
sut.clearMap();
expect(sut.dirty, true);
});
});
}, tags: "nobrowser");
group("save&load", () {
test(
"saves a copy of the map which does not change when the actual map changes",
@ -49,5 +49,5 @@ void main() {
expect(sut.loadSnapshot(), isNot(equals(snapshot)));
});
});
}, tags: "nobrowser");
}