Skip to content

Commit f613afe

Browse files
fix USING lines (#171)
accumulate and list-ops use math
1 parent 2b92cb8 commit f613afe

8 files changed

Lines changed: 13 additions & 10 deletions

File tree

bin/add-practice-exercise

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ module_name=$(echo "${slug}" | sed -r 's/(^|-)(\w)/\U\2/g')
7878
cat > "${exercise_dir}/.meta/generator.jl" << GENERATOR
7979
module ${module_name}
8080
81-
const HEADER = "USING: ${slug} tools.test ;"
82-
8381
function gen_test_case(case)
8482
error("TODO: implement gen_test_case for ${slug}")
8583
end

exercises/practice/accumulate/.meta/generator.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module Accumulate
22

3+
const EXTRA_VOCABS = ["math"]
4+
35
const ACCUMULATORS = Dict(
46
"(x) => x * x" => "[ dup * ]",
57
"(x) => upcase(x)" => "[ >upper ]",

exercises/practice/accumulate/accumulate/accumulate-tests.factor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
USING: accumulate io kernel lexer tools.test unicode ;
1+
USING: accumulate io kernel lexer math tools.test unicode ;
22
IN: accumulate.tests
33

44
: STOP-HERE ( -- ) lexer get [ text>> length ] keep line<< ; parsing

exercises/practice/armstrong-numbers/.meta/example.factor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
USING: assocs kernel locals math math.functions math.order sequences ;
2-
IN: armstrong
2+
IN: armstrong-numbers
33

44
:: digits ( x -- digits )
55
x 10 /mod :> x! :> xs!
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
USING: kernel ;
2-
IN: armstrong
2+
IN: armstrong-numbers
33

44
: armstrong? ( n -- ? )
55
"unimplemented" throw ;

exercises/practice/list-ops/.meta/generator.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module ListOps
22

3+
const EXTRA_VOCABS = ["math"]
4+
35
const WORD_NAMES = Dict(
46
"append" => "list-append",
57
"concat" => "list-concat",

exercises/practice/list-ops/list-ops/list-ops-tests.factor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
USING: io kernel lexer list-ops tools.test unicode ;
1+
USING: io kernel lexer list-ops math tools.test unicode ;
22
IN: list-ops.tests
33

44
: STOP-HERE ( -- ) lexer get [ text>> length ] keep line<< ; parsing

generator/generate.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,15 @@ const STOP_HERE_DEF = ": STOP-HERE ( -- ) lexer get [ text>> length ] keep line<
9999

100100
title_of(slug) = join((uppercasefirst(w) for w in split(slug, '-')), ' ')
101101

102-
function gen_header(cases, slug)
103-
vocabs = [slug, "lexer", "kernel", "io", "tools.test", "unicode"]
104-
sort!(vocabs)
102+
function gen_header(mod, slug)
103+
base = String["io", "kernel", "lexer", slug, "tools.test", "unicode"]
104+
extra = isdefined(mod, :EXTRA_VOCABS) ? collect(mod.EXTRA_VOCABS) : String[]
105+
vocabs = sort!(unique!(vcat(base, extra)))
105106
return "USING: $(join(vocabs, " ")) ;\nIN: $(slug).tests"
106107
end
107108

108109
function render_test_file(mod, cases, slug)
109-
lines = String[gen_header(cases, slug), ""]
110+
lines = String[gen_header(mod, slug), ""]
110111
push!(lines, STOP_HERE_DEF, "")
111112
if length(cases) > 1
112113
push!(lines, """"$(title_of(slug)):" print""", "")

0 commit comments

Comments
 (0)