<commit_before>USING: tools.test alien.syntax specialized-arrays sequences
alien accessors kernel arrays combinators compiler
compiler.units classes.struct combinators.smart
compiler.tree.debugger math libc destructors sequences.private
multiline eval words vocabs namespaces assocs prettyprint
alien.data math.vectors definitions compiler.test ;
FROM: specialized-arrays.private => specialized-array-vocab ;
FROM: alien.c-types => int float bool uchar char float ulonglong ushort uint
heap-size ;
FROM: alien.data => little-endian? ;
IN: specialized-arrays.tests

SPECIALIZED-ARRAY: int
SPECIALIZED-ARRAYS: bool uchar ushort char uint float ulonglong ;

[ t ] [ { 1 2 3 } int >c-array int-array? ] unit-test

[ t ] [ int-array{ 1 2 3 } int-array? ] unit-test

[ 2 ] [ int-array{ 1 2 3 } second ] unit-test

[ t ] [
    { t f t } bool >c-array underlying>>
    { 1 0 1 } bool heap-size {
        { 1 [ char >c-array ] }
        { 4 [ uint >c-array ] }
    } case underlying>> =
] unit-test

[ ushort-array{ 1234 } ] [
    little-endian? B{ 210 4 } B{ 4 210 } ? ushort cast-array
] unit-test

[ B{ 210 4 1 } ushort cast-array ] must-fail

[ { 3 1 3 3 7 } ] [
    int-array{ 3 1 3 3 7 } malloc-byte-array 5 int <c-direct-array> >array
] unit-test

[ float-array{ 0x1.222,222p0   0x1.111,112p0   } ]
[ float-array{ 0x1.222,222,2p0 0x1.111,111,1p0 } ] unit-test

[ f ] [ float-array{ 4 3 2 1 } dup clone [ underlying>> ] bi@ eq? ] unit-test

[ f ] [ [ float-array{ 4 3 2 1 } dup clone [ underlying>> ] bi@ eq? ] compile-call ] unit-test

[ ushort-array{ 0 0 0 } ] [
    3 ALIEN: 123 100 <direct-ushort-array> new-sequence
    [ drop 0 ] map!
] unit-test

STRUCT: test-struct
    { x int }
    { y int } ;

SPECIALIZED-ARRAY: test-struct
<commit_msg>specialized-arrays: Don't leak in unit test.<commit_after>USING: tools.test alien.syntax specialized-arrays sequences
alien accessors kernel arrays combinators compiler
compiler.units classes.struct combinators.smart
compiler.tree.debugger math libc destructors sequences.private
multiline eval words vocabs namespaces assocs prettyprint
alien.data math.vectors definitions compiler.test ;
FROM: specialized-arrays.private => specialized-array-vocab ;
FROM: alien.c-types => int float bool uchar char float ulonglong ushort uint
heap-size ;
FROM: alien.data => little-endian? ;
IN: specialized-arrays.tests

SPECIALIZED-ARRAY: int
SPECIALIZED-ARRAYS: bool uchar ushort char uint float ulonglong ;

[ t ] [ { 1 2 3 } int >c-array int-array? ] unit-test

[ t ] [ int-array{ 1 2 3 } int-array? ] unit-test

[ 2 ] [ int-array{ 1 2 3 } second ] unit-test

[ t ] [
    { t f t } bool >c-array underlying>>
    { 1 0 1 } bool heap-size {
        { 1 [ char >c-array ] }
        { 4 [ uint >c-array ] }
    } case underlying>> =
] unit-test

[ ushort-array{ 1234 } ] [
    little-endian? B{ 210 4 } B{ 4 210 } ? ushort cast-array
] unit-test

[ B{ 210 4 1 } ushort cast-array ] must-fail

[ { 3 1 3 3 7 } ] [
    int-array{ 3 1 3 3 7 } malloc-byte-array [ 5 int <c-direct-array> >array ] with-disposal
] unit-test

[ float-array{ 0x1.222,222p0   0x1.111,112p0   } ]
[ float-array{ 0x1.222,222,2p0 0x1.111,111,1p0 } ] unit-test

[ f ] [ float-array{ 4 3 2 1 } dup clone [ underlying>> ] bi@ eq? ] unit-test

[ f ] [ [ float-array{ 4 3 2 1 } dup clone [ underlying>> ] bi@ eq? ] compile-call ] unit-test

[ ushort-array{ 0 0 0 } ] [
    3 ALIEN: 123 100 <direct-ushort-array> new-sequence
    [ drop 0 ] map!
] unit-test

STRUCT: test-struct
    { x int }
    { y int } ;

SPECIALIZED-ARRAY: test-struct

{'fraction_non_alphanumeric': 0.12913252331166997, 'fraction_numerical': 0.05651313930488839, 'mean_word_length': 3.078341013824885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5030332', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1276, 'n_words': 392}