[pypy-svn] r50646 - in pypy/branch/clr-module-improvements/pypy/translator/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Tue Jan 15 19:11:39 CET 2008
Author: antocuni
Date: Tue Jan 15 19:11:39 2008
New Revision: 50646
Modified:
pypy/branch/clr-module-improvements/pypy/translator/cli/dotnet.py
pypy/branch/clr-module-improvements/pypy/translator/cli/test/test_dotnet.py
Log:
fix annotations of strings. Thanks cfbolz
Modified: pypy/branch/clr-module-improvements/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/translator/cli/dotnet.py (original)
+++ pypy/branch/clr-module-improvements/pypy/translator/cli/dotnet.py Tue Jan 15 19:11:39 2008
@@ -157,7 +157,7 @@
elif TYPE is ootype.Char:
return SomeChar()
elif TYPE is ootype.String:
- return SomeString()
+ return SomeString(can_be_None=True)
else:
return lltype_to_annotation(TYPE)
lltype_to_annotation = classmethod(lltype_to_annotation)
Modified: pypy/branch/clr-module-improvements/pypy/translator/cli/test/test_dotnet.py
==============================================================================
--- pypy/branch/clr-module-improvements/pypy/translator/cli/test/test_dotnet.py (original)
+++ pypy/branch/clr-module-improvements/pypy/translator/cli/test/test_dotnet.py Tue Jan 15 19:11:39 2008
@@ -12,6 +12,7 @@
System = CLR.System
Math = CLR.System.Math
ArrayList = CLR.System.Collections.ArrayList
+Type = CLR.System.Type
class TestDotnetAnnotation(object):
@@ -169,6 +170,15 @@
assert isinstance(s, annmodel.SomeInstance)
assert s.classdef.name.endswith('Foo')
+ def test_can_be_None(self):
+ def fn():
+ ttype = Type.GetType('foo')
+ return ttype.get_Namespace()
+ a = RPythonAnnotator()
+ s = a.build_types(fn, [])
+ assert isinstance(s, annmodel.SomeString)
+ assert s.can_be_None
+
class TestDotnetRtyping(CliTest):
def _skip_pythonnet(self, msg):
@@ -389,9 +399,27 @@
res = self.interpret(fn, [])
assert res is True
+ def test_compare_string_None(self):
+ from pypy.rlib.nonconst import NonConstant
+ def null():
+ if NonConstant(True):
+ return None
+ else:
+ return ""
+
+ def fn():
+ ttype = Type.GetType('Consts, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
+ namespace = ttype.get_Namespace()
+ if namespace is not None:
+ return False
+ else:
+ return True
+ res = self.interpret(fn, [], backendopt=False)
+ assert res is True
+
class TestPythonnet(TestDotnetRtyping):
# don't interpreter functions but execute them directly through pythonnet
- def interpret(self, f, args):
+ def interpret(self, f, args, backendopt='ignored'):
return f(*args)
def _skip_pythonnet(self, msg):
More information about the Pypy-commit
mailing list