atabac / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
0 stars 0 forks source link

Fix string.count #132

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Report from Arduino forum:

The lines 55-60 in t047.py  look like this:
Code:
assert string.count("","") == 0
assert string.count("","a") == 0
assert string.count("a","") == 0
assert string.count("","\0") == 0
assert string.count("\0","\0") == 0
assert string.count("\0","") == 0 

Here's what I got with python 2.4 and python 2.6:

1:  string.count("","")      = 1
2:  string.count("","a")     = 0
3:  string.count("a","")     = 2
4:  string.count("","\0")    = 0
5:  string.count("\0","\0")  = 1
6:  string.count("\0","")    = 2

Original issue reported on code.google.com by dwhall...@gmail.com on 2 Sep 2010 at 4:05

GoogleCodeExporter commented 9 years ago
r591
- Adjusted system test t047.py to match CPython (per above)
- Fixed algorithm in count() in src/lib/string.py

Tests pass.  Mainlined directly.

Original comment by dwhall...@gmail.com on 2 Sep 2010 at 7:12