Commit e69a1fa5 authored by Stefan Behnel's avatar Stefan Behnel

make an old test from 'broken' directory usable

parent 53595204
# mode: run
cdef class Spam:
cdef int tons
......@@ -13,14 +14,16 @@ cdef class Spam:
def lift(self):
print self.tons
cdef class SubSpam(Spam):
cdef void add_tons(self, int x):
self.tons += 2 * x
def test():
def test_spam():
"""
>>> test()
>>> test_spam()
5
0
20
......@@ -41,3 +44,39 @@ def test():
ss.lift()
s.lift()
cdef class SpamDish:
cdef int spam
cdef void describe(self):
print "This dish contains", self.spam, "tons of spam."
cdef class FancySpamDish(SpamDish):
cdef int lettuce
cdef void describe(self):
print "This dish contains", self.spam, "tons of spam",
print "and", self.lettuce, "milligrams of lettuce."
cdef void describe_dish(SpamDish d):
d.describe()
def test_spam_dish():
"""
>>> test_spam_dish()
This dish contains 42 tons of spam.
This dish contains 88 tons of spam and 5 milligrams of lettuce.
"""
cdef SpamDish s
cdef FancySpamDish ss
s = SpamDish()
s.spam = 42
ss = FancySpamDish()
ss.spam = 88
ss.lettuce = 5
describe_dish(s)
describe_dish(ss)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment