anchor.diff:    late TestCode code;
     List<FoldingRegion> regions = [];
   
  +  /// Expects no [FoldingRegion]s.
  +  ///
  +  /// If [onlyVerify] is provided, folding regions of other kinds are allowed.
  +  void expectNoRegions({Set<FoldingKind>? onlyVerify}) {
  +    expectRegions({}, onlyVerify: onlyVerify);
  +  }
  +
     /// Expects to find a [FoldingRegion] for the code marked [index] with a
     /// [FoldingKind] of [kind].
  -  void expectRegions(Map<int, FoldingKind> expected) {
  +  ///
  +  /// If [onlyVerify] is provided, only folding regions with matching kinds will
  +  /// be verified.
  +  void expectRegions(Map<int, FoldingKind> expected,
  +      {Set<FoldingKind>? onlyVerify}) {
       final expectedRegions = expected.entries.map((entry) {
         final range = code.ranges[entry.key].sourceRange;
         return FoldingRegion(entry.value, range.offset, range.length);
       }).toSet();
   
  -    expect(regions, expectedRegions);
  +    final actualRegions = onlyVerify == null
  +        ? regions.toSet()
  +        : regions.where((region) => onlyVerify.contains(region.kind)).toSet();
  +
  +    expect(actualRegions, expectedRegions);
     }
   
     @override
  
positive.code:     sourcePath = convertPath('$testPackageLibPath/test.dart');
    }
  
    Future<void> test_annotations() async {
      var content = '''
  @myMultilineAnnotation/*[0*/(
    "this",
    "is a test"
  )/*0]*/
  void f() {}
  
  @noFoldNecessary
  main2() {}
  
  @multipleAnnotations1/*[1*/(
    "this",
    "is a test"
  )
  @multipleAnnotations2()
  @multipleAnnotations3/*1]*/
  main3() {}
  
  @noFoldsForSingleClassAnnotation
  class MyClass {}
  
  @folded.classAnnotation1/*[2*/()
  @foldedClassAnnotation2/*2]*/
  class MyClass2 {/*[3*/
    @fieldAnnotation1/*[4*/
    @fieldAnnotation2/*4]*/
    int myField;
  
    @getterAnnotation1/*[5*/
    @getterAnnotation2/*5]*/
    int get myThing => 1;
  
    @setterAnnotation1/*[6*/
    @setterAnnotation2/*6]*/
    void set myThing(int value) {}
  
    @methodAnnotation1/*[7*/
    @methodAnnotation2/*7]*/
    void myMethod() {}
  
    @constructorAnnotation1/*[8*/
    @constructorAnnotation1/*8]*/
    MyClass2() {}
  /*3]*/}
  ''';
  
      await _computeRegions(content);
      expectRegions({
        0: FoldingKind.ANNOTATIONS,
        1: FoldingKind.ANNOTATIONS,
        2: FoldingKind.ANNOTATIONS,
        3: FoldingKind.CLASS_BODY,
        4: FoldingKind.ANNOTATIONS,
        5: FoldingKind.ANNOTATIONS,
        6: FoldingKind.ANNOTATIONS,
        7: FoldingKind.ANNOTATIONS,
        8: FoldingKind.ANNOTATIONS,
      });
    }
  
    Future<void> test_assertInitializer() async {
      var content = '''
  class C {/*1:INC*/
    C() : assert(/*2:INC*/
      true,
      ''
    /*2:INC:INVOCATION*/);
  /*1:INC:CLASS_BODY*/}
  ''';
      final regions = await _computeRegions(content);
      _compareRegions(regions, content);
    }
  
    Future<void> test_assertStatement() async {
      var content = '''
  void f() {/*1:INC*/
    assert(/*2:INC*/
      true,
      ''
    /*2:INC:INVOCATION*/);
  /*1:INC:FUNCTION_BODY*/}
  ''';
      final regions = await _computeRegions(content);
      _compareRegions(regions, content);
    }
  
    Future<void> test_class() async {
      var content = '''
  // Content before
  
  class Person {/*1:INC*/
    Person() {/*2:INC*/
      print("Hello, world!");
    /*2:INC:FUNCTION_BODY*/}
  
    void sayHello() {/*3:INC*/
      print("Hello, world!");
    /*3:INC:FUNCTION_BODY*/}
  /*1:INC:CLASS_BODY*/}
  
  // Content after
  ''';
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content);
    }
  
    Future<void> test_comment_is_not_considered_file_header() async {
      var content = """
  // This is not the file header/*1:EXC*/
  // It's just a comment/*1:INC:COMMENT*/
  void f() {}
  """;
  
      // Since there are no region comment markers above
      // just check the length instead of the contents
      final regions = await _computeRegions(content);
      _compareRegions(regions, content);
    }
  
    Future<void> test_comment_multiline() async {
      var content = '''
  void f() {
  /*/*1:EXC*/
   * comment 1
   *//*1:EXC:COMMENT*/
  
  /* this comment starts on the same line as delimeters/*2:EXC*/
   * second line
   *//*2:EXC:COMMENT*/
  }
  ''';
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content, commentKinds);
    }
  
    Future<void> test_comment_singleFollowedByBlankLine() async {
      var content = '''
  void f() {
  // this is/*1:EXC*/
  // a comment/*1:INC:COMMENT*/
  /// this is not part of it
  }
  ''';
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content, commentKinds);
    }
  
    Future<void> test_comment_singleFollowedByMulti() async {
      var content = '''
  void f() {
    // this is/*1:EXC*/
    // a comment/*1:INC:COMMENT*/
    /* this is not part of it */
    String foo;
  }
  ''';
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content, commentKinds);
    }
  
    Future<void> test_comment_singleFollowedByTripleSlash() async {
      var content = '''
  void f() {
  // this is/*1:EXC*/
  // a comment/*1:INC:COMMENT*/
  /// this is not part of it
  }
  ''';
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content, commentKinds);
    }
  
    Future<void> test_constructor_invocations() async {
      var content = '''
  // Content before
  
  void f() {/*1:INC*/
    return new Text(/*2:INC*/
      "Hello, world!",
    /*2:INC:INVOCATION*/);
  /*1:INC:FUNCTION_BODY*/}
  
  // Content after
  ''';
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content);
    }
  
    Future<void> test_file_header() async {
      var content = """
  // Copyright some year by some people/*1:EXC*/
  // See LICENCE etc./*1:INC:FILE_HEADER*/
  
  // This is not the file header
  // It's just a comment
  void f() {}
  """;
  
      final regions = await _computeRegions(content);
      _compareRegions(regions, content, {FoldingKind.FILE_HEADER});
    }
  
    Future<void> test_file_header_does_not_include_block_comments() async {
  
negative.code: void f() {}
  """;
  
      await _computeRegions(content);
      expectNoRegions();
    }
  
    Future<void> _computeRegions(String sourceContent) async {
      code = TestCode.parse(sourceContent);
      newFile(sourcePath, code.code);
      var result =
          await (await session).getResolvedUnit(sourcePath) as ResolvedUnitResult;
      var computer = DartUnitFoldingComputer(result.lineInfo, result.unit);
      regions = computer.compute();
    }
  }
  