Commit ce0618d4 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix str.split and add some test cases for it

parent 36f59af3
......@@ -453,7 +453,7 @@ Box* floatNew2(BoxedClass *cls, Box* a) {
if (s == "-inf")
return boxFloat(-INFINITY);
RELEASE_ASSERT(0, "%s", s.c_str());
return boxFloat(strtod(s.c_str(), NULL));
}
RELEASE_ASSERT(0, "%s", getTypeName(a)->c_str());
}
......
......@@ -330,12 +330,18 @@ Box* strSplit1(BoxedString* self) {
std::ostringstream os("");
for (char c : self->s) {
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f') {
listAppendInternal(rtn, boxString(os.str()));
os.str("");
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v') {
if (os.tellp()) {
listAppendInternal(rtn, boxString(os.str()));
os.str("");
}
} else {
os << c;
}
}
listAppendInternal(rtn, boxString(os.str()));
if (os.tellp()) {
listAppendInternal(rtn, boxString(os.str()));
}
return rtn;
}
......
......@@ -4,3 +4,7 @@ print repr(chr(0) + chr(180))
print repr('"')
# print repr("'") // don't feel like handling this right now; this should print out (verbatim) "'", ie realize it can use double quotes
print repr("'\"")
print "hello world\tmore\nwords\va\fb\ao".split()
print " test ".split()
# print " test ".split(' ')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment