manager 0.0.0 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHART.html +1270 -0
  3. data/MANUAL.html +1252 -0
  4. data/bin/manager +43 -0
  5. data/examples/array/CHART.html +1376 -0
  6. data/examples/array/MANUAL.html +1126 -0
  7. data/examples/array/spec +3438 -0
  8. data/lib/manager.rb +528 -0
  9. data/lib/manager/annotation +96 -0
  10. data/lib/manager/input +189 -0
  11. data/lib/manager/js +257 -0
  12. data/lib/manager/refine_module +142 -0
  13. data/lib/manager/refine_object_mapping +143 -0
  14. data/lib/manager/refine_test +97 -0
  15. data/lib/manager/render +1228 -0
  16. data/lib/manager/spell_check +49 -0
  17. data/lib/manager/test +404 -0
  18. data/lib/manager/test_helper +9 -0
  19. data/license +9 -0
  20. data/manager.gemspec +21 -0
  21. data/spec/alternatives_implemented.png +0 -0
  22. data/spec/alternatives_unimplemented.png +0 -0
  23. data/spec/annotations.png +0 -0
  24. data/spec/benchmark_test.png +0 -0
  25. data/spec/citation.png +0 -0
  26. data/spec/code_block.png +0 -0
  27. data/spec/context_module.png +0 -0
  28. data/spec/documentation +1289 -0
  29. data/spec/external_link.png +0 -0
  30. data/spec/image.png +0 -0
  31. data/spec/list.png +0 -0
  32. data/spec/long.png +0 -0
  33. data/spec/main_and_object.png +0 -0
  34. data/spec/markup.png +0 -0
  35. data/spec/module_diagram.png +0 -0
  36. data/spec/navigation.png +0 -0
  37. data/spec/nested_section_headers.png +0 -0
  38. data/spec/ruby.png +0 -0
  39. data/spec/setup_teardown.png +0 -0
  40. data/spec/short.png +0 -0
  41. data/spec/signature.png +0 -0
  42. data/spec/spec +76 -0
  43. data/spec/spec_example.png +0 -0
  44. data/spec/table.png +0 -0
  45. data/spec/test_header.png +0 -0
  46. data/spec/test_non_unit_spec +184 -0
  47. data/spec/test_program +71 -0
  48. data/spec/test_unit_spec +790 -0
  49. data/spec/tutorial_1.png +0 -0
  50. data/spec/tutorial_2.png +0 -0
  51. data/spec/tutorial_3.png +0 -0
  52. data/spec/tutorial_4.png +0 -0
  53. data/spec/tutorial_5.png +0 -0
  54. data/spec/tutorial_6.png +0 -0
  55. data/spec/tutorial_7.png +0 -0
  56. data/spec/tutorial_8.png +0 -0
  57. data/spec/unambiguous_links.png +0 -0
  58. data/spec/unit_test_failure.png +0 -0
  59. data/spec/unit_test_raise.png +0 -0
  60. data/spec/unit_test_receiver.png +0 -0
  61. data/spec/unit_test_succeed.png +0 -0
  62. data/spec/unit_test_success.png +0 -0
  63. data/spec/unit_test_throw.png +0 -0
  64. data/spec/valid_heading.png +0 -0
  65. data/spec/with_expr.png +0 -0
  66. data/spec/without_expr.png +0 -0
  67. data/theme/2016a.css +670 -0
  68. data/theme/coderay_github.css +132 -0
  69. metadata +140 -11
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: false
2
+
3
+ Manager.config(
4
+ title: "Manager",
5
+ bdir: "../lib/manager",
6
+ odir: "../",
7
+ spell_check: :en,
8
+ )
9
+
10
+ Manager.config case_sensitive: %w[
11
+ API
12
+ CSS
13
+ Ctrl
14
+ DDD
15
+ UTF
16
+ ]
17
+
18
+ Manager.config case_insensitive: %w[
19
+ associativity
20
+ backtick
21
+ backticks
22
+ backtrace
23
+ backtraces
24
+ bdir
25
+ checkbox
26
+ dev
27
+ disambiguated
28
+ dom
29
+ falsy
30
+ getter
31
+ initializer
32
+ matchers
33
+ merchantability
34
+ mixin
35
+ mixins
36
+ noninfringement
37
+ odir
38
+ pragma
39
+ prepended
40
+ runtime
41
+ sawa
42
+ setter
43
+ subfile
44
+ sublicense
45
+ substring
46
+ superset
47
+ teardown
48
+ truthy
49
+ un
50
+ untestable
51
+ verifications
52
+ verifier
53
+ versioning
54
+ ]
55
+
56
+ #gemspec "../manager.gemspec"
57
+
58
+ #! Loading the three files commented out would cause an error. This is a limitation of
59
+ # analyzing Manager using Manager itself. The features that appear in these files need to
60
+ # be manuall described.
61
+ manage "../lib/manager/annotation"
62
+ #manage "../lib/manager/input"
63
+ #manage "../lib/manager/manager.rb"
64
+ manage "../lib/manager/refine_module"
65
+ manage "../lib/manager/refine_object_mapping"
66
+ #manage "../lib/manager/refine_test"
67
+ manage "../lib/manager/render"
68
+ manage "../lib/manager/test"
69
+ manage "../lib/manager/test_helper"
70
+ manage "../lib/manager/spell_check"
71
+
72
+ load "#{__dir__}/documentation"
73
+ load "#{__dir__}/test_unit_spec"
74
+
75
+ manage "test_program"
76
+ load "#{__dir__}/test_non_unit_spec"
Binary file
Binary file
Binary file
@@ -0,0 +1,184 @@
1
+ #! frozen_string_literal: false
2
+
3
+ hide spec "::TestA",
4
+ "? Expecting “Untestable” result.",
5
+ "?? Expecting “unimplemented” message.",
6
+ BM,
7
+ "? Expecting “missing preceding successfule test” message.",
8
+ RECEIVER == 2,
9
+ "? Expecting “missing preceding successfule test” message.",
10
+ RETURN == 1,
11
+ "? Expecting “Bad test” result.",
12
+ UT,
13
+ coda
14
+
15
+ module TestA
16
+ spec "::TestPublicConstant",
17
+ coda
18
+
19
+ spec "::TestPrivateConstant",
20
+ coda
21
+
22
+ spec "::TestUnimplementedConstant",
23
+ "! Expected to be tagged as `Unimplemented`.",
24
+ coda
25
+ end
26
+
27
+ hide spec "::TestB",
28
+ coda
29
+
30
+ hide spec "#test_foo",
31
+ "?Syntax error in exercise receiver, exercise arguments, or verifier arguments should be detected and reported as “bad test”, prior to exercising or verifying the test.",
32
+ "??Receiver",
33
+ expr("efwe )def.").UT,
34
+ expr("efwe )def.").UT == 1,
35
+ "??Examining argument",
36
+ 1.UT(expr("class <<.")),
37
+ 1.UT(expr("class <<.")) == 1,
38
+ "??Verifying argument",
39
+ 1.UT == expr("expresson}with. syntax (error"),
40
+ "?Test format error should be detected and result in “bad test” prior to runtime error in `expr`",
41
+ "??Runtime `expr` error in receiver has less priority",
42
+ expr("unimplemented_variable").UT,
43
+ "??Runtime `expr` error in examining argument has less priority",
44
+ 1.UT(expr("unimplemented_variable")),
45
+ "?Exercising error such as method missing should be detected and result in “untestable” prior to runtime `expr` error in verifying argument.",
46
+ 1.UT == expr("unimplemented_variable"),
47
+ "?Runtime error in `expr` should result in “bad test”, not “bug”",
48
+ "??Receiver",
49
+ expr("unimplemented_variable").UT == 1,
50
+ "??Exercise argument",
51
+ 1.UT(expr("unimplemented_variable")) == 1,
52
+ "??Verifying argument",
53
+ 1.UT == expr("unimplemented_variable"),
54
+ coda
55
+
56
+ hide spec "#unimplemented",
57
+ "! Expected to be tagged as `Unimplmenented`.",
58
+ "? Expect `NameError`'s during setup processing to be captured and is displayed with a modified error message.",
59
+ expr("unimplemented").UT == :bar,
60
+ :foo.UT(expr("unimplemented")) == :baz,
61
+ "? Unimplemented method should result in “untestable”",
62
+ UT{}.succeed?,
63
+ "? Expecting “missing previous successful” message.",
64
+ RETURN == "BAR",
65
+ RECEIVER == "BAR",
66
+ coda
67
+
68
+ hide spec "#NotConstantButMethod",
69
+ coda
70
+
71
+ hide spec "::NotConstantButMethod",
72
+ "! Expected to be tagged as `Unimplmenented`.",
73
+ "? Expecting `Untestable` (`unimplemented`).",
74
+ UT.succeed?,
75
+ "? Expecting Bad test (constant invocation cannot take an argument)",
76
+ UT(:foo).succeed?,
77
+ coda
78
+
79
+ hide spec "#test_nest_a",
80
+ "? Expecting an error. Expected to display the backtrace.",
81
+ UT.succeed?,
82
+ coda
83
+
84
+ hide spec "#test_nest_b",
85
+ coda
86
+
87
+ hide spec "#test_nest_c",
88
+ coda
89
+
90
+ hide spec "#test_nest_d",
91
+ coda
92
+
93
+ hide spec "#test_nest_e",
94
+ coda
95
+
96
+ hide spec "#test_nest_f",
97
+ "? Expecting an error. Expected to display the backtrace.",
98
+ UT.succeed?,
99
+ coda
100
+
101
+ hide spec "#test_nest_g",
102
+ coda
103
+
104
+ hide spec "#test_nest_h",
105
+ coda
106
+
107
+ hide spec "#test_nest_i",
108
+ coda
109
+
110
+ hide spec "#test_throw",
111
+ "? Expecting Success.",
112
+ UT.throw?(:yes),
113
+ "? Expecting Bug.",
114
+ UT.throw?(:no),
115
+ "? Expecting Success.",
116
+ UT.throw?(:yes, value: "correct"),
117
+ "? Expecting Bug.",
118
+ UT.throw?(:yes, value: "wrong"),
119
+ "? Uncaught throw should be reported as Bug.",
120
+ UT == true,
121
+ coda
122
+
123
+ hide spec "#test_or",
124
+ <<~RUBY.setup,
125
+ require 'set'
126
+ a = (1..1000).to_a
127
+ b = [2,6,7,1]
128
+ RUBY
129
+ "? Expected that alternative error messages are reported independently.",
130
+ UT(expr("a"), expr("b")) == expr("[*3..5, *8..1000]"),
131
+ BM(expr("a"), expr("b")),
132
+ coda
133
+
134
+ hide spec "#test_or_without_main",
135
+ "! Expected to be tagged as `Unimplemented`. The main method is not implemented.",
136
+ "? Expects tests to be run in absense of main method, and independently report a bug for an alternative implementation.",
137
+ UT(expr("a"), expr("b")) == expr("[*3..5, *8..1000]"),
138
+ "? Expects benchmark to be run in absense of main method.",
139
+ BM(expr("a"), expr("b")),
140
+ coda
141
+
142
+ hide spec "#check_int",
143
+ <<~'RUBY'.setup,
144
+ int = "220000"
145
+ bad_int = "22.to.2"
146
+ RUBY
147
+ UT(expr("int")) == true,
148
+ BM(expr("int")),
149
+ BM(expr("bad_int")),
150
+ coda
151
+
152
+ class String
153
+ hide spec "#upcase",
154
+ "? Expecting Untestable (no previous successful unit test).",
155
+ RECEIVER > 5,
156
+ "? Expecting Bad test (no verification).",
157
+ "bar".UT{},
158
+ "? Expecting Untestable (no previous successful unit test).",
159
+ RETURN == "BAR",
160
+ RECEIVER == "BAR",
161
+ "? Expecting Success",
162
+ "bar".UT{}.succeed?,
163
+ RETURN == "BAR",
164
+ "? Expecting Bug",
165
+ RECEIVER == "BAR",
166
+ ("bzz".UT == "Zoo") <= "Goo",
167
+ "abcde".BM,
168
+ coda
169
+ end
170
+
171
+ hide spec "::Array",
172
+ coda
173
+
174
+ class Array
175
+ hide spec "#[]=",
176
+ UT == 3,
177
+ "? `expr` objects' identity should be preserved with `RECEIVER` and `RETURN`",
178
+ expr('Array[*(0..99).to_a]').UT(10, 10, 0).zero?,
179
+ RECEIVER == expr('Array[*(0..9).to_a] + Array[0] + Array[*(20..99).to_a]'),
180
+ "? `expr` used in argument position should be displayed as the source string, not as the expanded value.",
181
+ 'a = Array[1, 2, 3]'.setup,
182
+ expr('a').UT(1, 0, expr('a')).succeed?,
183
+ coda
184
+ end
@@ -0,0 +1,71 @@
1
+ #! This is an additional program code to be loaded when running manager on itself
2
+ #!! This comment is written in the main context, and should have global scope, and be displayed
3
+ # in the main context.
4
+ #!! global_1: This comment is written in the main context, and should have global scope,
5
+ # and be displayed in the main context.
6
+
7
+ module TestA
8
+ #!! global_1;
9
+ #!! global_2: This comment is also written inside a method definition, and should have
10
+ # global scope, and be displayed in the main context.
11
+ TestPublicConstant = 1
12
+ TestPrivateConstant = 1
13
+ private_constant :TestPrivateConstant
14
+ end
15
+
16
+ class TestB
17
+ def foo; end
18
+ alias boo foo
19
+ Bar = "Interned string".freeze
20
+ Foo = +"Non interned string"
21
+ end
22
+
23
+ def NotConstantButMethod; end
24
+
25
+ def test_foo
26
+ #!! global_1: This comment is written inside a method definition, and should have global
27
+ # scope, and be displayed in the main context.
28
+ #! local1:
29
+ # This comment spans
30
+ # over multiple lines.
31
+ #! Comment without a tag should be an Agenda.
32
+ end
33
+
34
+ def test_nest_a; test_nest_b end
35
+ def test_nest_b; test_nest_c end
36
+ def test_nest_c; test_nest_d end
37
+ def test_nest_d; test_nest_e end
38
+ def test_nest_e x, y; end
39
+
40
+ def test_nest_f; test_nest_g end
41
+ def test_nest_g; test_nest_h end
42
+ def test_nest_h; test_nest_i end
43
+ def test_nest_i; raise "Raised" end
44
+
45
+ def check_int
46
+ Integer(int) rescue false
47
+ end
48
+ def check_int__1 int
49
+ int.to_i.to_s == int
50
+ end
51
+ def check_int__2 int
52
+ int =~ /\A\d+\z/
53
+ end
54
+
55
+ def test_throw
56
+ throw(:yes, "correct")
57
+ end
58
+
59
+ def test_or a, b; end
60
+ def test_or__foo a; end
61
+ def test_or__bar a, b; :bar end
62
+ def test_or__1 a, b; (a + b) - (a & b); end
63
+ def test_or__2 a, b; (a - b) + (b - a); end
64
+ def test_or__3 a, b; (a | b) - (a & b); end
65
+ def test_or__4 a, b; (Set[*a] ^ Set[*b]).to_a; end
66
+
67
+ def test_or_without_main__wrong a, b; :bar end
68
+ def test_or_without_main__1 a, b; (a + b) - (a & b); end
69
+ def test_or_without_main__2 a, b; (a - b) + (b - a); end
70
+ def test_or_without_main__3 a, b; (a | b) - (a & b); end
71
+ def test_or_without_main__4 a, b; (Set[*a] ^ Set[*b]).to_a; end
@@ -0,0 +1,790 @@
1
+ #! frozen_string_literal: false
2
+
3
+ spec nil,
4
+ "! Here are some limitations of running Manager on Manager itself.",
5
+ "*! Manager cannot automatically detect some of its own features. They needed to be documented manually.",
6
+ "*! Some of Manager's own features cannot be tested.",
7
+ "*! Some of Manager's own features cannot be tested in a unit test. They are tested by intentionally being expected to raise Missing test, Unimplemented, Untestable, Bad test, or Bug. Their headers describe that such reports are expected. Their reports should be manually examined.",
8
+ coda
9
+
10
+ class Manager
11
+ hide spec "::DebugDirs",
12
+ "! Directories internal to Manager. Files that belong to these directories should be exempt from backtraces in test reports.",
13
+ UT.all?{|f| f =~ %r|/bin/| or f =~ %r|/gems/|},
14
+ coda
15
+
16
+ hide spec "::Main",
17
+ "! The main environment.",
18
+ UT.class == Object,
19
+ coda
20
+ hide spec "::AlternativeMethod",
21
+ "! Matches alternative implementations of a method.",
22
+ "? Should not match balanced `__`.",
23
+ UT !~ "__foo__",
24
+ UT !~ "foo__bar__",
25
+ UT !~ "__foo__bar",
26
+ UT !~ "foo__bar__baz",
27
+ UT !~ "__foo__bar__",
28
+ "? The label should not be empty.",
29
+ UT !~ "foo__",
30
+ "? Should match.",
31
+ UT =~ "foo__my_foo",
32
+ UT =~ "foo__2",
33
+ UT =~ "foo__my_version?",
34
+ (UT =~ "foo__my").zero?,
35
+ coda
36
+
37
+ hide spec "::InterruptionInactive",
38
+ "! Default (inactive) `Proc` to be called when Ctrl+C is pressed. The sole function is to erase `^C-c` that is printed on the screen because of the key press.",
39
+ UT.call.nil?,
40
+ coda
41
+
42
+ hide spec ".current",
43
+ "! Returns the current running instance.",
44
+ UT.is_a?(Manager),
45
+ coda
46
+
47
+ hide spec ".context",
48
+ "! Short for `.current.context`, the current testing context.",
49
+ UT.is_a?(Manager::Context),
50
+ coda
51
+
52
+ hide spec ".counts",
53
+ "! Short for `.current.counts`. Holds all the statistics.",
54
+ UT.is_a?(Hash),
55
+ coda
56
+
57
+ move spec ".config",
58
+ "! Defined in a file that cannot be listed.",
59
+ "! Cannot be tested.",
60
+ "! Moved since its real source location cannot be listed by `manage` method.",
61
+ {"(symbol)" => Object},
62
+ "Gets the Manager configuration. `symbol` can take the following values. See {::=Customization and Options} for detail.",
63
+ "* `:bdir`",
64
+ "* `:odir`",
65
+ "* `:user`",
66
+ "* `:dev`",
67
+ "* `:theme`",
68
+ "* `:highlight`",
69
+ "* `:debug`",
70
+ "* `:spell_check`",
71
+ "* `:case_sensitive`",
72
+ "* `:case_insensitive`",
73
+ # "* `:timeout`",
74
+ "* `:title`",
75
+ <<~'RUBY'.code,
76
+ Manager.config(:odir)
77
+ RUBY
78
+ UT(:bdir).is_a?(String),
79
+ UT(:odir).is_a?(String),
80
+ UT(:user).is_a?(String),
81
+ UT(:dev).is_a?(String),
82
+ UT(:theme).is_a?(String),
83
+ UT(:highlight).is_a?(String),
84
+ UT(:debug).instance_eval{|e| e == true or e == false},
85
+ UT(:spell_check).instance_eval{|e| e.is_a?(String) or e.is_a?(Symbol)or e.nil?},
86
+ UT(:case_sensitive).is_a?(Hash),
87
+ UT(:case_insensitive).is_a?(Hash),
88
+ UT(:timeout).instance_eval{|e| Numeric === e or e.nil?},
89
+ UT(:title).is_a?(String),
90
+ {"(hash)" => value(nil)},
91
+ "Sets the Manager configuration. `hash` should be a symbol key with the value to be set.",
92
+ <<~'RUBY'.code,
93
+ Manager.config(odir: "../", title: "My Special Program", spell_check: "en")
94
+ RUBY
95
+ coda
96
+
97
+ hide spec "#files",
98
+ "! Getter/setter. List of files loaded or required. Including listed and non-listed ones.",
99
+ expr("Manager.current").UT.is_a?(Array),
100
+ coda
101
+
102
+ hide spec "#implementations",
103
+ "! Getter/setter. A hash of implementations extracted from the program code.",
104
+ expr("Manager.current").UT.is_a?(Hash),
105
+ coda
106
+
107
+ hide spec "#annotations",
108
+ "! Getter/setter. A hash of annotations extracted from the program code.",
109
+ expr("Manager.current").UT.is_a?(Hash),
110
+ coda
111
+
112
+ hide spec "#context",
113
+ "! Getter/setter. The current binding object under which `expr` is evaluated.",
114
+ expr("Manager.current").UT.is_a?(Manager::Context),
115
+ coda
116
+
117
+ hide spec "#counts",
118
+ "! Getter/setter. Holds all the statistics.",
119
+ expr("Manager.current").UT.is_a?(Hash),
120
+ coda
121
+
122
+ hide spec "#annotation_extractor",
123
+ "! Cannot be tested because `Manager::AnnotationExtractor` is refined.",
124
+ "! Getter/setter",
125
+ coda
126
+
127
+ hide spec "#slf",
128
+ "! Getter. Current environment. Either a module or the main object, or `nil`.",
129
+ expr("Manager.current").UT.instance_eval{|e| e.kind_of?(Module) or e == Manager::Main or e.nil?},
130
+ coda
131
+
132
+ hide spec "#sample",
133
+ "! Getter. The current test exercise receiver. Can be any object.",
134
+ expr("Manager.current").UT.succeed?,
135
+ coda
136
+
137
+ hide spec "#modul",
138
+ "! Getter. The current module.",
139
+ expr("Manager.current").UT.is_a?(Module),
140
+ coda
141
+
142
+ hide spec "#type",
143
+ "! Getter. The current type.",
144
+ expr("Manager.current").UT.in?([:module, :constant, :module_as_constant, :singleton, :instance]),
145
+ coda
146
+
147
+ hide spec "#feature",
148
+ "! Getter. The current feature.",
149
+ expr("Manager.current").UT.instance_eval{|e| String === e or Symbol === e},
150
+ coda
151
+
152
+ move spec ".new",
153
+ "! Defined in a file that cannot be listed.",
154
+ "! Cannot be tested",
155
+ "The main method to be called when running Manager. See {::=Running Manager}.",
156
+ {"(file, **command_options)" => value(nil)},
157
+ "The `file` argument is a string expressing the path to the spec file. `command_options` are options as explained in {::=Customization and Options}.",
158
+ <<~'RUBY'.code,
159
+ Manager.new("../spec_file.rb", bdir: "../")
160
+ RUBY
161
+ coda
162
+
163
+ hide spec "#gemspec",
164
+ "! Cannot be tested",
165
+ "! Called from `main#gemspec`",
166
+ coda
167
+
168
+ hide spec "#manage",
169
+ "! Cannot be tested",
170
+ "! Called from `main#manage`",
171
+ coda
172
+
173
+ hide spec "#hide",
174
+ "! Cannot be tested.",
175
+ "! Called from `Module#hide`",
176
+ coda
177
+
178
+ hide spec "#move",
179
+ "! Cannot be tested.",
180
+ "! Called from `Module#move`",
181
+ coda
182
+
183
+ hide spec "#_spec",
184
+ "! Cannot be tested.",
185
+ "! The main method called by `Module#spec` after verification.",
186
+ coda
187
+
188
+ hide spec "::Coda",
189
+ "! Called from `Module#coda`",
190
+ "! Dummy constant called by the pseudo-keyword `coda` to close the block opened by the `spec` method.",
191
+ coda
192
+
193
+ hide spec ".validate_feature_call",
194
+ "! Validates the `feature`, and check is the `spec` block was correctly closed by a `coda`.",
195
+ "? Correct feature names",
196
+ UT(Object, "::Foo", Coda).succeed?,
197
+ UT(Object, ".foo", Coda).succeed?,
198
+ UT(Object, "#foo", Coda).succeed?,
199
+ UT(Object, nil, Coda).succeed?,
200
+ "? Cannot check the cases with `=`.",
201
+ "? Invalid feature name",
202
+ UT(Object, "@foo", Coda).raise?(message: /invalid feature name/i),
203
+ "? Alternative implementation name used as a main method name",
204
+ UT(Object, "#foo__1", Coda).raise?(message: /crashes/),
205
+ "? Missing coda",
206
+ UT(Object, "#foo", :foo).raise?(message: /missing/i),
207
+ coda
208
+
209
+ hide spec ".main_method",
210
+ "! Takes a method name and returns the main (i.e. non-alternative) method name.",
211
+ UT(:foo__) == :foo__,
212
+ UT(:foo__1) == :foo,
213
+ UT(:foo__by_version?) == :foo?,
214
+ coda
215
+
216
+ hide spec "#i",
217
+ "! Returns the index number of a spec it if exists.",
218
+ expr("Manager.current").UT(Manager, :instance, :i).kind_of?(Numeric),
219
+ coda
220
+
221
+ hide spec "#add_described_header",
222
+ "! Cannot be tested.",
223
+ "! Validates a given descriptive header, and if it passes, then adds it.",
224
+ coda
225
+
226
+ hide spec "#described_headers",
227
+ "! Searches for a described header within the module that matches the name path. Used for searching the target of a link to a feature.",
228
+ expr("Manager.current").UT(Manager::Main, ["License"]).instance_of?(Array),
229
+ RETURN.length == 1,
230
+ coda
231
+
232
+ hide spec "#bad_spec",
233
+ "! Cannot be tested.",
234
+ "! Used for printing error in terminal.",
235
+ coda
236
+
237
+ hide spec "#wrong_item",
238
+ "! Cannot be tested.",
239
+ "! Used for printing error in terminal.",
240
+ coda
241
+
242
+ hide spec "::CodeRayOption",
243
+ "! Some output configurations for `coderay`.",
244
+ coda
245
+
246
+ hide spec "#render",
247
+ "! Calls the main routine to render the result. Called once for user's manual, and once for developer's chart.",
248
+ coda
249
+
250
+ hide spec "#left",
251
+ "! Renders the left panel in developer's chart.",
252
+ coda
253
+
254
+ hide spec "#coverage",
255
+ "! Temporal method to display the coverage report matched with lines.",
256
+ coda
257
+
258
+ hide spec "#main",
259
+ "! Renders the main section",
260
+ coda
261
+
262
+ hide spec "#checkbox",
263
+ "! Renders the checkbox in the files section in developer's chart.",
264
+ coda
265
+ end
266
+
267
+ hide spec "::Manager::Spec",
268
+ coda
269
+
270
+ class Manager::Spec
271
+ spec nil,
272
+ "! The identity of each specification description.",
273
+ "spec = Manager::Spec.new".setup,
274
+ coda
275
+
276
+ spec "#header",
277
+ "! Getter.",
278
+ expr("spec").UT == nil,
279
+ coda
280
+
281
+ spec "#documentation",
282
+ "! Getter.",
283
+ expr("spec").UT == nil,
284
+ coda
285
+
286
+ spec "#hidden",
287
+ "! Getter.",
288
+ expr("spec").UT == false,
289
+ coda
290
+
291
+ spec "#type",
292
+ "! Getter.",
293
+ expr("spec").UT == nil,
294
+ coda
295
+
296
+ spec "#aliases",
297
+ "! Getter.",
298
+ expr("spec").UT == nil,
299
+ coda
300
+
301
+ spec "#alts",
302
+ "! Getter.",
303
+ "! Somehow plain `{}` would not be recognized as an argument of `==` in the test below.",
304
+ expr("spec").UT == expr("{}"),
305
+ coda
306
+
307
+ spec ".new",
308
+ "! Initializer",
309
+ Manager::Spec.UT.succeed?,
310
+ coda
311
+
312
+ spec "#undocumented_mark",
313
+ "! Marks those initialized through trace point signals during analysis of program code.",
314
+ expr("spec").UT == expr("spec"),
315
+ RECEIVER.instance_variable_get(:@undocumented) == true,
316
+ coda
317
+
318
+ hide spec "#order_fix",
319
+ "! Cannot be tested.",
320
+ coda
321
+
322
+ hide spec "#missing?",
323
+ "! Cannot be tested",
324
+ coda
325
+ end
326
+
327
+ hide spec "::Manager::AnnotationExtractor",
328
+ coda
329
+
330
+ class Manager::AnnotationExtractor
331
+ hide spec "::AnnotationLine",
332
+ "! Tagged annotations in the program code.",
333
+ UT =~ "#!TodO: blah blah",
334
+ UT =~ "#!!TodO blah blah",
335
+ UT !~ "#TodO blah blah",
336
+ coda
337
+
338
+ hide spec "::ContinuationOrCommentLine",
339
+ "! A line that starts with a comment character.",
340
+ UT =~ "# blah blah",
341
+ UT =~ "#blah blah",
342
+ UT !~ " #blah blah",
343
+ UT !~ " blah blah",
344
+ coda
345
+
346
+ hide spec "::ContinuationLine",
347
+ "! A line that is indented and has a comment character.",
348
+ "? Matches",
349
+ UT =~ " #blah blah",
350
+ "? Is not indented",
351
+ UT !~ "# blah blah",
352
+ UT !~ "#blah blah",
353
+ "? Does not have a comment character",
354
+ UT !~ " blah blah",
355
+ coda
356
+
357
+ hide spec "::BlockCommentStart",
358
+ "! Beginning of a block comment.",
359
+ UT =~ "=begin ",
360
+ UT =~ "=begin\t",
361
+ UT =~ "=begin\n",
362
+ UT !~ "=begi",
363
+ coda
364
+
365
+ hide spec "::BlockCommentEnd",
366
+ "! End of a block comment.",
367
+ UT =~ "=end ",
368
+ UT =~ "=end\t",
369
+ UT =~ "=end\n",
370
+ UT !~ "=en",
371
+ coda
372
+
373
+ hide spec "::DebugCommand",
374
+ "! A line that starts with method `puts`, `p`, or a line that has `.intercept`.",
375
+ UT =~ "puts()",
376
+ UT =~ "p 'foo'",
377
+ UT !~ "[] puts()",
378
+ UT !~ "{} p 'foo'",
379
+ UT =~ ".intercept",
380
+ coda
381
+
382
+ hide spec "#initialize",
383
+ coda
384
+
385
+ hide spec ".new",
386
+ "! Cannot be tested",
387
+ coda
388
+
389
+ hide spec "#read_upto",
390
+ "! Triggered by trace point, increments the reading line on the program file.",
391
+ coda
392
+
393
+ hide spec "#close",
394
+ "! Closes the program file that was read for extracting the annotations",
395
+ coda
396
+
397
+ hide spec "#read_line",
398
+ "! Read a line in the program file, checks for an annotation, and set the current state.",
399
+ coda
400
+ end
401
+
402
+ class Manager
403
+ hide spec "::MethodSignatureException",
404
+ coda
405
+
406
+ hide spec "::MethodSignatureAlternatives",
407
+ coda
408
+ end
409
+
410
+ move spec "#expr",
411
+ "! Cannot be tested.",
412
+ "! Moved because the file `input` cannot be listed.",
413
+ {"(string)" => Manager::Expr},
414
+ "Wraps a expression (string). Its content is evaluated during tests. Its inspected form is the original string expression, not the inspection form of the object it represents.",
415
+ <<~'RUBY'.code,
416
+ class String
417
+ spec "#upcase",
418
+ "long_foo = \"foo\" * 100".setup,
419
+ expr("long_foo").UT.length == 300,
420
+ coda
421
+ end
422
+ RUBY
423
+ coda
424
+
425
+ class <<Manager::Main
426
+ move spec "#gemspec",
427
+ "! Cannot be tested.",
428
+ "! Moved because the file `input` cannot be listed.",
429
+ "When the program under analysis is a Ruby gem, and this method is called, the gem spec information is displayed in the left panel of developer's chart.",
430
+ {"(file)" => Gem::Specification},
431
+ "`file` should be the path to the `.gemspec` file either absolute or relative to the spec file.",
432
+ <<~'RUBY'.code,
433
+ gemspec "../manager.gemspec"
434
+ RUBY
435
+ coda
436
+
437
+ move spec "#manage",
438
+ "! Cannot be tested.",
439
+ "! Moved because the file `input` cannot be listed.",
440
+ "Registers the files to be analyzed. Files that are loaded or required other than by method would not be the object of analysis.",
441
+ {"(file)" => value(nil)},
442
+ "`file` should be the path to the `.gemspec` file either absolute or relative to the spec file.",
443
+ <<~'RUBY'.code,
444
+ manage "../lib/helpers/foo.rb"
445
+ manage "../lib/helpers/bar.rb"
446
+ RUBY
447
+ coda
448
+ end
449
+
450
+ class BasicObject
451
+ spec nil,
452
+ "Besides, `UT` and `BM` explained below, `RETURN` and `RECEIVER` can be used in tests.",
453
+ coda
454
+ move spec "#UT",
455
+ "! Cannot be tested.",
456
+ "! Moved because the file `input` cannot be listed.",
457
+ {"(*args, **kargs, &pr)" => value(::Manager::UnitTest)},
458
+ "A placeholder for the feature (method or constant) examined in unit tests.",
459
+ <<~'RUBY'.code,
460
+ class String
461
+ spec "#capitalize",
462
+ "foo".UT == "Foo",
463
+ coda
464
+ end
465
+ RUBY
466
+ coda
467
+
468
+ move spec "#BM",
469
+ "! Cannot be tested.",
470
+ "! Moved because the file `input` cannot be listed.",
471
+ {"(*args, **kargs, &pr)" => ::Manager::Benchmark},
472
+ "A placeholder for the feature (method or constant) examined in benchmark tests.",
473
+ <<~'RUBY'.code,
474
+ class String
475
+ spec "#capitalize",
476
+ "foo".BM,
477
+ coda
478
+ end
479
+ RUBY
480
+ coda
481
+
482
+ #spec "#succeed?",
483
+ # "! Cannot be tested.",
484
+ # "! Cannot be described.",
485
+ #coda
486
+
487
+ #spec "#raise?",
488
+ # "! Cannot be tested.",
489
+ # "! Cannot be described.",
490
+ #coda
491
+
492
+ #spec "#throw?",
493
+ # "! Cannot be tested.",
494
+ # "! Cannot be described.",
495
+ #coda
496
+
497
+ # move spec "::RETURN",
498
+ # "! Cannot be tested.",
499
+ # "! Cannot be described",
500
+ # "! Moved because the file `input` cannot be listed.",
501
+ # "A placeholder for the return value of a previous successful unit test.",
502
+ # coda
503
+
504
+ # move spec "::RECEIVER",
505
+ # "! Cannot be tested.",
506
+ # "! Moved because the file `input` cannot be listed.",
507
+ # "A placeholder for the receiver value of a previous successful unit test.",
508
+ # coda
509
+
510
+ # move spec "::OUTPUT",
511
+ # "! Cannot be tested.",
512
+ # "! Moved because the file `input` cannot be listed.",
513
+ # "A placeholder for the terminal output during a previous successful unit test.",
514
+ # coda
515
+ end
516
+
517
+ class Module
518
+ move spec "#hide",
519
+ "! Cannot be tested.",
520
+ "! Moved because the file `manager.rb` cannot be listed.",
521
+ "When a `spec` method is prefixed with this method, the specification will be hided in the user' manual.",
522
+ {"()" => nil},
523
+ <<~'RUBY'.code,
524
+ hide spec "#foo",
525
+ ...
526
+ coda
527
+ RUBY
528
+ coda
529
+
530
+ move spec "#move",
531
+ "! Cannot be tested.",
532
+ "! Moved because the file `manager.rb` cannot be listed.",
533
+ "When a `spec` method is prefixed with this method, the specification will be immune to the misplaced warning.",
534
+ {"()" => nil},
535
+ <<~'RUBY'.code,
536
+ move spec "#foo",
537
+ ...
538
+ coda
539
+ RUBY
540
+ coda
541
+
542
+ move spec "#spec",
543
+ "! Cannot be tested.",
544
+ "! Moved because the file `input` cannot be listed.",
545
+ "The main method to describe a specification.",
546
+ {"(feature, *[items])" => value(nil)},
547
+ <<~'RUBY'.code,
548
+ spec "#foo",
549
+ ...
550
+ coda
551
+ RUBY
552
+ coda
553
+
554
+ move spec "#coda",
555
+ "! Cannot be tested.",
556
+ "! Moved because the file `input` cannot be listed.",
557
+ "A pseudo-keyword to close the block opened by the `spec` method.",
558
+ {"()" => Manager::Coda},
559
+ <<~'RUBY'.code,
560
+ spec "#foo",
561
+ ...
562
+ coda
563
+ RUBY
564
+ coda
565
+
566
+ move spec "#value",
567
+ "! Cannot be tested.",
568
+ "! Moved because the file `input` cannot be listed.",
569
+ "Wraps an individual object in a method signature.",
570
+ {"(object)" => Module},
571
+ <<~'RUBY'.code,
572
+ spec "#foo",
573
+ {"(string, array)" => String | value(nil)},
574
+ ...
575
+ coda
576
+ RUBY
577
+ coda
578
+
579
+ move spec "#error",
580
+ "! Cannot be tested.",
581
+ "! Moved because the file `input` cannot be listed.",
582
+ "Wraps an exception class in a method signature.",
583
+ {"(exception, **message: nil)" => Module},
584
+ <<~'RUBY'.code,
585
+ spec "#foo",
586
+ {"(string, array)" => String | error(ArgumentError)},
587
+ ...
588
+ coda
589
+ RUBY
590
+ coda
591
+
592
+ move spec "#image",
593
+ "! Cannot be tested.",
594
+ "Describe an image for the user's manual.",
595
+ {"(title, path)" => Manager::Render::Image},
596
+ <<~'RUBY'.code,
597
+ spec "#foo",
598
+ image("Initial diagram", "asset/initial_diagram.png"),
599
+ ...
600
+ coda
601
+ RUBY
602
+ coda
603
+
604
+ move spec "#image!",
605
+ "! Cannot be tested.",
606
+ "Describe an image for the developer's chart.",
607
+ {"(title, path)" => Manager::Render::Image},
608
+ <<~'RUBY'.code,
609
+ spec "#foo",
610
+ image!("Initial diagram", "asset/initial_diagram.png"),
611
+ ...
612
+ coda
613
+ RUBY
614
+ coda
615
+
616
+ move spec "#teardown",
617
+ "! Cannot be tested.",
618
+ "! Moved because the file `input` cannot be listed.",
619
+ "Resets the effect of all previous setups.",
620
+ {"()" => nil},
621
+ <<~'RUBY'.code,
622
+ spec "#foo",
623
+ "a = 3".setup,
624
+ ...
625
+ teardown,
626
+ coda
627
+ RUBY
628
+ coda
629
+ end
630
+
631
+ class Class
632
+ spec "#|",
633
+ {"(other)" => Manager::MethodSignatureAlternatives},
634
+ "Expresses alternatives in the output of method signatures.",
635
+ <<~'RUBY'.code,
636
+ spec "#foo",
637
+ {"(string, array)" => String | error(ArgumentError) | value(nil)},
638
+ ...
639
+ coda
640
+ RUBY
641
+ coda
642
+ end
643
+
644
+ hide spec "::Manager::Spellcheck",
645
+ coda
646
+
647
+ module Manager::Spellcheck
648
+ spec ".prepare",
649
+ "! Ensures to load the `ffi-aspell` gem.",
650
+ coda
651
+
652
+ spec ".list",
653
+ "! Returns the available dictionaries",
654
+ UT.include?("en") == true,
655
+ coda
656
+
657
+ spec ".language?",
658
+ "! Checks whether a given language is available.",
659
+ UT("en") == true,
660
+ coda
661
+
662
+ spec ".new",
663
+ coda
664
+
665
+ spec ".regex",
666
+ "! Returns a regular expression pattern for the language that extracts a word (the object of spell check).",
667
+ UT("en") =~ "word",
668
+ coda
669
+
670
+ spec ".filter",
671
+ "! Returns a list of non-existing words for the given language",
672
+ UT("en", %w[word nonword aaa who]) == %w[nonword aaa],
673
+ coda
674
+ end
675
+
676
+ hide spec "::Manager::Console",
677
+ coda
678
+
679
+ class Manager::Console
680
+ spec ".abort",
681
+ "! Cannot be tested.",
682
+ "! Routine to print an error message and terminate.",
683
+ coda
684
+ end
685
+
686
+ hide spec "::Manager::Context",
687
+ coda
688
+
689
+ hide spec "::Manager::Binding",
690
+ coda
691
+
692
+ hide spec "::Manager::ExprProc",
693
+ coda
694
+
695
+ hide spec "::Manager::Setup",
696
+ coda
697
+
698
+ hide spec "::Manager::Expr",
699
+ coda
700
+
701
+ hide spec "::Manager::UnitTest",
702
+ coda
703
+
704
+ hide spec "::Manager::Benchmark",
705
+ coda
706
+
707
+ hide spec "::Manager::Render",
708
+ coda
709
+
710
+ class Manager::Render
711
+ spec ".relative_path",
712
+ "! Returns the path relative to a given location. When given nil, returns `Manager.config(:bdir_expanded)`.",
713
+ coda
714
+ end
715
+
716
+ hide spec "::Manager::ModuleRefinement",
717
+ coda
718
+
719
+ hide spec "::Manager::ObjectMappingRefinement",
720
+ coda
721
+
722
+ hide spec "::Manager::TesterRefinement",
723
+ coda
724
+
725
+ class Object
726
+ spec "#in?",
727
+ {"(array)" => value(true) | value(false)},
728
+ "A helper method for writing tests. It switches the receiver and the argument of `Array#include?`.",
729
+ <<~'RUBY'.code,
730
+ 1.in?([1, 2]) #=> true
731
+ 3.in?([1, 2]) #=> false
732
+ RUBY
733
+ 1.UT([1, 2]) == true,
734
+ 3.UT([1, 2]) == false,
735
+ coda
736
+ end
737
+
738
+ class String
739
+ spec "#setup",
740
+ {"()" => Manager::Setup},
741
+ "Describes a setup to be used in tests.",
742
+ <<~'_'.code,
743
+ spec "#foo",
744
+ <<~'RUBY'.setup,
745
+ a = []
746
+ b = a * 10
747
+ c = [a, b]
748
+ RUBY
749
+ coda
750
+ _
751
+ coda
752
+
753
+ spec "#code",
754
+ {"(*language)" => Manager::Render::Code},
755
+ "Describes a code block for the user's manual. The optional `language` argument determines the language to be used in highlighting. By default, it is `:ruby`.",
756
+ <<~'_'.code,
757
+ spec "#foo",
758
+ <<~'RUBY'.code,
759
+ def foo
760
+ puts "This is Ruby code."
761
+ end
762
+ RUBY
763
+ <<~'CSS'.code(:css),
764
+ #main{
765
+ background-color: green;
766
+ }
767
+ CSS
768
+ coda
769
+ _
770
+ coda
771
+
772
+ spec "#code!",
773
+ {"(*language)" => Manager::Render::Code},
774
+ "Describes a code block for the developer's chart. The optional `language` argument determines the language to be used in highlighting. By default, it is `:ruby`.",
775
+ <<~'_'.code,
776
+ spec "#foo",
777
+ <<~'RUBY'.code!,
778
+ def foo
779
+ puts "This is Ruby code."
780
+ end
781
+ RUBY
782
+ <<~'CSS'.code!(:css),
783
+ #main{
784
+ background-color: green;
785
+ }
786
+ CSS
787
+ coda
788
+ _
789
+ coda
790
+ end