-
Notifications
You must be signed in to change notification settings - Fork 0
/
02.py
122 lines (122 loc) · 3.05 KB
/
02.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
test = {
'name': 'Problem 2',
'points': 1,
'suites': [
{
'cases': [
{
'code': r"""
>>> global_frame = create_global_frame()
>>> global_frame.define("x", 3)
>>> global_frame.parent is None
True
>>> global_frame.lookup("x")
3
>>> global_frame.define("x", 2)
>>> global_frame.lookup("x")
2
>>> global_frame.lookup("foo")
SchemeError
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> first_frame = create_global_frame()
>>> first_frame.define("x", 3)
>>> first_frame.define("y", False)
>>> second_frame = Frame(first_frame)
>>> second_frame.parent == first_frame
True
>>> second_frame.lookup("x")
3
>>> second_frame.lookup("y")
False
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> first_frame = create_global_frame()
>>> first_frame.define("x", 3)
>>> second_frame = Frame(first_frame)
>>> third_frame = Frame(second_frame)
>>> fourth_frame = Frame(third_frame)
>>> fourth_frame.lookup("x")
3
>>> second_frame.define("y", 1)
>>> fourth_frame.lookup("y")
1
>>> first_frame.define("y", 0)
>>> fourth_frame.lookup("y")
1
>>> fourth_frame.define("y", 2)
>>> fourth_frame.lookup("y")
2
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> first_frame = create_global_frame()
>>> first_frame.define("x", 1)
>>> second_frame = Frame(first_frame)
>>> third_frame = Frame(second_frame)
>>> fourth_frame = Frame(first_frame)
>>> fifth_frame = Frame(fourth_frame)
>>> fifth_frame.lookup("x")
1
>>> third_frame.lookup("x")
1
>>> second_frame.define("x", 2)
>>> third_frame.lookup("x")
2
>>> fifth_frame.lookup("x")
1
>>> fifth_frame.define("x", 5)
>>> fifth_frame.lookup("x")
5
>>> fourth_frame.lookup("x")
1
>>> first_frame.define("x", 4)
>>> fourth_frame.lookup("x")
4
>>> third_frame.lookup("x")
2
""",
'hidden': False,
'locked': False
}
],
'scored': True,
'setup': r"""
>>> from scheme import *
""",
'teardown': '',
'type': 'doctest'
},
{
'cases': [
{
'code': r"""
scm> +
#[+]
scm> display
#[display]
scm> hello
SchemeError
""",
'hidden': False,
'locked': False
}
],
'scored': True,
'setup': '',
'teardown': '',
'type': 'scheme'
}
]
}