tools.test math random ;
IN: bit-arrays.tests
+[ -1 <bit-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
+
[ 100 ] [ 100 <bit-array> length ] unit-test
[
-! Copyright (C) 2007, 2010 Slava Pestov.
+! Copyright (C) 2007, 2011 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.data accessors io.binary math math.bitwise
alien.accessors kernel kernel.private sequences
PRIVATE>
+ERROR: bad-array-length n ;
+
: <bit-array> ( n -- bit-array )
- dup bits>bytes <byte-array> bit-array boa ; inline
+ dup 0 < [ bad-array-length ] when
+ dup bits>bytes <byte-array>
+ bit-array boa ; inline
M: bit-array length length>> ; inline
USING: nibble-arrays tools.test sequences kernel math ;
IN: nibble-arrays.tests
+[ -1 <nibble-array> ] [ T{ bad-array-length f -1 } = ] must-fail-with
+
[ t ] [ 16 iota dup >nibble-array sequence= ] unit-test
[ N{ 4 2 1 3 } ] [ N{ 3 1 2 4 } reverse ] unit-test
[ N{ 1 4 9 0 9 4 } ] [ N{ 1 2 3 4 5 6 } [ sq ] map ] unit-test
PRIVATE>
+ERROR: bad-array-length n ;
+
: <nibble-array> ( n -- nibble-array )
+ dup 0 < [ bad-array-length ] when
dup nibbles>bytes <byte-array> nibble-array boa ; inline
M: nibble-array length length>> ;
USING: accessors alien alien.c-types alien.destructors
alien.libraries alien.syntax combinators debugger destructors
fry io kernel literals math prettyprint sequences splitting
-system words.constant
-graphviz
-;
+system memoize graphviz ;
IN: graphviz.ffi
-<<
"libgraph" {
{ [ os macosx? ] [ "libgraph.dylib" ] }
{ [ os unix? ] [ "libgraph.so" ] }
{ [ os unix? ] [ "libgvc.so" ] }
{ [ os winnt? ] [ "gvc.dll" ] }
} cond cdecl add-library
->>
LIBRARY: libgraph
LIBRARY: libgvc
! Graphviz contexts
-! This must be wrapped in << >> so that GVC_t*, gvContext, and
-! &gvFreeContext can be used to compute the supported-engines
-! and supported-formats constants below.
-<<
C-TYPE: GVC_t
FUNCTION: GVC_t* gvContext ( ) ;
int-gvFreeContext dup zero? [ drop ] [ ffi-errors ] if ;
DESTRUCTOR: gvFreeContext
->>
! Layout
! Supported layout engines (dot, neato, etc.) and output
! formats (png, jpg, etc.)
-
-<<
<PRIVATE
ENUM: api_t
] with-destructors ;
PRIVATE>
->>
-CONSTANT: supported-engines $[ API_layout plugin-list ]
-CONSTANT: supported-formats $[ API_device plugin-list ]
+MEMO: supported-engines ( -- seq ) API_layout plugin-list ;
+MEMO: supported-formats ( -- seq ) API_device plugin-list ;
! Copyright (C) 2011 Alex Vondrak.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators continuations destructors
-images.viewer io.backend io.files.unique kernel locals
-namespaces parser sequences summary unicode.case words
-graphviz.ffi
-graphviz.builder
-;
+USING: accessors combinators compiler.units continuations
+destructors images.viewer io.backend io.files.unique kernel
+locals namespaces parser sequences summary unicode.case words
+graphviz.ffi graphviz.builder ;
IN: graphviz.render
SYMBOL: default-layout
: preview-window ( graph -- )
(preview) image-window ; inline
-<<
-
<PRIVATE
: define-graphviz-by-engine ( -K -- )
PRIVATE>
-supported-engines [ define-graphviz-by-engine ] each
-supported-formats [ define-graphviz-by-format ] each
-
->>
+[
+ supported-engines [ define-graphviz-by-engine ] each
+ supported-formats [ define-graphviz-by-format ] each
+] with-compilation-unit