all repos — min @ 8bf2154657c0209e53cf153865a0874223de1ee9

A small but practical concatenative programming language.

tests/dict.min

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
'min-test require :test 
;;;

"dict" test.describe

  ((("a" 1)("b" 2)("c" 3)) dictionary? not) test.assert

  ({1 :a 2 :b 3 :c} dictionary?) test.assert

  ({1 :a 2 :b 3 :c} 'b dict.get 2 ==) test.assert

  ({1 :a 2 :b 3 :c} :dict1 dict1 5 'b dict.set 7 "d" dict.set :newdict newdict {1 :a 5 :b 3 :c 7 :d} ==  dict1 newdict != and) test.assert

  ({1 :a 2 :b 3 :c} :dict1 dict1 dict.dup 5 'b dict.set 7 "d" dict.set :newdict newdict {1 :a 5 :b 3 :c 7 :d} ==  dict1 {1 :a 2 :b 3 :c} == and) test.assert

  ({1 :a 2 :b 3 :c} :dict1 dict1 'b dict.del {1 :a 3 :c} ==) test.assert

  ({1 :a 2 :b 3 :c} dict.keys ("a" "b" "c") ==) test.assert

  ({1 :a 2 :b 3 :c} dict.values (1 2 3) ==) test.assert

  (global dict.type "module" ==) test.assert
  
  ({} dict.type "" ==) test.assert 

  ({1 :a 2 :b 3 :c 4 :d} ("b" "c") dict.pick {2 :b 3 :c} ==) test.assert

  (2 2 {+ :plus} "plus" dict.get 4 ==) test.assert

  (2 {(2 3 +) :sum} "sum" dict.get -> + 7 ==) test.assert

  ({a :test} "test" dict.get-raw "str" dict.get "a" ==) test.assert

  ({} 'aaa 'test dict.set-sym {aaa :test} ==) test.assert

  (
    {} :archives
    ({"a" :a 2 :b} {"aa" :a 4 :b} {"aaa" :a 6 :b})
    (
      :article
      article "a" dict.get :code
      {}
      code "code" dict.set
      :archive
      archives archive code dict.set @archives 
    ) foreach
    archives {{"a" :code} :a {"aa" :code} :aa {"aaa" :code} :aaa} ==) test.assert

  (
    {1 :a 2 :b 3 :c} dict.pairs ((1 "a") (2 "b") (3 "c")) ==
  ) test.assert

  test.report
  stack.clear