~ubuntu-branches/ubuntu/trusty/picolisp/trusty

« back to all changes in this revision

Viewing changes to .pc/picolisp_sync_to_tip.patch/test/src/main.l

  • Committer: Bazaar Package Importer
  • Author(s): Kan-Ru Chen
  • Date: 2011-07-11 17:48:35 UTC
  • Revision ID: james.westby@ubuntu.com-20110711174835-dwmwfgj6yfpny222
Tags: 3.0.7.2-2
* Sync to upstream tip.
* Drop two unused patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# 10jun11abu
 
2
# (c) Software Lab. Alexander Burger
 
3
 
 
4
### alarm ###
 
5
(let N 6
 
6
   (alarm 1 (inc 'N))
 
7
   (test 6 N)
 
8
   (wait 2000)
 
9
   (test 7 N)
 
10
   (alarm 0) )
 
11
 
 
12
 
 
13
### sigio ###
 
14
(unless (= *OS "SunOS")
 
15
   (off "SigVal")
 
16
   (sigio (setq "SigSock" (port T 0 "SigPort"))
 
17
      (setq "SigVal" (udp "SigSock")) )
 
18
   (test '((setq "SigVal" (udp "SigSock"))) (sigio))
 
19
   (udp "localhost" "SigPort" '(a b c))
 
20
   (wait 200)
 
21
   (test '(a b c) "SigVal")
 
22
   (sigio "SigSock")
 
23
   (test NIL (sigio)) )
 
24
 
 
25
 
 
26
### protect ###
 
27
(test NIL (pipe (prog (kill *Pid) (pr 7)) (rd)))
 
28
(test 7 (pipe (protect (kill *Pid) (pr 7)) (rd)))
 
29
 
 
30
 
 
31
### quit ###
 
32
(test "Quit" (catch '("Quit") (quit "Quit")))
 
33
 
 
34
 
 
35
### adr ###
 
36
(let (X (box 7)  L (123))
 
37
   (test 7 (val (adr (adr X))))
 
38
   (test 123 (car (adr (adr L)))) )
 
39
 
 
40
### env ###
 
41
(test NIL (env))
 
42
(test '((A . 1) (B . 2))
 
43
   (let (A 1 B 2)
 
44
      (env) ) )
 
45
(test '((B . 2) (A . 1))
 
46
   (let (A 1 B 2)
 
47
      (env '(A B)) ) )
 
48
(test '((Y . 8) (C . 3) (B . 2) (A . 1) (X . 7))
 
49
   (let (A 1 B 2)
 
50
      (env 'X 7 '(A B (C . 3)) 'Y 8) ) )
 
51
 
 
52
 
 
53
### up ###
 
54
(test 1
 
55
   (let N 1
 
56
      ((quote (N) (up N)) 2) ) )
 
57
(test 7
 
58
   (let N 1
 
59
      ((quote (N) (up N 7)) 2)
 
60
      N ) )
 
61
 
 
62
 
 
63
### args next arg rest ####
 
64
(test '(T 1 1 3 (2 3 4))
 
65
   (let foo '(@ (list (args) (next) (arg) (arg 2) (rest)))
 
66
      (foo 1 2 3 4) ) )
 
67
 
 
68
(test (7 7 NIL NIL)
 
69
   ((quote @ (list (next) (arg) (next) (arg))) 7) )
 
70
 
 
71
 
 
72
### usec ###
 
73
(let U (usec)
 
74
   (wait 400)
 
75
   (test 4 (*/ (- (usec) U) 100000)) )
 
76
 
 
77
 
 
78
### pwd ###
 
79
(test (path '@) (pack (pwd) '/))
 
80
 
 
81
 
 
82
### cd ###
 
83
(cd "test")
 
84
(test (path "@test") (pwd))
 
85
(cd "..")
 
86
 
 
87
 
 
88
### info ###
 
89
(test '(T . @) (info "test"))
 
90
(test (5 . @)
 
91
   (out (tmp "info") (prinl "info"))
 
92
   (info (tmp "info")) )
 
93
 
 
94
 
 
95
### file ###
 
96
(test (cons (tmp) "file" 1)
 
97
   (out (tmp "file") (println '(file)))
 
98
   (load (tmp "file")) )
 
99
 
 
100
 
 
101
### dir ###
 
102
(call 'mkdir "-p" (tmp "dir"))
 
103
(out (tmp "dir/.abc"))
 
104
(out (tmp "dir/a"))
 
105
(out (tmp "dir/b"))
 
106
(out (tmp "dir/c"))
 
107
 
 
108
(test '("a" "b" "c") (sort (dir (tmp "dir"))))
 
109
(test '("." ".." ".abc" "a" "b" "c") (sort (dir (tmp "dir") T)))
 
110
 
 
111
 
 
112
### cmd ###
 
113
(cmd "test")
 
114
(test "test" (cmd))
 
115
 
 
116
 
 
117
### argv ###
 
118
(test '("abc" "123")
 
119
   (pipe
 
120
      (call "bin/picolisp" "-prog (println (argv)) (bye)" "abc" 123)
 
121
      (read) ) )
 
122
(test '("abc" "123")
 
123
   (pipe
 
124
      (call "bin/picolisp" "-prog (argv A B) (println (list A B)) (bye)" "abc" 123)
 
125
      (read) ) )
 
126
 
 
127
 
 
128
### opt ###
 
129
(test '("abc" "123")
 
130
   (pipe
 
131
      (call "bin/picolisp" "-prog (println (list (opt) (opt))) (bye)" "abc" 123)
 
132
      (read) ) )
 
133
(test "abc"
 
134
   (pipe
 
135
      (call "bin/picolisp" "-de f () (println (opt))" "-f" "abc" "-bye")
 
136
      (read) ) )
 
137
 
 
138
 
 
139
### date time ###
 
140
(use (Dat1 Tim1 Dat2 Tim2 D1 T1 D2 T2)
 
141
   (until
 
142
      (=
 
143
         (setq Dat1 (date)  Tim1 (time T))
 
144
         (prog
 
145
            (setq
 
146
               Dat2 (date T)
 
147
               Tim2 (time T)
 
148
               D1 (in '(date "+%Y %m %d") (list (read) (read) (read)))
 
149
               T1 (in '(date "+%H %M %S") (list (read) (read) (read)))
 
150
               D2 (in '(date "-u" "+%Y %m %d") (list (read) (read) (read)))
 
151
               T2 (in '(date "-u" "+%H %M %S") (list (read) (read) (read))) )
 
152
            (time) ) ) )
 
153
   (test Tim1 (time T1))
 
154
   (test Tim1 (apply time T1))
 
155
   (test Tim2 (time T2))
 
156
   (test Dat1 (date D1))
 
157
   (test Dat1 (apply date D1))
 
158
   (test Dat2 (date D2)) )
 
159
 
 
160
(test (2000 7 15) (date 730622))
 
161
(test 730622 (date 2000 7 15))
 
162
(test 730622 (date (2000 7 15)))
 
163
(test NIL (date NIL))
 
164
 
 
165
(test (11 17 23) (time 40643))
 
166
(test 40643 (time 11 17 23))
 
167
(test 40643 (time (11 17 23)))
 
168
(test NIL (time NIL))
 
169
 
 
170
# vi:et:ts=3:sw=3