Bug fixes for lcs.diff2html; xml.writer
[factor/jcg.git] / basis / linked-assocs / linked-assocs-tests.factor
blob7a259ee59ae26932130dc175a0479efb6675a397
1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel sequences assocs tools.test linked-assocs math ;
4 IN: linked-assocs.test
6 { { 1 2 3 } } [
7     <linked-hash> 1 "b" pick set-at
8                   2 "c" pick set-at
9                   3 "a" pick set-at
10     values
11 ] unit-test
13 { 2 t } [
14     <linked-hash> 1 "b" pick set-at
15                   2 "c" pick set-at
16                   3 "a" pick set-at
17     "c" swap at*
18 ] unit-test
20 { { 2 3 4 } { "c" "a" "d" } 3 } [
21     <linked-hash> 1 "a" pick set-at
22                   2 "c" pick set-at
23                   3 "a" pick set-at
24                   4 "d" pick set-at
25     [ values ] [ keys ] [ assoc-size ] tri
26 ] unit-test 
28 { f 1 } [
29     <linked-hash> 1 "c" pick set-at
30                   2 "b" pick set-at
31     "c" over delete-at
32     "c" over at swap assoc-size
33 ] unit-test 
35 { { } 0 } [
36     <linked-hash> 1 "a" pick set-at
37                   2 "c" pick set-at
38                   3 "a" pick set-at
39                   4 "d" pick set-at
40     dup clear-assoc [ keys ] [ assoc-size ] bi
41 ] unit-test
43 { { } { 1 2 3 } } [
44     <linked-hash> dup clone
45     1 "c" pick set-at
46     2 "q" pick set-at
47     3 "a" pick set-at
48     [ values ] bi@
49 ] unit-test
51 { 9 } [
52     <linked-hash>
53     { [ 3 * ] [ 1- ] }          "first"   pick set-at
54     { [ [ 1- ] bi@ ] [ 2 / ] }  "second"  pick set-at
55     4 6 pick values [ first call ] each
56     + swap values <reversed> [ second call ] each
57 ] unit-test