<commit_before>! Copyright (C) 2010 <NAME>
! See http://factorcode.org/license.txt for BSD license

USING: arrays assocs calendar math math.functions memcached
memcached.private kernel present sequences system threads
tools.test ;

IN: memcached.tests

<PRIVATE

: not-found? ( quot -- )
    [ key-not-found? ] must-fail-with ;

: x ( -- str ) cpu present "-x" append ;
: y ( -- str ) cpu present "-y" append ;
: z ( -- str ) cpu present "-z" append ;

PRIVATE>

! test version
[ t ] [ [ m/version ] with-memcached length 0 > ] unit-test

! test simple set get
[ m/flush ] with-memcached
[ "valuex" x m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test

! test flush
[ m/flush ] with-memcached
[ "valuex" x m/set "valuey" y m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
[ "valuey" ] [ [ y m/get ] with-memcached ] unit-test
[ m/flush ] with-memcached
[ [ x m/get ] with-memcached ] not-found?
[ [ y m/get ] with-memcached ] not-found?

! test noop
[ m/noop ] with-memcached

! test delete
[ m/flush ] with-memcached
[ "valuex" x m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
[ x m/delete ] with-memcached
[ [ x m/get ] with-memcached ] not-found?

! test replace
[ m/flush ] with-memcached
[ [ x m/get ] with-memcached ] not-found?
[ [ "ex" x m/replace ] with-memcached ] not-found?
[ "ex" x m/add ] with-memcached
[ "ex" ] [ [ x m/get ] with-memcached ] unit-test
[ "ex2" x m/replace ] with-memcached
[ "ex2" ] [ [ x m/get ] with-memcached ] unit-test

! test incr
[ m/flush ] with-memcached
[ 0 ] [ [ x m/incr ] with-memcached ] unit-test
[ 1 ] [ [ x m/incr ] with-memcached ] unit-test
[ 212 ] [ [ 211 x m/incr-val ] with-memcached ] unit-test
[ 8589934804 ] [ [ 2 33 ^ x m/incr-val ] with-memcached ] unit-test

! test decr
[ m/flush ] with-memcached
[ "5" x m/set ] with-memcached
[ 4 ] [ [ x m/decr ] with-memcached ] unit-test
[ 0 ] [ [ 211 x m/decr-val ] with-memcached ] unit-test

! test timebombed flush
[ m/flush ] with-memcached
[ [ x m/get ] with-memcached ] not-found?
[ "valuex" x m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
[ 2 m/flush-later ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
3 seconds sleep
[ [ x m/get ] with-memcached ] not-found?

! test append
[ m/flush ] with-memcached
[ "some" x m/set ] with-memcached
[ "thing" x m/append ] with-memcached
[ "something" ] [ [ x m/get ] with-memcached ] unit-test

! test prepend
[ m/flush ] with-memcached
[ "some" x m/set ] with-memcached
[ "thing" x m/prepend ] with-memcached
[ "thingsome" ] [ [ x m/get ] with-memcached ] unit-test

! test multi-get
[ m/flush ] with-memcached
[ H{ } ] [ [ x y z 3array m/getseq ] with-memcached ] unit-test
[ "5" x m/set ] with-memcached
[ "valuex" y m/set ] with-memcached
[ { "5" "valuex" } ] [
    [ x y z 3array m/getseq values ] with-memcached
] unit-test
<commit_msg>memcached: enforce sorted order for test results.<commit_after>! Copyright (C) 2010 <NAME>
! See http://factorcode.org/license.txt for BSD license

USING: arrays assocs calendar math math.functions memcached
memcached.private kernel present sequences sorting system
threads tools.test ;

IN: memcached.tests

<PRIVATE

: not-found? ( quot -- )
    [ key-not-found? ] must-fail-with ;

: x ( -- str ) cpu present "-x" append ;
: y ( -- str ) cpu present "-y" append ;
: z ( -- str ) cpu present "-z" append ;

PRIVATE>

! test version
[ t ] [ [ m/version ] with-memcached length 0 > ] unit-test

! test simple set get
[ m/flush ] with-memcached
[ "valuex" x m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test

! test flush
[ m/flush ] with-memcached
[ "valuex" x m/set "valuey" y m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
[ "valuey" ] [ [ y m/get ] with-memcached ] unit-test
[ m/flush ] with-memcached
[ [ x m/get ] with-memcached ] not-found?
[ [ y m/get ] with-memcached ] not-found?

! test noop
[ m/noop ] with-memcached

! test delete
[ m/flush ] with-memcached
[ "valuex" x m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
[ x m/delete ] with-memcached
[ [ x m/get ] with-memcached ] not-found?

! test replace
[ m/flush ] with-memcached
[ [ x m/get ] with-memcached ] not-found?
[ [ "ex" x m/replace ] with-memcached ] not-found?
[ "ex" x m/add ] with-memcached
[ "ex" ] [ [ x m/get ] with-memcached ] unit-test
[ "ex2" x m/replace ] with-memcached
[ "ex2" ] [ [ x m/get ] with-memcached ] unit-test

! test incr
[ m/flush ] with-memcached
[ 0 ] [ [ x m/incr ] with-memcached ] unit-test
[ 1 ] [ [ x m/incr ] with-memcached ] unit-test
[ 212 ] [ [ 211 x m/incr-val ] with-memcached ] unit-test
[ 8589934804 ] [ [ 2 33 ^ x m/incr-val ] with-memcached ] unit-test

! test decr
[ m/flush ] with-memcached
[ "5" x m/set ] with-memcached
[ 4 ] [ [ x m/decr ] with-memcached ] unit-test
[ 0 ] [ [ 211 x m/decr-val ] with-memcached ] unit-test

! test timebombed flush
[ m/flush ] with-memcached
[ [ x m/get ] with-memcached ] not-found?
[ "valuex" x m/set ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
[ 2 m/flush-later ] with-memcached
[ "valuex" ] [ [ x m/get ] with-memcached ] unit-test
3 seconds sleep
[ [ x m/get ] with-memcached ] not-found?

! test append
[ m/flush ] with-memcached
[ "some" x m/set ] with-memcached
[ "thing" x m/append ] with-memcached
[ "something" ] [ [ x m/get ] with-memcached ] unit-test

! test prepend
[ m/flush ] with-memcached
[ "some" x m/set ] with-memcached
[ "thing" x m/prepend ] with-memcached
[ "thingsome" ] [ [ x m/get ] with-memcached ] unit-test

! test multi-get
[ m/flush ] with-memcached
[ H{ } ] [ [ x y z 3array m/getseq ] with-memcached ] unit-test
[ "5" x m/set ] with-memcached
[ "valuex" y m/set ] with-memcached
[ { "5" "valuex" } ] [
    [ x y z 3array m/getseq values natural-sort ] with-memcached
] unit-test

{'fraction_non_alphanumeric': 0.16257824395195397, 'fraction_numerical': 0.013534088986635088, 'mean_word_length': 3.0299931833674165, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '352278', 'n_tokens_mistral': 2336, 'n_tokens_neox': 2266, 'n_words': 612}