Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/dartdoc_test_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class DartdocTestBase {

String get sdkConstraint => '>=3.3.0 <4.0.0';

List<String> get experiments => [];
List<String> get experiments => ['wildcards'];

bool get skipUnreachableSdkLibraries => true;

Expand Down
44 changes: 42 additions & 2 deletions test/parameter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,48 @@ void main() {
class ParameterTest extends DartdocTestBase {
@override
String get libraryName => 'parameters';
@override
String get sdkConstraint => '>=2.17.0 <3.0.0';

void test_formalParameter_referenced() async {
var library = await bootPackageWithLibrary('''
/// Text [p].
void f(int p) {}
''');
var f = library.functions.named('f');
// There is no link, but also no wrong link or crash.
expect(f.documentationAsHtml, '<p>Text <code>p</code>.</p>');
}

void test_formalParameter_referenced_notShadowedElement() async {
var library = await bootPackageWithLibrary('''
/// Text [p].
void f(int p) {}
var p = 0;
''');
var f = library.functions.named('f');
// There is no link, but also no wrong link or crash.
expect(f.documentationAsHtml, '<p>Text <code>p</code>.</p>');
}

void test_formalParameter_referenced_notShadowedPrefix() async {
var library = await bootPackageWithLibrary('''
import 'dart:async' as p;
/// Text [p].
void f(int p) {}
''');
var f = library.functions.named('f');
// There is no link, but also no wrong link or crash.
expect(f.documentationAsHtml, '<p>Text <code>p</code>.</p>');
}

void test_formalParameter_referenced_wildcard() async {
var library = await bootPackageWithLibrary('''
/// Text [_].
void f(int _) {}
''');
var f = library.functions.named('f');
// There is no link, but also no wrong link or crash.
expect(f.documentationAsHtml, '<p>Text <code>_</code>.</p>');
}

void test_formalParameter_generic_method() async {
var library = await bootPackageWithLibrary('''
Expand Down
54 changes: 54 additions & 0 deletions test/type_parameter_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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(TypeParameterTest);
});
}

@reflectiveTest
class TypeParameterTest extends DartdocTestBase {
@override
String get libraryName => 'type_parameters';

void test_referenced() async {
var library = await bootPackageWithLibrary('''
/// Text [T].
void f<T>(int p) {}
typedef T = int;
''');
var f = library.functions.named('f');
// There is no link, but also no wrong link or crash.
expect(f.documentationAsHtml, '<p>Text <code>T</code>.</p>');
}

void test_referenced_wildcard() async {
var library = await bootPackageWithLibrary('''
/// Text [_].
void f<_>() {}
''');
var f = library.functions.named('f');
// There is no link, but also no wrong link or crash.
expect(f.documentationAsHtml, '<p>Text <code>_</code>.</p>');
}

void test_referenced_wildcardInParent() async {
var library = await bootPackageWithLibrary('''
class C<_> {
/// Text [_].
void m() {}
}
''');
var m = library.classes.named('C').instanceMethods.named('m');
// There is no link, but also no wrong link or crash.
expect(m.documentationAsHtml, '<p>Text <code>_</code>.</p>');
}
}