all repos — min @ 877cfd95409ab21b1ec1ec77c24249bf1411b2fb

A small but practical concatenative programming language.

tests/stack.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
'min-test require :test
;;;

"stack" test.describe

  (1 2 3 4 stack.get (1 2 3 4) ==) test.assert

  ((1 2 3) stack.set stack.get (1 2 3) ==) test.assert


  (2 stack.pop stack.get () ==) test.assert

  (1 stack.dup stack.get (1 1) ==) test.assert

  (3 2 (1 +) stack.dip + 6 ==) test.assert

  (1 2 stack.nip stack.get (2) ==) test.assert

  (1 2 4 '+ stack.dip stack.get (3 4) ==) test.assert

  (1 2 4 '+ stack.keep stack.get (1 6 4) ==) test.assert

  ((1) (2 stack.swap append) stack.sip concat (1 2 1) ==) test.assert

  (1 (2 3) stack.cons (1 2 3) ==) test.assert

  (1 2 stack.over stack.get (1 2 1) ==) test.assert

  (1 2 3 stack.pick stack.get (1 2 3 1) ==) test.assert

  ((1 2 3) ('sum 'size) => stack.cleave / 2 ==) test.assert

  ((1 2) (3 4) ((0 get) (1 get)) stack.spread stack.get (1 4) ==) test.assert

  test.report
  stack.clear