Commits

Armin Rigo committed f40a57d

Improve tests to check a non-final build() call

  • Participants
  • Parent commits 2ff5087
  • Branches stringbuilder-perf

Comments (0)

Files changed (2)

File rpython/translator/c/test/test_newgc.py

 
     def definestr_string_builder_multiple_builds(cls):
         def fn(_):
+            s = StringBuilder(4)
+            got = []
+            for i in range(50):
+                s.append(chr(33+i))
+                got.append(s.build())
+                gc.collect()
+            return ' '.join(got)
+        return fn
+
+    def test_string_builder_multiple_builds(self):
+        res = self.run('string_builder_multiple_builds')
+        assert res == ' '.join([''.join(map(chr, range(33, 33+length)))
+                                for length in range(1, 51)])
+
+    def definestr_string_builder_multiple_builds_2(cls):
+        def fn(_):
             got = []
             for j in range(3, 76, 5):
                 s = StringBuilder()
             return ' '.join(got)
         return fn
 
-    def test_string_builder_multiple_builds(self):
-        res = self.run('string_builder_multiple_builds')
+    def test_string_builder_multiple_builds_2(self):
+        res = self.run('string_builder_multiple_builds_2')
         assert res == ' '.join([''.join(map(chr, range(33, 33+length)))
                                 for length in range(3, 76, 5)])
 

File rpython/translator/c/test/test_standalone.py

 
         self.compile(entry_point)
         # assert did not explode
-    
+
     def test_unicode_builder(self):
         import random
         from rpython.rlib.rstring import UnicodeBuilder
         for x in to_do:
             if x < 1500:
                 expected.append("``%s''" % (s,))
-                s = ''
+                if x < 1000:
+                    s = ''
             elif x < 20000:
                 s += chr(32 + (x & 63))
             elif x < 30000:
             for x in to_do:
                 if x < 1500:
                     print "``%s''" % str(b.build())
-                    b = UnicodeBuilder(32)
+                    if x < 1000:
+                        b = UnicodeBuilder(32)
                 elif x < 20000:
                     b.append(unichr(32 + (x & 63)))
                 elif x < 30000: