[pypy-svn] r15373 - in pypy/dist/pypy/translator/llvm2: module test

ericvrp at codespeak.net ericvrp at codespeak.net
Fri Jul 29 21:05:56 CEST 2005


Author: ericvrp
Date: Fri Jul 29 21:05:55 2005
New Revision: 15373

Modified:
   pypy/dist/pypy/translator/llvm2/module/ll_os.py
   pypy/dist/pypy/translator/llvm2/test/test_extfunc.py
Log:
added os.isatty


Modified: pypy/dist/pypy/translator/llvm2/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/module/ll_os.py	(original)
+++ pypy/dist/pypy/translator/llvm2/module/ll_os.py	Fri Jul 29 21:05:55 2005
@@ -6,6 +6,7 @@
 declare int %write(int, sbyte*, int)
 declare int %read(int, sbyte*, int)
 declare sbyte* %strncpy(sbyte*, sbyte*, int)
+declare int %isatty(int)
 """
 
 extfunctions = {}
@@ -59,3 +60,14 @@
 }
 
 """)
+
+extfunctions["%ll_os_isatty"] = ((), """
+bool %ll_os_isatty(int %fd) {
+    %ret = call int %isatty(int %fd)
+    %ret.bool = cast int %ret to bool
+    ret bool %ret.bool
+}
+
+""")
+
+

Modified: pypy/dist/pypy/translator/llvm2/test/test_extfunc.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_extfunc.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_extfunc.py	Fri Jul 29 21:05:55 2005
@@ -189,4 +189,12 @@
     f = compile_function(fn, [])
     assert f() == False
 
+def test_os_isatty():
+    def call_isatty(fd):
+        return os.isatty(fd)
+    f = compile_function(call_isatty, [int])
+    assert f(0) == os.isatty(0)
+    assert f(1) == os.isatty(1)
+    assert f(2) == os.isatty(2)
+
 # end of tests taken from c backend



More information about the Pypy-commit mailing list