summary: improved summary for tuples
It reads nicer if it says "a blabla tuple" instead of just "blabla".locals-and-roots
parent
a974e752ab
commit
cf3e376ac0
|
@ -1,5 +1,13 @@
|
||||||
USING: summary tools.test ;
|
USING: combinators continuations kernel summary tools.test ;
|
||||||
IN: summary.tests
|
IN: summary.tests
|
||||||
|
|
||||||
|
{ "array with 2 elements" } [ { 1 2 } summary ] unit-test
|
||||||
{ "string with 5 elements" } [ "hello" summary ] unit-test
|
{ "string with 5 elements" } [ "hello" summary ] unit-test
|
||||||
{ "hash-set with 3 members" } [ HS{ 1 2 3 } summary ] unit-test
|
{ "hash-set with 3 members" } [ HS{ 1 2 3 } summary ] unit-test
|
||||||
|
{ "hashtable with 1 entries" } [ H{ { 3 4 } } summary ] unit-test
|
||||||
|
{ "Quotation's stack effect does not match call site" } [
|
||||||
|
[ [ ] f wrong-values ] [ ] recover summary
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
TUPLE: ooga-boga ;
|
||||||
|
{ "a ooga-boga tuple" } [ ooga-boga boa summary ] unit-test
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs classes continuations formatting kernel math
|
USING: accessors assocs classes continuations formatting kernel math
|
||||||
sequences sets strings ;
|
sequences sets ;
|
||||||
IN: summary
|
IN: summary
|
||||||
|
|
||||||
GENERIC: summary ( object -- string )
|
GENERIC: summary ( object -- string )
|
||||||
|
@ -11,17 +11,25 @@ GENERIC: summary ( object -- string )
|
||||||
: container-summary ( obj size word -- str )
|
: container-summary ( obj size word -- str )
|
||||||
[ object-summary ] 2dip "%s with %d %s" sprintf ;
|
[ object-summary ] 2dip "%s with %d %s" sprintf ;
|
||||||
|
|
||||||
|
GENERIC: tuple-summary ( object -- string )
|
||||||
|
|
||||||
|
M: assoc tuple-summary
|
||||||
|
dup assoc-size "entries" container-summary ;
|
||||||
|
|
||||||
|
M: object tuple-summary
|
||||||
|
class-of "a %s tuple" sprintf ;
|
||||||
|
|
||||||
|
M: unordered-set tuple-summary
|
||||||
|
dup cardinality "members" container-summary ;
|
||||||
|
|
||||||
|
M: tuple summary
|
||||||
|
tuple-summary ;
|
||||||
|
|
||||||
M: object summary object-summary ;
|
M: object summary object-summary ;
|
||||||
|
|
||||||
M: sequence summary
|
M: sequence summary
|
||||||
dup length "elements" container-summary ;
|
dup length "elements" container-summary ;
|
||||||
|
|
||||||
M: assoc summary
|
|
||||||
dup assoc-size "entries" container-summary ;
|
|
||||||
|
|
||||||
M: unordered-set summary
|
|
||||||
dup cardinality "members" container-summary ;
|
|
||||||
|
|
||||||
! Override sequence => integer instance
|
! Override sequence => integer instance
|
||||||
M: f summary object-summary ;
|
M: f summary object-summary ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue