-
Notifications
You must be signed in to change notification settings - Fork 15
/
tests.txt
206 lines (186 loc) Β· 6.64 KB
/
tests.txt
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Don't know how to test multiline error output... the error here is obsolete
#friendly-error-with-no-setup
# extensions [ py ]
# O> py:run "foo" => ERROR Extension exception: Python process has not been started. Please run PY:SETUP before any other python #extension primitive.
#nonexistent-python
# extensions [ py ]
# O> py:setup "foobarbaz" => ERROR Extension exception: Couldn't find Python executable: foobarbaz
# open-connection-python2
# extensions [ py ]
# O> py:setup py:python2
# O> py:run "print('python hi1!')"
# O> py:run "print('python hi2!')"
#
# python2-gets-python-2
# extensions [ py ]
# O> py:setup py:python2
# O> py:run "import sys"
# py:runresult "sys.version_info[0]" => 2
#
# basic-python-types-convert-python2
# extensions [ py ]
# O> py:setup py:python2
# py:runresult "1" => 1
# py:runresult "'hi'" => "hi"
# py:runresult "True" => true
# py:runresult "False" => false
# py:runresult "[1, 'hi', [2, 'bye']]" => [1 "hi" [2 "bye"]]
#
# basic-netlogo-types-convert-python2
# extensions [ py ]
# O> py:setup py:python2
# O> py:set "num" 1
# O> py:set "string" "hi"
# O> py:set "lst" [1 "hi" [2 "bye"]]
# O> py:set "b" true
# py:runresult "num" => 1
# py:runresult "string" => "hi"
# py:runresult "lst" => [1 "hi" [2 "bye"]]
# py:runresult "b" => true
#
# error-handling-python2
# extensions [ py ]
# O> py:setup py:python2
# O> py:run "raise Exception('hi')" => ERROR Extension exception: hi
# py:runresult "1 / 0" => ERROR Extension exception: integer division or modulo by zero
#
# dicts-convert-to-lists-python2
# extensions [ py ]
# O> py:setup py:python2
# py:runresult "{'a': 1}" => [["a" 1]]
#
# sets-convert-to-lists-python2
# extensions [ py ]
# O> py:setup py:python2
# py:runresult "{1, 1}" => [1]
#
# np-array-convert-to-lists-python2
# extensions [ py ]
# O> py:setup py:python2
# O> py:run "import numpy as np"
# py:runresult "np.array([1,2,3])" => [1 2 3]
#
# supports-utf8-python2
# extensions [ py ]
# O> py:setup py:python2
# py:runresult "'π'" => "π"
#
# errors-on-nan-python2
# extensions [ py ]
# O> py:setup py:python2
# py:runresult "float('nan')" => ERROR Extension exception: Python reported a non-numeric value from a mathematical operation.
#
# errors-on-infinity-python2
# extensions [ py ]
# O> py:setup py:python2
# py:runresult "float('inf')" => ERROR Extension exception: Python reported a number too large for NetLogo.
open-connection-python3
extensions [ py ]
O> py:setup py:python3
python3-gets-python-3
extensions [ py ]
O> py:setup py:python3
O> py:run "import sys"
py:runresult "sys.version_info[0]" => 3
basic-python-types-convert-python3
extensions [ py ]
O> py:setup py:python3
py:runresult "1" => 1
py:runresult "'hi'" => "hi"
py:runresult "True" => true
py:runresult "False" => false
py:runresult "[1, 'hi', [2, 'bye']]" => [1 "hi" [2 "bye"]]
basic-netlogo-types-convert-python3
extensions [ py ]
O> py:setup py:python3
O> py:set "num" 1
O> py:set "string" "hi"
O> py:set "lst" [1 "hi" [2 "bye"]]
O> py:set "b" true
py:runresult "num" => 1
py:runresult "string" => "hi"
py:runresult "lst" => [1 "hi" [2 "bye"]]
py:runresult "b" => true
error-handling-python3
extensions [ py ]
O> py:setup py:python3
O> py:run "raise Exception('hi')" => ERROR Extension exception: hi
py:runresult "1 / 0" => ERROR Extension exception: division by zero
multiline-python3
extensions [ py ]
O> py:setup py:python3
O> (py:run "x = 0" "for i in range(11):" " x += i" "x += 45")
py:runresult "x" => 100
# We were running into https://stackoverflow.com/questions/45132645/list-comprehension-in-exec-with-empty-locals-nameerror
comprehensions-see-variables-python3
extensions [ py ]
O> py:setup py:python3
O> (py:run "x = 2" "y = [i ** x for i in range(5)]")
py:runresult "y" => [0 1 4 9 16]
dicts-convert-to-lists-python3
extensions [ py ]
O> py:setup py:python3
py:runresult "{'a': 1}" => [["a" 1]]
sets-convert-to-lists-python3
extensions [ py ]
O> py:setup py:python3
py:runresult "{1, 1}" => [1]
np-array-convert-to-lists-python3
extensions [ py ]
O> py:setup py:python3
O> py:run "import numpy as np"
py:runresult "np.array([1,2,3])" => [1 2 3]
send-receive-big-python3
extensions [ py ]
O> py:setup py:python3
O> py:set "foo" range 100000
length py:runresult "foo" => 100000
setup-takes-arguments-python3
extensions [ py ]
O> (py:setup py:python3 "-O")
py:runresult "0" => 0
supports-utf8-python3
extensions [ py ]
O> py:setup py:python3
py:runresult "'π'" => "π"
python-prefers-3
extensions [ py ]
O> py:setup py:python
O> py:run "import sys"
py:runresult "sys.version_info[0]" => 3
errors-on-nan-python3
extensions [ py ]
O> py:setup py:python3
py:runresult "float('nan')" => ERROR Extension exception: Python reported a non-numeric value from a mathematical operation.
errors-on-infinity-python3
extensions [ py ]
O> py:setup py:python3
py:runresult "float('inf')" => ERROR Extension exception: Python reported a number too large for NetLogo.
turtle-serialization
extensions [ py ]
breed [goats goat]
goats-own [energy agent-var agentset-var ]
O> py:setup py:python3
O> create-goats 1 [ set heading 0 set color 75 ]
O> ask goat 0 [ set energy 42 ]
O> py:set "goat" goat 0
py:runresult "str(goat)" => "{'WHO': 0, 'COLOR': 75, 'HEADING': 0, 'XCOR': 0, 'YCOR': 0, 'SHAPE': 'default', 'LABEL': '', 'LABEL-COLOR': 9.9, 'BREED': 'GOATS', 'HIDDEN?': False, 'SIZE': 1, 'PEN-SIZE': 1, 'PEN-MODE': 'up', 'ENERGY': 42, 'AGENT-VAR': 0, 'AGENTSET-VAR': 0}"
turtle-re-serialization
extensions [ py ]
breed [goats goat]
goats-own [energy agent-var agentset-var ]
O> py:setup py:python3
O> create-goats 1 [ set heading 0 set color 75 ]
O> ask goat 0 [ set energy 42 ]
O> py:set "goat" goat 0
py:runresult "goat" => [["WHO" 0] ["COLOR" 75] ["HEADING" 0] ["XCOR" 0] ["YCOR" 0] ["SHAPE" "default"] ["LABEL" ""] ["LABEL-COLOR" 9.9] ["BREED" "GOATS"] ["HIDDEN?" false] ["SIZE" 1] ["PEN-SIZE" 1] ["PEN-MODE" "up"] ["ENERGY" 42] ["AGENT-VAR" 0] ["AGENTSET-VAR" 0]]
turtle-re-serialization-agent-and-agentset-variables
extensions [ py ]
breed [goats goat]
goats-own [energy agent-var agentset-var ]
O> py:setup py:python3
O> create-goats 2 [ set heading 0 set color 75 ]
O> ask goat 0 [ set agent-var goat 1 ]
O> ask goat 0 [ set agentset-var goats ]
O> py:set "goat" goat 0
py:runresult "goat" => [["WHO" 0] ["COLOR" 75] ["HEADING" 0] ["XCOR" 0] ["YCOR" 0] ["SHAPE" "default"] ["LABEL" ""] ["LABEL-COLOR" 9.9] ["BREED" "GOATS"] ["HIDDEN?" false] ["SIZE" 1] ["PEN-SIZE" 1] ["PEN-MODE" "up"] ["ENERGY" 0] ["AGENT-VAR" "goat 1"] ["AGENTSET-VAR" "GOATS"]]