// Copyright (c) 2022, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'common/service_test_common.dart';
import 'common/test_helper.dart';

// AUTOGENERATED START
//
// Update these constants by running:
//
// dart pkg/vm_service/test/update_line_numbers.dart pkg/vm_service/test/breakpoint_in_enhanced_enums_test.dart
//
const LINE_A = 26;
const LINE_B = 37;
const LINE_C = 41;
const LINE_D = 45;
const LINE_E = 50;
const LINE_F = 54;
const LINE_G = 59;
const LINE_H = 64;
// AUTOGENERATED END

mixin M on Object {
  int mixedInMethod() {
    print('mixedInMethod'); // LINE_A
    return 0;
  }
}

enum E with M {
  e1,
  e2,
  e3;

  void instanceMethod() {
    print('instanceMethod'); // LINE_B
  }

  static void staticMethod() {
    print('staticMethod'); // LINE_C
  }

  int get getter {
    print('getter'); // LINE_D
    return 0;
  }

  set setter(int x) {
    print('setter'); // LINE_E
  }

  static int get staticGetter {
    print('staticGetter'); // LINE_F
    return 0;
  }

  static set staticSetter(int x) {
    print('staticSetter'); // LINE_G
  }

  @override
  String toString() {
    print('overridden toString'); // LINE_H
    return '';
  }
}

void testMain() {
  E.staticMethod();
  E.staticGetter;
  E.staticSetter = 42;
  final e = E.e1;
  e.mixedInMethod();
  e.instanceMethod();
  e.getter;
  e.setter = 42;
  e.toString();
}

const lines = <int>[
  LINE_C,
  LINE_F,
  LINE_G,
  LINE_A,
  LINE_B,
  LINE_D,
  LINE_E,
  LINE_H,
];

const fileName = 'breakpoint_in_enhanced_enums_test.dart';
final expected = <String>[
  for (final line in lines) '$fileName:$line:5',
];

final stops = <String>[];

final tests = <IsolateTest>[
  hasPausedAtStart,
  for (final line in lines) setBreakpointAtLine(line),
  resumeProgramRecordingStops(stops, false),
  checkRecordedStops(stops, expected),
];

Future<void> main([args = const <String>[]]) => runIsolateTests(
      args,
      tests,
      fileName,
      testeeConcurrent: testMain,
      pauseOnStart: true,
      pauseOnExit: true,
    );
