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