forked from hcientist/OnlinePythonTutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock-data.js
86 lines (69 loc) · 18.1 KB
/
mock-data.js
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
// mock data for UI
/* From this test script:
x = {1 : 2}
x[('tup', 'le')] = set([1, 2, 3])
def foo():
local_x = {1 : 2}
local_y = {}
local_y[('tup', 'le')] = set([1, 2, 3])
print "hello", local_y.values()
foo()
*/
dict_test_trace = [{"globals": {}, "stdout": "", "func_name": "<module>", "line": 1, "stack_locals": [], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]]}, "stdout": "", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]]}, "stdout": "", "func_name": "<module>", "line": 4, "stack_locals": [], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "", "func_name": "<module>", "line": 10, "stack_locals": [], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "", "func_name": "foo", "line": 4, "stack_locals": [["foo", {}]], "event": "call"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "", "func_name": "foo", "line": 5, "stack_locals": [["foo", {}]], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "", "func_name": "foo", "line": 6, "stack_locals": [["foo", {"local_x": ["DICT", [1, 2]]}]], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "", "func_name": "foo", "line": 7, "stack_locals": [["foo", {"local_y": ["DICT", [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "local_x": ["DICT", [1, 2]]}]], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "", "func_name": "foo", "line": 8, "stack_locals": [["foo", {"local_y": ["DICT", [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "local_x": ["DICT", [1, 2]]}]], "event": "step_line"}, {"globals": {"x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "hello [set([1, 2, 3])]\n", "func_name": "foo", "line": 8, "stack_locals": [["foo", {"__return__": null, "local_y": ["DICT", [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "local_x": ["DICT", [1, 2]]}]], "event": "return"}, {"globals": {"__return__": null, "x": ["DICT", [1, 2], [["TUPLE", "tup", "le"], ["SET", 1, 2, 3]]], "foo": "<user-defined function>"}, "stdout": "hello [set([1, 2, 3])]\n", "func_name": "<module>", "line": 10, "stack_locals": [], "event": "return"}]
/*
x = 5
y = 10
z = x * y
print "HELLO WORLD"
for i in range(10):
print z * i
*/
simple_test_trace =
[{"globals": {}, "stdout": "", "func_name": "<module>", "line": 1, "stack_locals": [], "event": "step_line"}, {"globals": {"x": 5}, "stdout": "", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5}, "stdout": "", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "z": 50}, "stdout": "", "func_name": "<module>", "line": 4, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "z": 50}, "stdout": "HELLO WORLD\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 0, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 0, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 1, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 1, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 2, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 2, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 3, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 3, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 4, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 4, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 5, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 5, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 6, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 6, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 7, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 7, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n350\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 8, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n350\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 8, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n350\n400\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 9, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n350\n400\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 9, "x": 5, "z": 50, "y": 10}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n350\n400\n450\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"__return__": null, "i": 9, "z": 50, "y": 10, "x": 5}, "stdout": "HELLO WORLD\n0\n50\n100\n150\n200\n250\n300\n350\n400\n450\n", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "return"}]
/*
x = ('hello', 'world', 1, 2, 3, 'goodbye')
y = list(x)
z = set(x)
w = {"joe" : 5, "mindy" : 6, "jack" : 7}
*/
data_test_trace = [{"globals": {}, "stdout": "", "func_name": "<module>", "line": 1, "stack_locals": [], "event": "step_line"}, {"globals": {"x": ["TUPLE", "hello", "world", 1, 2, 3, "goodbye"]}, "stdout": "", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"y": ["LIST", "hello", "world", 1, 2, 3, "goodbye"], "x": ["TUPLE", "hello", "world", 1, 2, 3, "goodbye"]}, "stdout": "", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"y": ["LIST", "hello", "world", 1, 2, 3, "goodbye"], "x": ["TUPLE", "hello", "world", 1, 2, 3, "goodbye"], "z": ["SET", 1, 2, 3, "goodbye", "world", "hello"]}, "stdout": "", "func_name": "<module>", "line": 4, "stack_locals": [], "event": "step_line"}, {"globals": {"__return__": null, "x": ["TUPLE", "hello", "world", 1, 2, 3, "goodbye"], "z": ["SET", 1, 2, 3, "goodbye", "world", "hello"], "y": ["LIST", "hello", "world", 1, 2, 3, "goodbye"], "w": ["DICT", ["mindy", 6], ["joe", 5], ["jack", 7]]}, "stdout": "", "func_name": "<module>", "line": 4, "stack_locals": [], "event": "return"}]
/*
# should NOT allow for any imports
import os
os.system("echo security breach")
*/
import_error_trace = [{"globals": {}, "stdout": "", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {}, "stdout": "", "exception_msg": "ImportError: __import__ not found", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "exception"}]
/*
x = 0
for i in range(10):
x += 1
print x
x += 1
*/
parse_error_trace = [{"exception_msg": "unexpected indent", "line": 4, "event": "uncaught_exception", "offset": [3]}]
/*
x = 5
for i in range(10):
if i == x:
z = x + y # ERROR!
else:
z = i
print z
*/
runtime_error_trace = [{"globals": {}, "stdout": "", "func_name": "<module>", "line": 1, "stack_locals": [], "event": "step_line"}, {"globals": {"x": 5}, "stdout": "", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 0, "x": 5}, "stdout": "", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 0, "x": 5}, "stdout": "", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 0, "x": 5, "z": 0}, "stdout": "", "func_name": "<module>", "line": 7, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 0, "x": 5, "z": 0}, "stdout": "0\n", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 1, "x": 5, "z": 0}, "stdout": "0\n", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 1, "x": 5, "z": 0}, "stdout": "0\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 1, "x": 5, "z": 1}, "stdout": "0\n", "func_name": "<module>", "line": 7, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 1, "x": 5, "z": 1}, "stdout": "0\n1\n", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 2, "x": 5, "z": 1}, "stdout": "0\n1\n", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 2, "x": 5, "z": 1}, "stdout": "0\n1\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 2, "x": 5, "z": 2}, "stdout": "0\n1\n", "func_name": "<module>", "line": 7, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 2, "x": 5, "z": 2}, "stdout": "0\n1\n2\n", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 3, "x": 5, "z": 2}, "stdout": "0\n1\n2\n", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 3, "x": 5, "z": 2}, "stdout": "0\n1\n2\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 3, "x": 5, "z": 3}, "stdout": "0\n1\n2\n", "func_name": "<module>", "line": 7, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 3, "x": 5, "z": 3}, "stdout": "0\n1\n2\n3\n", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 4, "x": 5, "z": 3}, "stdout": "0\n1\n2\n3\n", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 4, "x": 5, "z": 3}, "stdout": "0\n1\n2\n3\n", "func_name": "<module>", "line": 6, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 4, "x": 5, "z": 4}, "stdout": "0\n1\n2\n3\n", "func_name": "<module>", "line": 7, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 4, "x": 5, "z": 4}, "stdout": "0\n1\n2\n3\n4\n", "func_name": "<module>", "line": 2, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 5, "x": 5, "z": 4}, "stdout": "0\n1\n2\n3\n4\n", "func_name": "<module>", "line": 3, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 5, "x": 5, "z": 4}, "stdout": "0\n1\n2\n3\n4\n", "func_name": "<module>", "line": 4, "stack_locals": [], "event": "step_line"}, {"globals": {"i": 5, "x": 5, "z": 4}, "stdout": "0\n1\n2\n3\n4\n", "exception_msg": "NameError: name 'y' is not defined", "func_name": "<module>", "line": 4, "stack_locals": [], "event": "exception"}]
/*
def add(a, b, c):
d = a + b
return c + d
def double_add(a, b, c):
x = add(a, b, c)
y = add(a, b, c)
return x + y
x = 5
y = 10
z = x * y
print add(x, y, z)
print double_add(x, y, z)
*/
two_funcs_trace = [{"globals": {}, "stdout": "", "func_name": "<module>", "line": 1, "stack_locals": [], "event": "step_line"}, {"globals": {"add": "<function>"}, "stdout": "", "func_name": "<module>", "line": 5, "stack_locals": [], "event": "step_line"}, {"globals": {"add": "<function>", "double_add": "<function>"}, "stdout": "", "func_name": "<module>", "line": 10, "stack_locals": [], "event": "step_line"}, {"globals": {"x": 5, "add": "<function>", "double_add": "<function>"}, "stdout": "", "func_name": "<module>", "line": 11, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "double_add": "<function>"}, "stdout": "", "func_name": "<module>", "line": 12, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "", "func_name": "<module>", "line": 13, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "", "func_name": "add", "line": 1, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10}]], "event": "call"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "", "func_name": "add", "line": 2, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "", "func_name": "add", "line": 3, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10, "d": 15}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "", "func_name": "add", "line": 3, "stack_locals": [["add", {"a": 5, "__return__": 65, "c": 50, "b": 10, "d": 15}]], "event": "return"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "<module>", "line": 14, "stack_locals": [], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "double_add", "line": 5, "stack_locals": [["double_add", {"a": 5, "c": 50, "b": 10}]], "event": "call"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "double_add", "line": 6, "stack_locals": [["double_add", {"a": 5, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 1, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10}], ["double_add", {"a": 5, "c": 50, "b": 10}]], "event": "call"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 2, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10}], ["double_add", {"a": 5, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 3, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10, "d": 15}], ["double_add", {"a": 5, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 3, "stack_locals": [["add", {"a": 5, "__return__": 65, "c": 50, "b": 10, "d": 15}], ["double_add", {"a": 5, "c": 50, "b": 10}]], "event": "return"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "double_add", "line": 7, "stack_locals": [["double_add", {"a": 5, "x": 65, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 1, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10}], ["double_add", {"a": 5, "x": 65, "c": 50, "b": 10}]], "event": "call"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 2, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10}], ["double_add", {"a": 5, "x": 65, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 3, "stack_locals": [["add", {"a": 5, "c": 50, "b": 10, "d": 15}], ["double_add", {"a": 5, "x": 65, "c": 50, "b": 10}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "add", "line": 3, "stack_locals": [["add", {"a": 5, "__return__": 65, "c": 50, "b": 10, "d": 15}], ["double_add", {"a": 5, "x": 65, "c": 50, "b": 10}]], "event": "return"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "double_add", "line": 8, "stack_locals": [["double_add", {"a": 5, "x": 65, "c": 50, "b": 10, "y": 65}]], "event": "step_line"}, {"globals": {"y": 10, "x": 5, "add": "<function>", "z": 50, "double_add": "<function>"}, "stdout": "65\n", "func_name": "double_add", "line": 8, "stack_locals": [["double_add", {"a": 5, "c": 50, "b": 10, "__return__": 130, "y": 65, "x": 65}]], "event": "return"}, {"globals": {"double_add": "<function>", "__return__": null, "add": "<function>", "y": 10, "x": 5, "z": 50}, "stdout": "65\n130\n", "func_name": "<module>", "line": 14, "stack_locals": [], "event": "return"}]
tmp_error_out = [{"exception_msg": "unindent does not match any outer indentation level", "line": 6, "event": "uncaught_exception", "offset": [11]}]