[ this_does_not_exist ] try\r
\r
[ this_does_not_exist ] [\r
- { "kernel-error" 9 $[ "this_does_not_exist" string>symbol ] f }\r
+ ${ "kernel-error" ERROR-UNDEFINED-SYMBOL "this_does_not_exist" string>symbol f }
=\r
] must-fail-with\r
\r
[ no_such_function ] try\r
\r
[ no_such_function ] [\r
- {\r
- "kernel-error" 9\r
- $[ "no_such_function" string>symbol ]\r
- $[ "no_such_library" load-library ]\r
+ ${
+ "kernel-error" ERROR-UNDEFINED-SYMBOL
+ "no_such_function" string>symbol
+ "no_such_library" load-library
}\r
=\r
] must-fail-with\r
: memory-error. ( error -- )
"Memory protection fault at address " write third .h ;
-: primitive-error. ( error -- )
+: primitive-error. ( error -- )
"Unimplemented primitive" print drop ;
: fp-trap-error. ( error -- )
dup length 2 < [ drop f ] [
{
[ first-unsafe "kernel-error" = ]
- [ second-unsafe 0 18 between? ]
+ [ second-unsafe 0 kernel-error-count 1 - between? ]
} 1&&
] if ;
USING: kernel math math.floats.env math.floats.env.private
-math.functions math.libm sequences tools.test locals
+math.functions math.libm literals sequences tools.test locals
compiler.units kernel.private fry compiler.test math.private
words system memory ;
IN: math.floats.env.tests
] unit-test
: fp-trap-error? ( error -- ? )
- 2 head { "kernel-error" 17 } = ;
+ 2 head ${ "kernel-error" ERROR-FP-TRAP } = ;
: test-traps ( traps inputs quot -- quot' fail-quot )
append '[ _ _ with-fp-traps ] [ fp-trap-error? ] ;
-USING: arrays byte-arrays kernel kernel.private math memory
-namespaces sequences tools.test math.private quotations
+USING: arrays byte-arrays kernel kernel.private literals math
+memory namespaces sequences tools.test math.private quotations
continuations prettyprint io.streams.string debugger assocs
sequences.private accessors locals.backend grouping words
system alien alien.accessors ;
[ ] [ 1000 [ [ -1 f <array> ] ignore-errors ] times ] unit-test
! Make sure we report the correct error on stack underflow
-[ clear drop ] [ { "kernel-error" 10 f f } = ] must-fail-with
+[ clear drop ] [
+ ${ "kernel-error" ERROR-DATASTACK-UNDERFLOW f f } =
+] must-fail-with
[ ] [ :c ] unit-test
-[ 3 [ { } set-retainstack ] dip ] [ { "kernel-error" 12 f f } = ] must-fail-with
+[
+ 3 [ { } set-retainstack ] dip ]
+ [ ${ "kernel-error" ERROR-RETAINSTACK-UNDERFLOW f f } =
+] must-fail-with
[ ] [ :c ] unit-test
[ t "no-compile" set-word-prop ] each
>>
-[ overflow-d ] [ { "kernel-error" 11 f f } = ] must-fail-with
+[ overflow-d ] [
+ ${ "kernel-error" ERROR-DATASTACK-OVERFLOW f f } =
+] must-fail-with
[ ] [ :c ] unit-test
-[ overflow-d-alt ] [ { "kernel-error" 11 f f } = ] must-fail-with
+[ overflow-d-alt ] [
+ ${ "kernel-error" ERROR-DATASTACK-OVERFLOW f f } =
+] must-fail-with
[ ] [ [ :c ] with-string-writer drop ] unit-test
-[ overflow-r ] [ { "kernel-error" 13 f f } = ] must-fail-with
+[ overflow-r ] [
+ ${ "kernel-error" ERROR-RETAINSTACK-OVERFLOW f f } =
+] must-fail-with
[ ] [ :c ] unit-test
! because no facility exists to run memory protection
! fault handlers on an alternate callstack.
os windows? [
- [ overflow-c ] [ { "kernel-error" 15 f f } = ] must-fail-with
+ [ overflow-c ] [
+ ${ "kernel-error" ERROR-CALLSTACK-OVERFLOW f f } =
+ ] must-fail-with
] unless
[ -7 <byte-array> ] must-fail
CONSTANT: CONTEXT-OBJ-IN-CALLBACK-P 3
PRIVATE>
+
+! Runtime errors must be kept in sync with:
+! vm/errors.hpp
+CONSTANT: kernel-error-count 19
+CONSTANT: ERROR-EXPIRED 0
+CONSTANT: ERROR-IO 1
+CONSTANT: ERROR-NOT-IMPLEMENTED 2
+CONSTANT: ERROR-TYPE 3
+CONSTANT: ERROR-DIVIDE-BY-ZERO 4
+CONSTANT: ERROR-SIGNAL 5
+CONSTANT: ERROR-ARRAY-SIZE 6
+CONSTANT: ERROR-C-STRING 7
+CONSTANT: ERROR-FFI 8
+CONSTANT: ERROR-UNDEFINED-SYMBOL 9
+CONSTANT: ERROR-DATASTACK-UNDERFLOW 10
+CONSTANT: ERROR-DATASTACK-OVERFLOW 11
+CONSTANT: ERROR-RETAINSTACK-UNDERFLOW 12
+CONSTANT: ERROR-RETAINSTACK-OVERFLOW 13
+CONSTANT: ERROR-CALLSTACK-UNDERFLOW 14
+CONSTANT: ERROR-CALLSTACK-OVERFLOW 15
+CONSTANT: ERROR-MEMORY 16
+CONSTANT: ERROR-FP-TRAP 17
+CONSTANT: ERROR-INTERRUPT 18
-USING: continuations kernel math math.order namespaces make
+USING: continuations kernel literals math math.order namespaces make
strings strings.private sbufs tools.test sequences vectors
arrays memory prettyprint io.streams.null ;
IN: strings.tests
[ 1 "" nth ] must-fail
[ -6 "hello" nth ] must-fail
-[ t ] [ "hello world" dup >vector >string = ] unit-test
+[ t ] [ "hello world" dup >vector >string = ] unit-test
[ "ab" ] [ 2 "abc" resize-string ] unit-test
[ "abc\0\0\0" ] [ 6 "abc" resize-string ] unit-test
[ "\u001234bc\0\0\0" ] [ 6 "\u001234bc" resize-string ] unit-test
! Random tester found this
-[ 2 -7 resize-string ] [ { "kernel-error" 3 11 -7 } = ] must-fail-with
+[ 2 -7 resize-string ]
+[ ${ "kernel-error" ERROR-TYPE 11 -7 } = ] must-fail-with
! Make sure 24-bit strings work
"hello world" "s" set
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-USING: continuations decimals grouping kernel locals math
-math.functions math.order math.ratios prettyprint random
+USING: continuations decimals grouping kernel literals locals
+math math.functions math.order math.ratios prettyprint random
sequences tools.test ;
IN: decimals.tests
1000 [
drop
[ [ 100 D/ ] [ /f ] test-decimal-op ]
- [ { "kernel-error" 4 f f } = ] recover
+ [ ${ "kernel-error" ERROR-DIVIDE-BY-ZERO f f } = ] recover
] all-integers?
] unit-test
-[ t ] [
+[ t ] [
{ D: 0. D: .0 D: 0.0 D: 00.00 D: . } all-equal?
] unit-test
namespace factor {
-/* Runtime errors */
+// Runtime errors must be kept in sync with:
+// core/kernel/kernel.factor
enum vm_error_type {
ERROR_EXPIRED = 0,
ERROR_IO,