Skip to content

Commit 4da98b9

Browse files
inspector vocab for error reporting (exercism#20)
We no longer cull the inspector vocab
1 parent 3b26fd6 commit 4da98b9

4 files changed

Lines changed: 58 additions & 3 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUN sed -i 's#-i="\$BOOT_IMAGE"#-i="$BOOT_IMAGE" -exclude="'"${FACTOR_EXCLUDE}"'
3333
RUN ./build.sh net-bootstrap
3434

3535
# Precompile tools.test AND the common exercise vocabs into factor.image, then re-save it.
36-
RUN ./factor -e='USING: accessors arrays ascii assocs bit-arrays calendar calendar.english circular combinators combinators.short-circuit command-line concurrency.combinators concurrency.locks continuations debugger deques destructors disjoint-sets dlists formatting fry generic grouping hash-sets hashtables heaps infix io io.encodings.utf8 io.files io.streams.string kernel lexer locals macros make math math.bitwise math.combinatorics math.constants math.functions math.order math.parser math.primes math.statistics namespaces pair-rocket prettyprint.config quotations qw random random.mersenne-twister ranges regexp sequences sequences.repeating sets sorting source-files.errors.debugger splitting splitting.monotonic strings system tools.test tr typed unicode vectors vocabs vocabs.loader memory ; save'
36+
RUN ./factor -e='USING: accessors arrays ascii assocs bit-arrays calendar calendar.english circular combinators combinators.short-circuit command-line concurrency.combinators concurrency.locks continuations debugger deques destructors disjoint-sets dlists formatting fry generic grouping hash-sets hashtables heaps infix inspector io io.encodings.utf8 io.files io.streams.string kernel lexer locals macros make math math.bitwise math.combinatorics math.constants math.functions math.order math.parser math.primes math.statistics namespaces pair-rocket prettyprint.config quotations qw random random.mersenne-twister ranges regexp sequences sequences.repeating sets sorting source-files.errors.debugger splitting splitting.monotonic strings system tools.test tr typed unicode vectors vocabs vocabs.loader memory ; save'
3737

3838
# Remove files not needed at runtime
3939
RUN rm -rf .git build vm src misc Factor.app \

tests/concept-partial-fail/concept-partial-fail/concept-partial-fail-tests.factor

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
USING: concept-partial-fail exercism-tools io kernel prettyprint tools.test ;
1+
USING: concept-partial-fail exercism-tools io kernel math prettyprint sequences tools.test ;
22
IN: concept-partial-fail.tests
33

44
TASK: 1 squaring
@@ -11,3 +11,18 @@ STOP-HERE
1111
TASK: 2 cubing
1212
{ 27 } [ "cubing 3" print 3 cube ] unit-test
1313
{ 64 } [ 4 cube ] unit-test
14+
15+
TASK: 3 dropping the first element
16+
{ { } } [ { } but-first ] unit-test
17+
18+
TASK: 4 divide by zero
19+
{ 0 } [ 4 0 / ] unit-test
20+
21+
TASK: 5 index out of bounds
22+
{ 0 } [ 10 { 1 2 3 } nth ] unit-test
23+
24+
TASK: 6 method lookup
25+
{ "text" } [ 5 label ] unit-test
26+
27+
TASK: 7 stack effect mismatch
28+
{ 0 } [ 5 [ drop ] call( x -- x ) ] unit-test
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
USING: kernel math ;
1+
USING: kernel math sequences strings ;
22
IN: concept-partial-fail
33

44
: square ( n -- n^2 ) dup * ;
55

66
: cube ( n -- n^3 ) dup dup * + ;
7+
8+
: but-first ( seq -- rest ) rest ;
9+
10+
GENERIC: label ( obj -- str )
11+
M: string label drop "text" ;

tests/concept-partial-fail/expected_results.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,41 @@
3030
"test_code": "{ 64 } [ 4 cube ] unit-test",
3131
"task_id": 2,
3232
"message": "=== Expected:\n64\n=== Got:\n20"
33+
},
34+
{
35+
"name": "Test 5",
36+
"status": "error",
37+
"test_code": "{ { } } [ { } but-first ] unit-test",
38+
"task_id": 3,
39+
"message": "Cannot create slice: from > to\nfrom 1\nto 0\nseq { }"
40+
},
41+
{
42+
"name": "Test 6",
43+
"status": "error",
44+
"test_code": "{ 0 } [ 4 0 / ] unit-test",
45+
"task_id": 4,
46+
"message": "Division by zero\nx 4"
47+
},
48+
{
49+
"name": "Test 7",
50+
"status": "error",
51+
"test_code": "{ 0 } [ 10 { 1 2 3 } nth ] unit-test",
52+
"task_id": 5,
53+
"message": "Sequence index out of bounds\nindex 10\nseq { 1 2 3 }"
54+
},
55+
{
56+
"name": "Test 8",
57+
"status": "error",
58+
"test_code": "{ \"text\" } [ 5 label ] unit-test",
59+
"task_id": 6,
60+
"message": "Generic word label does not define a method for the fixnum class.\nDispatching on object: 5"
61+
},
62+
{
63+
"name": "Test 9",
64+
"status": "error",
65+
"test_code": "{ 0 } [ 5 [ drop ] call( x -- x ) ] unit-test",
66+
"task_id": 7,
67+
"message": "Quotation's stack effect does not match call site\nquot [ drop ]\ncall-site ( x -- x )"
3368
}
3469
]
3570
}

0 commit comments

Comments
 (0)