testing library
Reading a game's sound table out of its own source, for the one check no type can make.
import 'package:flutter3d_audio/testing.dart';
final it = soundTableIn('lib/src/sounds.dart');
expect(it.declared.difference(it.inTheBank), isEmpty);
A SoundBank removes the second list and cannot remove this. There is
nothing left that has to agree with anything — the bank is the list a mixer
preloads — but a static const SoundDef declared beside it and left out of
it is invisible to every type in Dart, because there is no reflection to ask
a class what it holds. The source is the only place that knows, and it is the
same source the compiler reads.
It is worth the ugliness: the platformer shipped for months with six of its fourteen sounds declared and not banked, and the game was half mute.
Why this is here rather than in each game
Because it was in three of them, twice each — _declared and _inTheBank,
the same two regular expressions copied — and a scan in three copies is two
copies that will stop matching the day somebody reformats a bank.
It returns the two sets rather than asserting on them. Asserting would mean
flutter_test as a real dependency of a package that ships to a browser, to
save each caller three lines.