-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.robin
40 lines (29 loc) · 1.14 KB
/
export.robin
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
;'<<SPEC'
-> Tests for functionality "Evaluate Robin Expression (with Env)"
`export` treats its arguments as a list of identifiers, and returns an
environment where only those identifiers are bound to values.
The original idea for `sandbox` was that it could be used in the body of
a module to restrict the visible identifiers to those the module wished
to export, which could then actually be exported with `env`. However,
this still required `env` to be a visible identifier (and thus exported.)
`export` simply evaluates to a binding alist which can be returned
directly.
Note: the order of the bindings in the binding alist isn't guaranteed;
thus these tests are written to search the resulting alist.
| (let ((a 1) (b 6))
| (length (export a b)))
= 2
| (let ((a 1) (b 6))
| (lookup (literal a) (export a b)))
= (1)
| (let ((a 1) (b 6))
| (lookup (literal b) (export a b)))
= (6)
| (lookup (literal head) (export head tail))
= (head)
| (lookup (literal prepend) (export head tail))
= ()
'<<SPEC'
(define export
(fexpr (args env)
(filter (fun (binding) (elem? (head binding) args)) env)))