File tree Expand file tree Collapse file tree
tests/concept-partial-fail Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ RUN sed -i 's#-i="\$BOOT_IMAGE"#-i="$BOOT_IMAGE" -exclude="'"${FACTOR_EXCLUDE}"'
3333RUN ./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
3939RUN rm -rf .git build vm src misc Factor.app \
Original file line number Diff line number Diff line change 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 ;
22IN: concept-partial-fail.tests
33
44TASK: 1 squaring
@@ -11,3 +11,18 @@ STOP-HERE
1111TASK: 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
Original file line number Diff line number Diff line change 1- USING: kernel math ;
1+ USING: kernel math sequences strings ;
22IN: 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" ;
Original file line number Diff line number Diff line change 3030 "test_code" : " { 64 } [ 4 cube ] unit-test" ,
3131 "task_id" : 2 ,
3232 "message" : " === Expected:\n 64\n === Got:\n 20"
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\n from 1\n to 0\n seq { }"
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\n x 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\n index 10\n seq { 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.\n Dispatching 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\n quot [ drop ]\n call-site ( x -- x )"
3368 }
3469 ]
3570}
You can’t perform that action at this time.
0 commit comments