Skip to content

Commit b8c58b8

Browse files
authored
Add a test for operator [] (#1660)
1 parent 3098910 commit b8c58b8

16 files changed

+174
-13
lines changed

test/model_test.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,20 @@ void main() {
553553
docsAsHtml = doAwesomeStuff.documentationAsHtml;
554554
});
555555

556+
test('operator [] reference within a class works', () {
557+
expect(
558+
docsAsHtml,
559+
contains(
560+
'<a href="fake/BaseForDocComments/operator_get.html">operator []</a> '));
561+
});
562+
563+
test('operator [] reference outside of a class works', () {
564+
expect(
565+
docsAsHtml,
566+
contains(
567+
'<a href="fake/SpecialList/operator_get.html">SpecialList.operator []</a> '));
568+
}, skip: 'https://github.com/dart-lang/dartdoc/issues/1285');
569+
556570
test('codeifies a class from the SDK', () {
557571
expect(docsAsHtml, contains('<code>String</code>'));
558572
});
@@ -649,9 +663,7 @@ void main() {
649663
() {
650664
expect(docsAsHtml,
651665
contains('<a href="">css.theOnlyThingInTheLibrary</a>'));
652-
},
653-
skip:
654-
'Wait for https://github.com/dart-lang/dartdoc/issues/767 to be fixed');
666+
}, skip: 'https://github.com/dart-lang/dartdoc/issues/1402');
655667

656668
// remove this test when the above test is fixed. just here to
657669
// track when the behavior changes

testing/test_package/lib/fake.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,15 @@ class BaseForDocComments {
719719
///
720720
/// Reference to a name of a class from an import of a library that exported
721721
/// the name [BaseClass] xx
722+
///
723+
/// Reference to a bracket operator within this class [operator []] xxx
724+
///
725+
/// Reference to a bracket operator in another class [SpecialList.operator []] xxx
722726
String doAwesomeStuff(int value) => null;
723727

724728
void anotherMethod() {}
729+
730+
String operator [](String key) => "${key}'s value";
725731
}
726732

727733
/// Testing if docs for inherited method are correct.

testing/test_package_docs/fake/BaseForDocComments-class.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,18 @@ <h2>Methods</h2>
248248
</dl>
249249
</section>
250250

251-
<section class="summary offset-anchor inherited" id="operators">
251+
<section class="summary offset-anchor" id="operators">
252252
<h2>Operators</h2>
253253
<dl class="callables">
254+
<dt id="operator []" class="callable">
255+
<span class="name"><a href="fake/BaseForDocComments/operator_get.html">operator []</a></span><span class="signature">(<wbr><span class="parameter" id="[]-param-key"><span class="type-annotation">String</span> <span class="parameter-name">key</span></span>)
256+
<span class="returntype parameter">&#8594; String</span>
257+
</span>
258+
</dt>
259+
<dd>
260+
261+
262+
</dd>
254263
<dt id="operator ==" class="callable inherited">
255264
<span class="name"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></span><span class="signature">(<wbr><span class="parameter" id="==-param-other"><span class="type-annotation">dynamic</span> <span class="parameter-name">other</span></span>)
256265
<span class="returntype parameter">&#8594; bool</span>
@@ -285,7 +294,8 @@ <h2>Operators</h2>
285294
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
286295
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
287296

288-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
297+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
298+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
289299
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
290300

291301

testing/test_package_docs/fake/BaseForDocComments/BaseForDocComments.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ <h5>BaseForDocComments class</h5>
5454
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
5555
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
5656

57-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
5859
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
5960

6061

testing/test_package_docs/fake/BaseForDocComments/anotherMethod.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ <h5>BaseForDocComments class</h5>
5454
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
5555
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
5656

57-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
5859
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
5960

6061

testing/test_package_docs/fake/BaseForDocComments/doAwesomeStuff.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ <h5>BaseForDocComments class</h5>
5454
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
5555
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
5656

57-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
5859
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
5960

6061

@@ -88,6 +89,8 @@ <h1>doAwesomeStuff method</h1>
8889
in this library <a href="anonymous_library/doesStuff.html">doesStuff</a> xx</p>
8990
<p>Reference to a name of a class from an import of a library that exported
9091
the name <a href="two_exports/BaseClass-class.html">BaseClass</a> xx</p>
92+
<p>Reference to a bracket operator within this class <a href="fake/BaseForDocComments/operator_get.html">operator []</a> xxx</p>
93+
<p>Reference to a bracket operator in another class <code>SpecialList.operator []</code> xxx</p>
9194
</section>
9295

9396

testing/test_package_docs/fake/BaseForDocComments/hashCode.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ <h5>BaseForDocComments class</h5>
5454
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
5555
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
5656

57-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
5859
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
5960

6061

testing/test_package_docs/fake/BaseForDocComments/noSuchMethod.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ <h5>BaseForDocComments class</h5>
5454
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
5555
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
5656

57-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
5859
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
5960

6061

testing/test_package_docs/fake/BaseForDocComments/operator_equals.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ <h5>BaseForDocComments class</h5>
5454
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
5555
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
5656

57-
<li class="section-title inherited"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
5859
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
5960

6061

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta name="description" content="API docs for the operator [] method from the BaseForDocComments class, for the Dart programming language.">
8+
<title>operator [] method - BaseForDocComments class - fake library - Dart API</title>
9+
<!-- required because all the links are pseudo-absolute -->
10+
<base href="../..">
11+
12+
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet">
13+
<link rel="stylesheet" href="static-assets/github.css">
14+
<link rel="stylesheet" href="static-assets/styles.css">
15+
<link rel="icon" href="static-assets/favicon.png">
16+
17+
</head>
18+
19+
<body>
20+
21+
<div id="overlay-under-drawer"></div>
22+
23+
<header id="title">
24+
<button id="sidenav-left-toggle" type="button">&nbsp;</button>
25+
<ol class="breadcrumbs gt-separated dark hidden-xs">
26+
<li><a href="index.html">test_package</a></li>
27+
<li><a href="fake/fake-library.html">fake</a></li>
28+
<li><a href="fake/BaseForDocComments-class.html">BaseForDocComments</a></li>
29+
<li class="self-crumb">operator [] method</li>
30+
</ol>
31+
<div class="self-name">operator []</div>
32+
<form class="search navbar-right" role="search">
33+
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
34+
</form>
35+
</header>
36+
37+
<main>
38+
39+
<div class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left">
40+
<h5>BaseForDocComments class</h5>
41+
<ol>
42+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#constructors">Constructors</a></li>
43+
<li><a href="fake/BaseForDocComments/BaseForDocComments.html">BaseForDocComments</a></li>
44+
45+
<li class="section-title inherited">
46+
<a href="fake/BaseForDocComments-class.html#instance-properties">Properties</a>
47+
</li>
48+
<li class="inherited"><a href="fake/BaseForDocComments/hashCode.html">hashCode</a></li>
49+
<li class="inherited"><a href="fake/BaseForDocComments/runtimeType.html">runtimeType</a></li>
50+
51+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#instance-methods">Methods</a></li>
52+
<li><a href="fake/BaseForDocComments/anotherMethod.html">anotherMethod</a></li>
53+
<li><a href="fake/BaseForDocComments/doAwesomeStuff.html">doAwesomeStuff</a></li>
54+
<li class="inherited"><a href="fake/BaseForDocComments/noSuchMethod.html">noSuchMethod</a></li>
55+
<li class="inherited"><a href="fake/BaseForDocComments/toString.html">toString</a></li>
56+
57+
<li class="section-title"><a href="fake/BaseForDocComments-class.html#operators">Operators</a></li>
58+
<li><a href="fake/BaseForDocComments/operator_get.html">operator []</a></li>
59+
<li class="inherited"><a href="fake/BaseForDocComments/operator_equals.html">operator ==</a></li>
60+
61+
62+
63+
</ol>
64+
</div><!--/.sidebar-offcanvas-->
65+
66+
<div class="col-xs-12 col-sm-9 col-md-8 main-content">
67+
<h1>operator [] method</h1>
68+
69+
<section class="multi-line-signature">
70+
<span class="returntype">String</span>
71+
<span class="name ">operator []</span>
72+
(<wbr><span class="parameter" id="[]-param-key"><span class="type-annotation">String</span> <span class="parameter-name">key</span></span>)
73+
</section>
74+
75+
76+
77+
</div> <!-- /.main-content -->
78+
79+
<div class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right">
80+
</div><!--/.sidebar-offcanvas-->
81+
82+
</main>
83+
84+
<footer>
85+
<span class="no-break">
86+
test_package 0.0.1
87+
</span>
88+
89+
</footer>
90+
91+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
92+
<script src="static-assets/typeahead.bundle.min.js"></script>
93+
<script src="static-assets/highlight.pack.js"></script>
94+
<script src="static-assets/URI.js"></script>
95+
<script src="static-assets/script.js"></script>
96+
97+
98+
</body>
99+
100+
</html>

0 commit comments

Comments
 (0)