1 USING: accessors english eval help.lint.coverage
2 help.lint.coverage.private help.markup help.syntax kernel
3 literals math math.matrices multiline sequences sorting
5 IN: help.lint.coverage.tests
8 : an-empty-word-with-a-unique-name ( a v -- x y ) ;
9 : a-nonexistent-word ( a v -- x y ) ;
10 : a-defined-word ( x -- x ) ;
12 HELP: an-empty-word-with-a-unique-name { $examples } ;
13 HELP: a-nonexistent-word ;
14 HELP: a-defined-word { $examples { $example "USING: prettyprint ; " "1 ." "1" } } ;
17 { t } [ \ an-empty-word-with-a-unique-name empty-examples? ] unit-test
18 { f } [ \ a-nonexistent-word empty-examples? ] unit-test
19 { f } [ \ a-defined-word empty-examples? ] unit-test
20 { f } [ \ keep empty-examples? ] unit-test
22 { { $description $values } } [ \ an-empty-word-with-a-unique-name missing-sections natural-sort ] unit-test
23 { { $description $values } } [ \ a-defined-word missing-sections natural-sort ] unit-test
24 { { } } [ \ keep missing-sections ] unit-test
26 { { "a.b" "a.b.c" } } [ { "a.b" "a.b.private" "a.b.c.private" "a.b.c" } filter-private ] unit-test
28 { "sections" } [ 0 "section" ?pluralize ] unit-test
29 { "section" } [ 1 "section" ?pluralize ] unit-test
30 { "sections" } [ 10 "section" ?pluralize ] unit-test
32 { { $examples } } [ \ an-empty-word-with-a-unique-name word-defines-sections ] unit-test
33 { { $examples } } [ \ a-defined-word word-defines-sections ] unit-test
34 { { } } [ \ a-nonexistent-word word-defines-sections ] unit-test
35 { { $values $description $examples } } [ \ keep word-defines-sections ] unit-test
36 { { $values $contract $examples } } [ \ <word-help-coverage> word-defines-sections ] unit-test
38 { an-empty-word-with-a-unique-name } [ "an-empty-word-with-a-unique-name" find-word ] unit-test
40 { { } } [ \ zero-matrix? missing-sections ] unit-test
41 { t } [ \ word-help-coverage? <word-help-coverage> 100%-coverage?>> ] unit-test
42 { t } [ \ zero-matrix? <word-help-coverage> 100%-coverage?>> ] unit-test
45 V{ "[" { $[ "math" dup lookup-vocab ] } "] " { "zero?" zero? } ": " }
47 V{ } clone \ zero? (assemble-word-metadata)
50 V{ "empty " { "$examples" $examples } "; " }
52 V{ } clone word-help-coverage new t >>empty-examples? (assemble-empty-examples)
56 V{ "needs help " "sections: " { { "$description" $description } " and " { "$examples" $examples } } }
58 V{ } clone word-help-coverage new { $description $examples } >>omitted-sections (assemble-omitted-sections)
61 V{ "needs help " "section: " { { "$description" $description } } }
63 V{ } clone word-help-coverage new { $description } >>omitted-sections (assemble-omitted-sections)
66 V{ "full help coverage" }
68 V{ } clone word-help-coverage new t >>100%-coverage? (assemble-full-coverage)
71 ! make sure this doesn't throw an error (would signify an issue with ignored-words)
72 [ { $io-error $prettyprinting-note $nl } [ <word-help-coverage> ] map ] must-not-fail
75 ! Lint system is written weirdly, there's no way to invoke it and get the output
76 ! Instead, it writes to lint-failures.
80 USING: assocs definitions math kernel namespaces help.syntax
81 help.lint help.lint.private continuations compiler.units ;
84 : add-stuff ( x y -- z ) + ;
89 H{ } clone lint-failures [
90 \ add-stuff check-word lint-failures get
91 assoc-empty? [ "help-lint is broken" throw ] when
94 [ \ add-stuff forget ] with-compilation-unit
102 ! clean up broken words
104 USING: definitions compiler.units ;
105 IN: help.lint.coverage.tests.private
107 \ an-empty-word-with-a-unique-name forget
108 \ a-nonexistent-word forget
109 \ a-defined-word forget
110 ] with-compilation-unit