Commit 6a83fd81 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Test cleanup: enable a bunch of close-to-succeeding tests

Many of them originally failed due to a missing language feature,
but now were failing due to simple reasons like printing out the repr
of an object which doesn't define __repr__ and getting something like
"<C object at 0x1234567890>" (ie nondeterministic).
parent dc9d0adc
......@@ -688,7 +688,8 @@ void checkAndThrowCAPIException() {
assert(!cur_thread_state.curexc_value);
if (_type) {
RELEASE_ASSERT(cur_thread_state.curexc_traceback == NULL, "unsupported");
RELEASE_ASSERT(cur_thread_state.curexc_traceback == NULL || cur_thread_state.curexc_traceback == None,
"unsupported");
BoxedClass* type = static_cast<BoxedClass*>(_type);
assert(isInstance(_type, type_cls) && isSubclass(static_cast<BoxedClass*>(type), BaseException)
&& "Only support throwing subclass of BaseException for now");
......@@ -902,7 +903,8 @@ extern "C" PyObject* PyNumber_Add(PyObject* lhs, PyObject* rhs) noexcept {
try {
return binop(lhs, rhs, AST_TYPE::Add);
} catch (ExcInfo e) {
Py_FatalError("unimplemented");
setCAPIException(e);
return NULL;
}
}
......
# expected: fail
# - metaclasses
# - object.__getattribute__ doesn't exist
# attr-getting resolution.
......
# expected: fail
# - lambdas, varargs
# Testing im-boxing:
class C(object):
def __repr__(self):
return "<C>"
def __call__(*args):
print args
return args
def mul(*args):
return args
class C1(object):
def __repr__(self):
return "<C1>"
__add__ = C()
__sub__ = lambda *args: args
__mul__ = mul
......
# expected: fail
# - arbitrary stuff in classdefs
# objmodel classattrs (like __add__) can be non-functions, so might not get bound into instancemethods:
class Adder(object):
......@@ -10,6 +7,8 @@ class Adder(object):
class C(object):
__add__ = Adder()
def __repr__(self):
return "<C>"
c = C()
print c + c
# expected: fail
# - inheritance not implemented
class C(object):
x = 1
......@@ -13,4 +10,5 @@ print d.x
# But also when doing instance-level lookups!
print D.x
print D.__dict__
print 'x' in C.__dict__
print 'x' in D.__dict__
# expected: fail
# - descriptors not implemented yet
# Make sure that we guard in a getattr IC to make sure that
# we don't subsequently get an object with a __get__ defined.
class D(object):
pass
def __repr__(self):
return "<D>"
class C(object):
def __repr__(self):
return "<C>"
d = D()
c = C()
......
# expected: fail
# - descriptors not implemented yet
def f1():
class D(object):
def __get__(self, instance, owner):
......@@ -13,6 +10,9 @@ def f1():
class C(object):
d = D()
def __repr__(self):
return "<C>"
print C.d
print C().d
......@@ -33,9 +33,15 @@ def f2():
print "__getattribute__", attr
return 1
def __repr__(self):
return "<MaybeDescriptor>"
class HasDescriptor(object):
x = MaybeDescriptor()
def __repr__(self):
return "<HasDescriptor>"
hd = HasDescriptor()
# Getting hd.x will look up type(hd.__dict__[x]).__get__
# and not go through __getattribute__
......
# expected: fail
# - inheritance
# - exception printing
class BadException(Exception):
def __str__(self):
......
# expected: fail
# execfile() not implemented yet
# - we throw some very weird error here
try:
execfile("doesnt_exist.py")
......
# expected: fail
# This test case currently fails because it prints the relative path to the .so
# module rather than the absolute path.
import basic_test
print basic_test
print type(basic_test)
# TODO this should work even if we don't keep a reference to l;
# it doesn't currently always work, but it sometimes works, so it's hard
......
# expected: fail
# - need to support closures
# - long % int
import sys
......
# expected: fail
# - setattr() not supported
# - memory explosion
class C(object):
pass
......
# expected: fail
# - not implemented yet
class CallableNew(object):
def __call__(self, cls, arg):
print "new", cls, arg
......@@ -9,6 +6,8 @@ class CallableInit(object):
def __call__(self, arg):
print "init", arg
class C(object):
def __repr__(self):
return "<C>"
def __getattribute__(self, name):
# This shouldn't get called
print "__getattribute__", name
......
# expected: fail
# setattr() not implemented
class C(object):
def print_none(self):
print None
c = C()
c.print_none()
# Can't do this:
# c.None = 1
setattr(C, "None", 1)
print dir(C)
print C.None # prints None!
c.print_none() # prints None!
# - not implemented yet
import sys
m = sys.modules["__main__"]
......
# allow-warning: converting unicode literal to str
# expected: fail
# - too slow
# - prints out poorly since we return an "attrwrapper" instead of a real dict
# Simple opt parse test, taken from the optparse.py docstring:
# Simple optparse test, taken from the optparse.py docstring:
from optparse import OptionParser
......@@ -16,4 +11,4 @@ parser.add_option("-q", "--quiet",
help="don't print status messages to stdout")
(options, args) = parser.parse_args(['test', '--file=/dev/null', 'hello world'])
print options, args
print sorted(options.__dict__.items()), args
# expected: fail
# - Relative imports not supported
# - crashes rather than throws an error
try:
from . import doesnt_exist
......
......@@ -6,6 +6,12 @@ print reduce(operator.add, "hello world")
print reduce(operator.add, "", 0)
try:
print reduce(operator.add, "hello world", 0)
except TypeError, e:
print e
def f(a, b):
print "f", a, b
return b
......
# expected: fail
# - can't pass exceptions through C API yet
# (TODO fold this into reduce.py once it works)
import operator
try:
print reduce(operator.add, "hello world", 0)
except TypeError, e:
print e
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