Skip to content

Commit 1545d4d

Browse files
committed
better help comments
1 parent b0268ce commit 1545d4d

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

xunit/DocTest.m

+17-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
%
44
% This TestComponent represents a single help(...) output, which is a
55
% logical unit because variables defined earlier in the help text
6-
% should carry over to the rest of it. A single DocTestCase is created
7-
% for each executable line of the test. A DocTestSuite represents more
8-
% than one DocTest.
6+
% should carry over to later parts. For instance, this example is
7+
% internally represented as two DocTestCases in one DocTest:
8+
%
9+
% >> x = 17;
10+
% >> x
11+
% x = 17
12+
%
13+
%
14+
% This lets x be carried over from one to the next.
15+
%
916
%
1017
properties
1118
MethodName
@@ -53,9 +60,11 @@ function print(self, numLeadingBlanks)
5360
%
5461
% All the variables in this function begin with DOCTEST__.
5562
% That's because the namespace of this function and of the
56-
% doctest that's being run are intermingled. This way, it's
57-
% very hard to unintentionally step on these internal
58-
% variables. It does make it hard to read, though...
63+
% doctest that's being run are intermingled. This is
64+
% unavoidable, as far as I can tell. With the DOCTEST__ prefix,
65+
% it's very hard to unintentionally step on these internal
66+
% variables when writing a doctest. It does make it hard to
67+
% read, though...
5968
%
6069
if nargin < 2
6170
DOCTEST__monitor = CommandWindowTestRunDisplay();
@@ -110,11 +119,11 @@ function print(self, numLeadingBlanks)
110119
% They also sometimes backspace over things for no apparent reason. This
111120
% doctest recreates that condition.
112121
%
113-
% >> sprintf('There is no dot here: .\x08')
122+
% >> sprintf('There is no letter x here: x\x08')
114123
%
115124
% ans =
116125
%
117-
% There is no dot here:
126+
% There is no letter x here:
118127
%
119128
%
120129
% All of the doctests should pass, and they manipulate this function.

xunit/DocTestCase.m

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
classdef DocTestCase < TestCase
2-
2+
%DocTestCase - a single executable line in a doctest
3+
%
4+
% This class is essentially a stub, because a single executable line
5+
% can't be run without context supplied from earlier lines. So all of
6+
% the logic lies in the DocTest class.
7+
%
38
methods
49
function self = DocTestCase(testMethod)
510
%TestCase Constructor

xunit/DocTestSuite.m

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
classdef DocTestSuite < TestSuite
2+
%DocTestSuite - a set of DocTests that can be run together.
3+
% The DocTest parts of the Suite don't share any state between them.
4+
%
5+
% A DocTestSuite could contain the DocTests for each of the methods in
6+
% a class, or all of the functions in a directory.
27
methods
38

49
function self = DocTestSuite(name)

0 commit comments

Comments
 (0)