Fixing some unit test failures

db4
Slava Pestov 2009-04-06 03:30:23 -05:00
parent 3af8643c30
commit 0f04061079
4 changed files with 19 additions and 15 deletions

View File

@ -278,11 +278,7 @@ GENERIC: generic-see-test-with-f ( obj -- obj )
M: f generic-see-test-with-f ;
[ "USING: prettyprint.tests ;\nM: f generic-see-test-with-f ;\n" ] [
[ { POSTPONE: f generic-see-test-with-f } see ] with-string-writer
] unit-test
[ "USING: prettyprint.tests ;\nM: f generic-see-test-with-f ;\n" ] [
[ \ f \ generic-see-test-with-f method see ] with-string-writer
[ M\ f generic-see-test-with-f see ] with-string-writer
] unit-test
PREDICATE: predicate-see-test < integer even? ;
@ -309,5 +305,5 @@ GENERIC: ended-up-ballin' ( a -- b )
M: started-out-hustlin' ended-up-ballin' ; inline
[ "USING: prettyprint.tests ;\nM: started-out-hustlin' ended-up-ballin' ; inline\n" ] [
[ { started-out-hustlin' ended-up-ballin' } see ] with-string-writer
[ M\ started-out-hustlin' ended-up-ballin' see ] with-string-writer
] unit-test

View File

@ -1,10 +1,12 @@
IN: words.constant.tests
USING: tools.test math ;
USING: tools.test math words.constant ;
CONSTANT: a +
[ + ] [ a ] unit-test
[ t ] [ \ a constant? ] unit-test
CONSTANT: b \ +
[ \ + ] [ b ] unit-test
@ -12,3 +14,7 @@ CONSTANT: b \ +
CONSTANT: c { 1 2 3 }
[ { 1 2 3 } ] [ c ] unit-test
SYMBOL: foo
[ f ] [ \ foo constant? ] unit-test

View File

@ -3,12 +3,15 @@
USING: accessors kernel sequences words definitions quotations ;
IN: words.constant
PREDICATE: constant < word ( obj -- ? )
def>> dup length 1 = [ first word? not ] [ drop f ] if ;
PREDICATE: constant < word "constant" word-prop >boolean ;
: define-constant ( word value -- )
[ ] curry (( -- value )) define-inline ;
[ "constant" set-word-prop ]
[ [ ] curry (( -- value )) define-inline ] 2bi ;
M: constant reset-word
[ call-next-method ] [ f "constant" set-word-prop ] bi ;
M: constant definer drop \ CONSTANT: f ;
M: constant definition def>> first literalize 1quotation ;
M: constant definition "constant" word-prop literalize 1quotation ;

View File

@ -1,10 +1,9 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel sequences accessors definitions
words words.constant ;
USING: kernel sequences accessors definitions words ;
IN: words.symbol
PREDICATE: symbol < constant ( obj -- ? )
PREDICATE: symbol < word ( obj -- ? )
[ def>> ] [ [ ] curry ] bi sequence= ;
M: symbol definer drop \ SYMBOL: f ;
@ -12,4 +11,4 @@ M: symbol definer drop \ SYMBOL: f ;
M: symbol definition drop f ;
: define-symbol ( word -- )
dup define-constant ;
dup [ ] curry (( -- value )) define-inline ;