case now throws the value it can't find
parent
07caee3405
commit
8bad9f014a
|
@ -324,3 +324,17 @@ DEFER: corner-case-1
|
||||||
[ 4 ] [ 2 corner-case-1 ] unit-test
|
[ 4 ] [ 2 corner-case-1 ] unit-test
|
||||||
|
|
||||||
[ 4 ] [ 2 2 [ + ] curry 1array case ] unit-test
|
[ 4 ] [ 2 2 [ + ] curry 1array case ] unit-test
|
||||||
|
|
||||||
|
: test-case-8 ( n -- )
|
||||||
|
{
|
||||||
|
{ 1 [ "foo" ] }
|
||||||
|
} case ;
|
||||||
|
|
||||||
|
[ 3 test-case-8 ]
|
||||||
|
[ object>> 3 = ] must-fail-with
|
||||||
|
|
||||||
|
[
|
||||||
|
3 {
|
||||||
|
{ 1 [ "foo" ] }
|
||||||
|
} case
|
||||||
|
] [ object>> 3 = ] must-fail-with
|
||||||
|
|
|
@ -49,7 +49,7 @@ ERROR: no-cond ;
|
||||||
reverse [ no-cond ] swap alist>quot ;
|
reverse [ no-cond ] swap alist>quot ;
|
||||||
|
|
||||||
! case
|
! case
|
||||||
ERROR: no-case ;
|
ERROR: no-case object ;
|
||||||
|
|
||||||
: case-find ( obj assoc -- obj' )
|
: case-find ( obj assoc -- obj' )
|
||||||
[
|
[
|
||||||
|
@ -66,7 +66,7 @@ ERROR: no-case ;
|
||||||
case-find {
|
case-find {
|
||||||
{ [ dup array? ] [ nip second call ] }
|
{ [ dup array? ] [ nip second call ] }
|
||||||
{ [ dup callable? ] [ call ] }
|
{ [ dup callable? ] [ call ] }
|
||||||
{ [ dup not ] [ no-case ] }
|
{ [ dup not ] [ drop no-case ] }
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
: linear-case-quot ( default assoc -- quot )
|
: linear-case-quot ( default assoc -- quot )
|
||||||
|
|
Loading…
Reference in New Issue