JS backend: fixed variable capturing in extension functions.

Fixed ClosureTest.testWrappedVariableInExtensionFun IteratorsTest.foldReducesTheFirstNElements and IteratorsTest.takeExtractsTheFirstNElements. All tests passed.

(cherry picked from commit f8f1895)
This commit is contained in:
develar
2013-08-08 21:28:41 +04:00
committed by Zalim Bashorov
parent 786652940d
commit e786e62fd7
12 changed files with 121 additions and 71 deletions
@@ -16,14 +16,12 @@ class IteratorsTest {
assertEquals(arrayList(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList())
}
// TODO fix and enable this test
fun foldReducesTheFirstNElements() {
test fun foldReducesTheFirstNElements() {
val sum = { (a: Int, b: Int) -> a + b }
assertEquals(arrayList(13, 21, 34, 55, 89).fold(0, sum), fibonacci().filter { it > 10 }.take(5).fold(0, sum))
}
// TODO fix and enable this test
fun takeExtractsTheFirstNElements() {
test fun takeExtractsTheFirstNElements() {
assertEquals(arrayList(0, 1, 1, 2, 3, 5, 8, 13, 21, 34), fibonacci().take(10).toList())
}