-
Notifications
You must be signed in to change notification settings - Fork 0
/
09.py
97 lines (97 loc) · 2.08 KB
/
09.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
test = {
'name': 'Problem 9',
'points': 2,
'suites': [
{
'cases': [
{
'code': r"""
scm> (define (f x y) (+ x y))
f
scm> f
(lambda (x y) (+ x y))
""",
'hidden': False,
'locked': False
},
{
'code': r"""
scm> (define (f) (+ 2 2))
f
scm> f
(lambda () (+ 2 2))
""",
'hidden': False,
'locked': False
},
{
'code': r"""
scm> (define (f x) (* x x))
f
scm> f
(lambda (x) (* x x))
""",
'hidden': False,
'locked': False
},
{
'code': r"""
scm> (define (foo x) 1 2 3 4 5)
foo
scm> foo
(lambda (x) 1 2 3 4 5)
""",
'hidden': False,
'locked': False
},
{
'code': r"""
scm> (define (foo) (/ 1 0))
foo
scm> foo
(lambda () (/ 1 0))
""",
'hidden': False,
'locked': False
},
{
'code': r"""
scm> (define (f 1 2 3) 4) ; check that you have valid formals
SchemeError
""",
'hidden': False,
'locked': False
}
],
'scored': True,
'setup': '',
'teardown': '',
'type': 'scheme'
},
{
'cases': [
{
'code': r"""
>>> inp = read_line("(define (f x) x)")
>>> scheme_eval(inp, env)
'f'
>>> scheme_eval('f', env)
LambdaProcedure(Pair('x', nil), Pair('x', nil), <Global Frame>)
>>> inp == read_line("(define (f x) x)") # Don't mutate the input expression!
True
""",
'hidden': False,
'locked': False
}
],
'scored': True,
'setup': r"""
>>> from scheme_reader import *
>>> from scheme import *
>>> env = create_global_frame()
""",
'teardown': '',
'type': 'doctest'
}
]
}