-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_op_collections.py
39 lines (35 loc) · 1.13 KB
/
test_op_collections.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
"""Tests of collections operators for stilted."""
import pytest
from error import StiltedError
from evaluate import evaluate
@pytest.mark.parametrize(
"text, error",
[
# get
("get", "stackunderflow"),
("/foo get", "stackunderflow"),
("123 /foo get", "typecheck"),
# getinterval
("getinterval", "stackunderflow"),
("1 getinterval", "stackunderflow"),
("1 2 getinterval", "stackunderflow"),
("3.1415 1 2 getinterval", "typecheck"),
# length
("length", "stackunderflow"),
("213 length", "typecheck"),
# put
("put", "stackunderflow"),
("12 put", "stackunderflow"),
("/foo 12 put", "stackunderflow"),
("123 /foo 12 put", "typecheck"),
# putinterval
("putinterval", "stackunderflow"),
("12 putinterval", "stackunderflow"),
("/foo 12 putinterval", "stackunderflow"),
("123 /foo 12 putinterval", "typecheck"),
("123 12 /foo putinterval", "typecheck"),
],
)
def test_evaluate_error(text, error):
with pytest.raises(StiltedError, match=error):
evaluate(text)