Skip to content

Commit 19f32cb

Browse files
committed
vm: Tests for STORE_ATTR, LOAD_ATTR, DELETE_ATTR
1 parent d059504 commit 19f32cb

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

notes.txt

+19-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,29 @@ astyle --style=java --add-brackets < x.c > x.go
3333

3434
Roadmap
3535
=======
36-
* make pystone.py work
36+
* make pystone.py work - DONE
3737
* make enough of internals work so can run python tests
3838
* import python tests and write go test runner to run them
3939
* make lots of them pass
4040

41+
42+
Exceptions
43+
==========
44+
45+
Currently uses a panic/recover mechanism
46+
47+
Change to an error passing mechanism using go error type (so can use go vet etc to check)
48+
49+
panic/recover only within single modules (like compiler/parser)
50+
4151
Missing parts
4252
=============
4353
* repr/str
4454
* subclassing built in types
55+
* integers > 64 bit
56+
* make py.Int be a wrapper for int
57+
* make it promote to py.BigInt
58+
* StringDict vs Dict
4559

4660
Polymorphism
4761
============
@@ -170,7 +184,9 @@ Introspection idea
170184
Parser
171185
======
172186

173-
Use Python's Grammar file - converted into parser/grammar.y
187+
Used Python's Grammar file - converted into parser/grammar.y
188+
189+
Used go tool yacc and a hand built lexer in parser/lexer.go
174190

175-
Use go tool yacc and a hand built lexer in parser/lexer.go
191+
DONE
176192

vm/tests/attr.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3.4
2+
3+
class C:
4+
attr1 = 42
5+
def __init__(self):
6+
self.attr2 = 43
7+
self.attr3 = 44
8+
c = C()
9+
10+
# Test LOAD_ATTR
11+
assert c.attr1 == 42
12+
assert C.attr1 == 42
13+
assert c.attr2 == 43
14+
assert c.attr3 == 44
15+
16+
# Test DELETE_ATTR
17+
del c.attr3
18+
19+
# FIXME - exception handling broken
20+
# ok = False
21+
# try:
22+
# c.attr3
23+
# except AttributeError:
24+
# ok = True
25+
# assert ok
26+
27+
# Test STORE_ATTR
28+
c.attr1 = 100
29+
c.attr2 = 101
30+
c.attr3 = 102
31+
assert c.attr1 == 100
32+
assert C.attr1 == 42
33+
assert c.attr2 == 101
34+
assert c.attr3 == 102
35+
36+
# End with this
37+
finished = True

0 commit comments

Comments
 (0)