[pypy-svn] r39199 - pypy/dist/pypy/lang/js/test/ecma

santagada at codespeak.net santagada at codespeak.net
Mon Feb 19 12:28:42 CET 2007


Author: santagada
Date: Mon Feb 19 12:28:41 2007
New Revision: 39199

Modified:
   pypy/dist/pypy/lang/js/test/ecma/conftest.py
   pypy/dist/pypy/lang/js/test/ecma/shell.js
Log:
tests running


Modified: pypy/dist/pypy/lang/js/test/ecma/conftest.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/ecma/conftest.py	(original)
+++ pypy/dist/pypy/lang/js/test/ecma/conftest.py	Mon Feb 19 12:28:41 2007
@@ -33,10 +33,10 @@
         t.execute(ctx)
     init_interp = classmethod(init_interp)
     
-    def __init__(self, filepath, parent=None):
-        super(JSTestFile, self).__init__(filepath, parent)
-        self.name = filepath.purebasename + " JSFILE"
-        self.filepath = filepath
+    def __init__(self, fspath, parent=None):
+        super(JSTestFile, self).__init__(fspath, parent)
+        self.name = fspath.purebasename + " JSFILE"
+        self.fspath = fspath
     
     def run(self):
         if not py.test.config.option.ecma:
@@ -45,34 +45,40 @@
             return
         self.init_interp()
         #actually run the file :)
-        t = load_source(self.filepath.read())
+        t = load_source(self.fspath.read())
         try:
             t.execute(self.interp.global_context)
         except (JsBaseExcept, JsSyntaxError):
             raise Failed(excinfo=py.code.ExceptionInfo())
         testcases = self.interp.global_context.resolve_identifier('testcases')
         values = testcases.GetValue().array
-        testcases.PutValue(W_Array(), self.interp.global_context)
-        return values
+        self.testcases = testcases
+        result = [str(i) for i in range(len(values))]
+        return result
 
     def join(self, name):
         return JSTestItem(name, parent = self)
 
-class JSTestItem(py.test.collect.Function):        
+    def teardown(self):
+        self.testcases.PutValue(W_Array(), self.interp.global_context)
+
+class JSTestItem(py.test.collect.Item):        
     def __init__(self, name, parent=None):
         super(JSTestItem, self).__init__(name, parent)
         self.name = name
-    
-    def startcapture(self): pass
-    def stopcapture(self): pass
-    
-    def run():
+        
+    def run(self):
         ctx = JSTestFile.interp.global_context
         r3 = ctx.resolve_identifier('run_test').GetValue()
-        result = r3.Call(ctx=ctx, args=[name,]).ToNumber()
+        result = r3.Call(ctx=ctx, args=[W_Number(int(self.name)),]).ToNumber()
         if result == 0:
             py.test.fail()
         elif result == -1:
             py.test.skip()
 
+    _handling_traceback = False
+    def _getpathlineno(self):
+        return self.parent.parent.fspath, 0 
+
+
 Directory = JSDirectory

Modified: pypy/dist/pypy/lang/js/test/ecma/shell.js
==============================================================================
--- pypy/dist/pypy/lang/js/test/ecma/shell.js	(original)
+++ pypy/dist/pypy/lang/js/test/ecma/shell.js	Mon Feb 19 12:28:41 2007
@@ -193,17 +193,18 @@
  * document.write.
  */
 
-function run_test(testnr) {
-     try
-     {
+function run_test(tc) {
+     // try
+     // {
+    print(tc)
      getTestCaseResult(testcases[tc].expect, testcases[tc].actual)
      testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
      return testcases[tc].passed? 1:0;
-     }
-     catch(e)
-     {
-        return -1
-     }
+     // }
+     // catch(e)
+     // {
+     //    return -1
+     // }
 }
 function writeTestCaseResult( expect, actual, string ) {
   var passed = getTestCaseResult( expect, actual );



More information about the Pypy-commit mailing list