import 'dart:io';

import 'package:flutter_test/flutter_test.dart';

/// The game engine must stay pure Dart: unit-testable headless, reusable by
/// the stage generator CLI, and free of widget-layer coupling.
void main() {
  test('lib/game and lib/core never import Flutter', () {
    final dirs = [Directory('lib/game'), Directory('lib/core')];
    final violations = <String>[];
    for (final dir in dirs) {
      for (final entity in dir.listSync(recursive: true)) {
        if (entity is! File || !entity.path.endsWith('.dart')) continue;
        final source = entity.readAsStringSync();
        if (source.contains("import 'package:flutter") ||
            source.contains('import "package:flutter')) {
          violations.add(entity.path);
        }
      }
    }
    expect(violations, isEmpty,
        reason: 'Flutter imports found in pure-Dart layers: $violations');
  });
}
