Skip to content

Commit 5625cb5

Browse files
concept-partial-fail: test slice failure
1 parent cac5f18 commit 5625cb5

4 files changed

Lines changed: 16 additions & 2 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ 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` is `{ } rest`, which throws a slice-error. The runner must
17+
! report the readable summary, not a bare `T{ slice-error ... }`.
18+
{ { } } [ { } but-first ] unit-test
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
USING: kernel math ;
1+
USING: kernel math sequences ;
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 ;

tests/concept-partial-fail/expected_results.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
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 { }"
3340
}
3441
]
3542
}

0 commit comments

Comments
 (0)