From 9bf90e5314792036d3bf461b5a8f63fc853595ff Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 20 Aug 2024 10:43:53 -0700 Subject: [PATCH] Add a prefixes test for prefix references (#3837) --- test/prefixes_test.dart | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 test/prefixes_test.dart diff --git a/test/prefixes_test.dart b/test/prefixes_test.dart new file mode 100644 index 0000000000..f7d10c26bc --- /dev/null +++ b/test/prefixes_test.dart @@ -0,0 +1,51 @@ +// Copyright (c) 2024, 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 'package:test/test.dart'; +import 'package:test_reflective_loader/test_reflective_loader.dart'; + +import 'dartdoc_test_base.dart'; +import 'src/utils.dart'; + +void main() { + defineReflectiveSuite(() { + defineReflectiveTests(PrefixesTest); + }); +} + +@reflectiveTest +class PrefixesTest extends DartdocTestBase { + @override + String get libraryName => 'prefixes'; + + void test_referenced() async { + var library = await bootPackageWithLibrary( + ''' +import 'dart:async' as async; + +/// Text [async]. +int x = 0; +''', + additionalArguments: ['--link-to-remote'], + ); + var f = library.properties.named('x'); + // There is no link, but also no wrong link or crash. + expect(f.documentationAsHtml, '

Text async.

'); + } + + void test_referenced_wildcard() async { + var library = await bootPackageWithLibrary( + ''' +import 'dart:async' as _; + +/// Text [_]. +int x = 0; +''', + additionalArguments: ['--link-to-remote'], + ); + var f = library.properties.named('x'); + // There is no link, but also no wrong link or crash. + expect(f.documentationAsHtml, '

Text _.

'); + } +}