]> gitweb.factorcode.org Git - factor.git/blob - core/classes/error/error-tests.factor
change ERROR: words from throw-foo back to foo.
[factor.git] / core / classes / error / error-tests.factor
1 ! Copyright (C) 2015 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors classes classes.error classes.tuple
4 compiler.units effects eval generic io.streams.string kernel
5 math namespaces parser tools.test words words.symbol ;
6 IN: classes.error.tests
7
8 ! Test error classes
9 ERROR: error-class-test a b c ;
10
11 { "( a b c -- * )" } [ \ error-class-test stack-effect effect>string ] unit-test
12 { f } [ \ error-class-test "inline" word-prop ] unit-test
13
14 [ "IN: classes.error.tests ERROR: error-x ; : error-x 3 ;" eval( -- ) ]
15 [ error>> error>> redefine-error? ] must-fail-with
16
17 DEFER: error-y
18
19 { } [ [ \ error-y dup class? [ forget-class ] [ drop ] if ] with-compilation-unit ] unit-test
20
21 { } [ "IN: classes.error.tests GENERIC: error-y ( a -- b )" eval( -- ) ] unit-test
22
23 { f } [ \ error-y tuple-class? ] unit-test
24
25 { f } [ \ error-y error-class? ] unit-test
26
27 { t } [ \ error-y generic? ] unit-test
28
29 { } [ "IN: classes.error.tests ERROR: error-y ;" eval( -- ) ] unit-test
30
31 { t } [ \ error-y tuple-class? ] unit-test
32
33 { t } [ \ error-y error-class? ] unit-test
34
35 { f } [ \ error-y generic? ] unit-test
36
37 ERROR: base-error x y ;
38 ERROR: derived-error < base-error z ;
39
40 { ( x y z -- * ) } [ \ derived-error stack-effect ] unit-test