Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r70971:6e240b6b7d94 Date: 2014-04-25 11:11 +0200 http://bitbucket.org/pypy/pypy/changeset/6e240b6b7d94/
Log: Check that string interpolation works, and is contant-folded if all arguments are constant. diff --git a/rpython/jit/metainterp/test/test_string.py b/rpython/jit/metainterp/test/test_string.py --- a/rpython/jit/metainterp/test/test_string.py +++ b/rpython/jit/metainterp/test/test_string.py @@ -654,3 +654,23 @@ self.check_resops(call_pure=0, unicodesetitem=0, call=2, newunicode=0, unicodegetitem=0, copyunicodecontent=0) + + def test_string_interpolation(self): + def f(x, y): + return len('<%d %d>' % (x, y)) + res = self.interp_operations(f, [222, 3333]) + assert res == 10 + + def test_string_interpolation_constants(self): + jitdriver = JitDriver(greens=['x', 'y'], reds=['z']) + def f(x, y): + z = 0 + while z < 10: + jitdriver.jit_merge_point(x=x, y=y, z=z) + if len('<%d %d>' % (x, y)) != 10: + raise Exception + z += 1 + return 0 + self.meta_interp(f, [222, 3333]) + self.check_simple_loop({'guard_true': 1, 'int_add': 1, + 'int_lt': 1, 'jump': 1}) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit