Skip to content

Commit 8d442b8

Browse files
committed
Resolve #1. Basic spec engine for lambda calc interpreters.
1 parent fcbf23c commit 8d442b8

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

Diff for: specs.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"version": 0,
4+
"specs": [
5+
{
6+
"expect": "\\x.x",
7+
"toEvaluateTo": "\\x.x",
8+
"because": "trivial lambdas evaluate to themselves"
9+
}
10+
]
11+
}
12+
]

Diff for: test.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
3+
from sys import argv
4+
5+
import json
6+
import os
7+
import os.path
8+
9+
if len(argv) < 2:
10+
print "Usage: ./test.sh path/to/details.json"
11+
exit()
12+
13+
details_file = argv[1]
14+
15+
with open(details_file, 'r') as f:
16+
json_details = json.loads(f.read())
17+
18+
with open('specs.json', 'r') as f:
19+
specs = json.loads(f.read())[json_details['specVersion']]['specs']
20+
21+
main_file = os.path.join(os.path.dirname(details_file), json_details['main'])
22+
exe = json_details['exe']
23+
24+
os.chdir(os.path.dirname(main_file))
25+
26+
for spec in specs:
27+
file = os.path.basename(main_file)
28+
result = os.popen(exe + ' ' + file + ' "' + spec['expect'] + '"').read().strip()
29+
30+
if result != spec['toEvaluateTo']:
31+
print "Fail: ", result, '!=', spec['toEvaluateTo'], '(' + spec['because'] + ')'

0 commit comments

Comments
 (0)