KT-968 String should provide an iterator() method

This commit is contained in:
Alex Tkachman
2012-01-25 09:36:55 +02:00
parent 309b6b3e0e
commit 3c13a2cd98
3 changed files with 61 additions and 0 deletions
@@ -110,6 +110,23 @@ public class StdlibTest extends CodegenTestCase {
} catch (Throwable t) {
// System.out.println(generateToText());
t.printStackTrace();
throw t instanceof Exception ? (Exception)t : new RuntimeException(t);
}
}
public void testForInString() throws Exception {
loadText("fun foo() : Int { var sum = 0\n" +
" for(c in \"239\")\n" +
" sum += (c.int - '0'.int)\n" +
" return sum" +
"}" );
final Method main = generateFunction();
try {
assertEquals(14, main.invoke(null));
} catch (Throwable t) {
System.out.println(generateToText());
t.printStackTrace();
throw t instanceof Exception ? (Exception)t : new RuntimeException(t);
}
}
}