[pypy-svn] r69137 - pypy/branch/avm/pypy/translator/avm2/test

magcius at codespeak.net magcius at codespeak.net
Wed Nov 11 00:55:37 CET 2009


Author: magcius
Date: Wed Nov 11 00:55:36 2009
New Revision: 69137

Modified:
   pypy/branch/avm/pypy/translator/avm2/test/harness.py
   pypy/branch/avm/pypy/translator/avm2/test/runtest.py
   pypy/branch/avm/pypy/translator/avm2/test/test.abc
   pypy/branch/avm/pypy/translator/avm2/test/test.swf
   pypy/branch/avm/pypy/translator/avm2/test/test_runtest.py
Log:
Some tests run, for a very limited definition of 'some'.

Modified: pypy/branch/avm/pypy/translator/avm2/test/harness.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm2/test/harness.py	(original)
+++ pypy/branch/avm/pypy/translator/avm2/test/harness.py	Wed Nov 11 00:55:36 2009
@@ -2,7 +2,7 @@
 import py
 from pypy.translator.avm1 import swf as s, tags as t, records as r
 from pypy.translator.avm2.test import browsertest as b
-from pypy.translator.avm2 import avm2gen as g, constants as c, abc_ as a
+from pypy.translator.avm2 import avm2gen as g, constants as c, abc_ as a, traits
 
 fl_dis_ns = c.Namespace("flash.display", c.TYPE_NAMESPACE_PackageNamespace)
 
@@ -10,21 +10,14 @@
     def __init__(self, name, gen):
         self.testname  = name
         self.swf = s.SwfData()
+        self.swf.add_tag(t.FileAttributes())
         self.swf.add_tag(t.SetBackgroundColor(0x333333))
-        self.swf.add_tag(t.DefineEditText(r.Rect(0, 0, 0, 0), "",
+        self.swf.add_tag(t.DefineEditText(r.Rect(0, 600, 0, 400), "tt",
                                           "Testing %s." % (name,), color=r.RGBA(0xFFFFFF)))
         self.swf.add_tag(t.PlaceObject2(1, 2, name="edittext"))
         self.abc = t.DoABC()
         self.actions = g.Avm2ilasm(gen.db, self.abc)
         
-        self.maincls = self.actions.begin_class(c.QName("PyPyTest_EntryPoint"), c.packagedQName("flash.display", "Sprite"), [
-                  c.packagedQName("flash.display", "Sprite"),
-                  c.packagedQName("flash.display", "DisplayObjectContainer"),
-                  c.packagedQName("flash.display", "InteractiveObject"),
-                  c.packagedQName("flash.display", "DisplayObject"),
-                  c.packagedQName("flash.events", "EventDispatcher"),
-                  c.QName("Object"),
-                ])
         self.swf.add_tag(self.abc)
         self.swf.add_tag(t.SymbolClass({0:"PyPyTest_EntryPoint"}))
         self.swf.add_tag(t.ShowFrame())
@@ -35,8 +28,7 @@
             return self.actions.push_var('edittext')
         
         self.actions.push_this()
-        self.actions.push_const('edittext')
-        self.actions.emit('callproperty', c.Multiname("getChildByName", c.PROP_NAMESPACE_SET), 1)
+        self.actions.emit('getlex', c.QName("edittext"))
         self.actions.store_var('edittext')
 
     def update_text(self):
@@ -70,8 +62,17 @@
         self.actions.store_var('text')
     
     def start_test(self):
+        self.maincls = self.actions.begin_class(c.QName("PyPyTest_EntryPoint"), c.packagedQName("flash.display", "Sprite"), [
+                  c.packagedQName("flash.display", "Sprite"),
+                  c.packagedQName("flash.display", "DisplayObjectContainer"),
+                  c.packagedQName("flash.display", "InteractiveObject"),
+                  c.packagedQName("flash.display", "DisplayObject"),
+                  c.packagedQName("flash.events", "EventDispatcher"),
+                  c.QName("Object"),
+                ])
         self.maincls.make_iinit()
         self.get_edittext()
+        self.maincls.add_instance_trait(traits.AbcSlotTrait(c.QName('edittext'), c.packagedQName("flash.text", "TextField")))
         self.actions.push_var('edittext')
         self.actions.emit('getproperty', c.QName('text'))
         self.actions.store_var('text')
@@ -90,7 +91,7 @@
         self.actions.emit('setproperty', c.QName("method"))
         self.actions.push_var('request')
         self.actions.emit('findpropstrict', c.packagedQName("flash.net", "URLVariables"))
-        self.actions.emit('constructprop', c.packagedQName("flash.net", "URLVariables"), 1)
+        self.actions.emit('constructprop', c.packagedQName("flash.net", "URLVariables"), 0)
         self.actions.emit('setproperty', c.QName("data"))
         self.actions.push_var('request')
         self.actions.emit('getproperty', c.QName("data"))
@@ -110,5 +111,5 @@
             f = open("test.abc", "w")
             f.write(a.AbcFile.serialize(self.abc))
             f.close()
-        py.test.fail("debug")
-        #return b.browsertest(self.testname, self.swf)
+        #py.test.fail("debug")
+        return b.browsertest(self.testname, self.swf)

Modified: pypy/branch/avm/pypy/translator/avm2/test/runtest.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm2/test/runtest.py	(original)
+++ pypy/branch/avm/pypy/translator/avm2/test/runtest.py	Wed Nov 11 00:55:36 2009
@@ -20,19 +20,18 @@
 #         gen.call_method("fromCharCode")
 
 def compile_function(func, name, annotation=[], graph=None, backendopt=True,
-                     auto_raise_exc=False, exctrans=False,
-                     annotatorpolicy=None, nowrap=False):
+                     exctrans=False, annotatorpolicy=None):
     olddefs = patch_os()
-    gen = _build_gen(func, annotation, name, graph, backendopt,
-                     exctrans, annotatorpolicy, nowrap)
+    gen = _build_gen(func, annotation,graph, backendopt,
+                     exctrans, annotatorpolicy)
     harness = TestHarness(name, gen)
     gen.ilasm = harness.actions
     gen.generate_source()
     unpatch_os(olddefs) # restore original values
     return gen, harness
 
-def _build_gen(func, annotation, name, graph=None, backendopt=True, exctrans=False,
-               annotatorpolicy=None, nowrap=False):
+def _build_gen(func, annotation, graph=None, backendopt=True, exctrans=False,
+               annotatorpolicy=None):
     try: 
         func = func.im_func
     except AttributeError: 
@@ -69,14 +68,13 @@
         self._genoo = None
         self._harness = None
 
-    def _compile(self, fn, args, ann=None, backendopt=True, auto_raise_exc=False, exctrans=False):
+    def _compile(self, fn, args, ann=None, backendopt=True, exctrans=False):
         if ann is None:
             ann = [lltype_to_annotation(typeOf(x)) for x in args]
         self._genoo, self._harness = compile_function(fn,
                                                       "%s.%s" % (self.__class__.__name__, fn.func_name),
                                                       ann,
                                                       backendopt=backendopt,
-                                                      auto_raise_exc=auto_raise_exc,
                                                       exctrans=exctrans)
         self._func = fn
         self._ann = ann
@@ -141,3 +139,14 @@
 
     def read_attr(self, obj, name):
         py.test.skip('read_attr not supported on gencli tests')
+
+class InstanceWrapper:
+    def __init__(self, class_name):
+        self.class_name = class_name
+
+class ExceptionWrapper:
+    def __init__(self, class_name):
+        self.class_name = class_name
+
+    def __repr__(self):
+        return 'ExceptionWrapper(%s)' % repr(self.class_name)

Modified: pypy/branch/avm/pypy/translator/avm2/test/test.abc
==============================================================================
Binary files. No diff available.

Modified: pypy/branch/avm/pypy/translator/avm2/test/test.swf
==============================================================================
Binary files. No diff available.

Modified: pypy/branch/avm/pypy/translator/avm2/test/test_runtest.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm2/test/test_runtest.py	(original)
+++ pypy/branch/avm/pypy/translator/avm2/test/test_runtest.py	Wed Nov 11 00:55:36 2009
@@ -4,13 +4,7 @@
 from pypy.translator.avm2.test.runtest import AVM2Test
 
 class TestRunTest(BaseTestRunTest, AVM2Test):
-
-    def test_auto_raise_exc(self):
-        def fn():
-            raise ValueError
-        f = self._compile(fn, [], auto_raise_exc=True)
-        py.test.raises(ValueError, f)
-
+    
     def test_big_arglist(self):
         def fn(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9):
             return a0



More information about the Pypy-commit mailing list