fixes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.k2js.test;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mozilla.javascript.JavaScriptException;
|
||||
|
||||
/**
|
||||
* @author Talanov Pavel
|
||||
@@ -43,4 +44,9 @@ public final class ArrayListTest extends JavaClassesTest {
|
||||
public void remove() throws Exception {
|
||||
testFooBoxIsTrue("remove.kt");
|
||||
}
|
||||
|
||||
@Test(expected = JavaScriptException.class)
|
||||
public void indexOOB() throws Exception {
|
||||
testFooBoxIsTrue("indexOOB.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace foo
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
fun box() : Boolean {
|
||||
val arr = ArrayList<Int>();
|
||||
var i = 0;
|
||||
while (i++ < 10) {
|
||||
arr.add(i);
|
||||
}
|
||||
return (arr[10] == 11)
|
||||
}
|
||||
@@ -12,5 +12,5 @@ fun box() : Boolean {
|
||||
for (a in arr) {
|
||||
sum += a;
|
||||
}
|
||||
return (sum == 55)
|
||||
return (sum == 55) && (arr.size() == 10)
|
||||
}
|
||||
@@ -463,13 +463,13 @@ Kotlin.Array = Class.create({
|
||||
}
|
||||
},
|
||||
get:function (index) {
|
||||
if ((index < 0) || (index > this.array.length)) {
|
||||
if ((index < 0) || (index >= this.array.length)) {
|
||||
throw Kotlin.Exceptions.IndexOutOfBounds;
|
||||
}
|
||||
return (this.array)[index];
|
||||
},
|
||||
set:function (index, value) {
|
||||
if ((index < 0) || (index > this.array.length)) {
|
||||
if ((index < 0) || (index >= this.array.length)) {
|
||||
throw Kotlin.Exceptions.IndexOutOfBounds;
|
||||
}
|
||||
(this.array)[index] = value;
|
||||
@@ -489,13 +489,13 @@ Kotlin.ArrayList = Class.create({
|
||||
this.$size = 0;
|
||||
},
|
||||
get:function (index) {
|
||||
if ((index < 0) || (index > this.$size)) {
|
||||
if ((index < 0) || (index >= this.$size)) {
|
||||
throw Kotlin.Exceptions.IndexOutOfBounds;
|
||||
}
|
||||
return (this.array)[index];
|
||||
},
|
||||
set:function (index, value) {
|
||||
if ((index < 0) || (index > this.$size)) {
|
||||
if ((index < 0) || (index >= this.$size)) {
|
||||
throw Kotlin.Exceptions.IndexOutOfBounds;
|
||||
}
|
||||
(this.array)[index] = value;
|
||||
|
||||
Reference in New Issue
Block a user