From: <fwi...@us...> - 2008-12-17 03:57:00
|
Revision: 5771 http://jython.svn.sourceforge.net/jython/?rev=5771&view=rev Author: fwierzbicki Date: 2008-12-17 03:56:56 +0000 (Wed, 17 Dec 2008) Log Message: ----------- On the advice of the original poster of http://bugs.jython.org/issue1205 known to us only as pb, switching the test cases to the more poetic computation of the Hardy-Ramanujan number http://en.wikipedia.org/wiki/1729_(number). Modified Paths: -------------- trunk/jython/Lib/test/test_genexps_jy.py trunk/jython/Lib/test/test_listcomp_jy.py Modified: trunk/jython/Lib/test/test_genexps_jy.py =================================================================== --- trunk/jython/Lib/test/test_genexps_jy.py 2008-12-16 19:24:41 UTC (rev 5770) +++ trunk/jython/Lib/test/test_genexps_jy.py 2008-12-17 03:56:56 UTC (rev 5771) @@ -17,11 +17,15 @@ #http://bugs.jython.org/issue1205 applied to genexps. def test_long_genexp(self): - r = 2 - g = ((x1**3+x2**3,(x1,x2),(y1,y2)) for x1 in range(4) for x2 in range(4) - if x1 < x2 for y1 in range(r) for y2 in range(r) if y1 < y2 - if x1**3+x2**3 == y1**3+y2**3 ) - self.assertEquals(g.next(), (1, (0, 1), (0, 1))) + #for a long genexp, we compute the Hardy-Ramanujan number + #http://en.wikipedia.org/wiki/1729_(number) + res = ((x1**3+x2**3,(x1,x2),(y1,y2)) + for x1 in range(20) for x2 in range(20) if x1 < x2 # x-Paare + for y1 in range(20) for y2 in range(20) if y1 < y2 # y-Paare + if x1**3+x2**3 == y1**3+y2**3 # gleiche Summe + if (x1,x2) < (y1,y2) + ) + self.assertEquals(1729, res.next()[0]) def test_main(): test_support.run_unittest(GeneratorExpressionsTestCase) Modified: trunk/jython/Lib/test/test_listcomp_jy.py =================================================================== --- trunk/jython/Lib/test/test_listcomp_jy.py 2008-12-16 19:24:41 UTC (rev 5770) +++ trunk/jython/Lib/test/test_listcomp_jy.py 2008-12-17 03:56:56 UTC (rev 5771) @@ -5,12 +5,16 @@ #http://bugs.jython.org/issue1205 def test_long_listcomp(self): - r = 2 - lc = [(x1**3+x2**3,(x1,x2),(y1,y2)) for x1 in range(4) for x2 in range(4) - if x1 < x2 for y1 in range(r) for y2 in range(r) if y1 < y2 - if x1**3+x2**3 == y1**3+y2**3 ] - self.assertEquals(len(lc), 1) - self.assertEquals(lc, [(1, (0, 1), (0, 1))]) + #for a long list comp, we compute the Hardy-Ramanujan number + #http://en.wikipedia.org/wiki/1729_(number) + res = [(x1**3+x2**3,(x1,x2),(y1,y2)) + for x1 in range(20) for x2 in range(20) if x1 < x2 # x-Paare + for y1 in range(20) for y2 in range(20) if y1 < y2 # y-Paare + if x1**3+x2**3 == y1**3+y2**3 # gleiche Summe + if (x1,x2) < (y1,y2) + ] + self.assertEquals(1729, min(res)[0]) + self.assertEquals(len(res), 2) def test_main(): test_support.run_unittest(ListCompTestCase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |