diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ed756ac66d9..4232bfd6705 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,38 +4,22 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
+
+
+
+
+
+
-
-
-
-
+
+
+
-
-
@@ -55,6 +39,9 @@
org.jetbrains.k2js.translate.*
+
+ org.jetbrains.k2js.translate.*
+
org.jetbrains.k2js.test.*
org.jetbrains.k2js.translate.*
@@ -159,7 +146,7 @@
-
+
@@ -172,7 +159,7 @@
-
+
@@ -242,38 +229,20 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -281,8 +250,8 @@
-
-
+
+
@@ -290,37 +259,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -328,10 +268,55 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -341,51 +326,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -426,9 +366,52 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -457,22 +440,22 @@
@@ -563,6 +546,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -609,7 +606,7 @@
-
+
@@ -631,7 +628,7 @@
-
+
@@ -661,6 +658,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -715,7 +738,7 @@
-
+
@@ -741,7 +764,7 @@
-
+
@@ -759,45 +782,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -819,6 +804,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -863,7 +874,7 @@
-
+
@@ -931,20 +942,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -984,8 +981,8 @@
-
-
+
+
@@ -996,64 +993,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -1069,7 +1010,7 @@
-
+
@@ -1080,8 +1021,8 @@
-
-
+
+
@@ -1094,17 +1035,11 @@
-
-
-
-
-
-
-
+
@@ -1115,8 +1050,8 @@
-
-
+
+
@@ -1133,6 +1068,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1260,11 +1252,11 @@
-
-
-
-
-
+
+
+
+
+
localhost
@@ -1325,7 +1317,6 @@
-
@@ -1339,11 +1330,12 @@
-
-
+
+
+
@@ -1383,7 +1375,7 @@
-
+
@@ -1396,10 +1388,6 @@
-
-
-
-
@@ -1421,6 +1409,10 @@
+
+
+
+
@@ -1430,116 +1422,114 @@
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/js/src/com/google/dart/compiler/util/AstUtil.java b/js/src/com/google/dart/compiler/util/AstUtil.java
index 9bafb490b94..7e2a7fc9107 100644
--- a/js/src/com/google/dart/compiler/util/AstUtil.java
+++ b/js/src/com/google/dart/compiler/util/AstUtil.java
@@ -335,4 +335,8 @@ public class AstUtil {
public static JsBinaryOperation subtract(JsExpression left, JsExpression right) {
return new JsBinaryOperation(JsBinaryOperator.SUB, left, right);
}
+
+ public static JsPrefixOperation not(JsExpression expression) {
+ return new JsPrefixOperation(JsUnaryOperator.NOT, expression);
+ }
}
diff --git a/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java b/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java
index d39c72319d5..903b86b9ec1 100644
--- a/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java
+++ b/translator/src/org/jetbrains/k2js/translate/context/StandardClasses.java
@@ -65,7 +65,7 @@ public final class StandardClasses {
standardClasses.declareStandardTopLevelObject(arrayListFQName, "ArrayList");
standardClasses.declareStandardInnerDeclaration(arrayListFQName, "", "ArrayList");
declareMethods(standardClasses, arrayListFQName, "size", "add", "get",
- "isEmpty", "set", "remove", "addAll");
+ "isEmpty", "set", "remove", "addAll", "contains");
}
private static void declareIterator(@NotNull StandardClasses standardClasses,
diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java
index acabf4e06fc..32941f8fe9d 100644
--- a/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java
+++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/Intrinsics.java
@@ -57,6 +57,7 @@ public final class Intrinsics {
}
}
+ //TODO: delete or include
private void declareArrayIntrinsics() {
FunctionDescriptor constructorFunction = getFunctionByName(library.getLibraryScope(), "Array");
functionIntrinsics.put(constructorFunction, ArrayNullConstructorIntrinsic.INSTANCE);
diff --git a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java
index a3020724826..bff16ef2802 100644
--- a/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java
+++ b/translator/src/org/jetbrains/k2js/translate/intrinsic/primitive/PrimitiveRangeToIntrinsic.java
@@ -1,6 +1,7 @@
package org.jetbrains.k2js.translate.intrinsic.primitive;
import com.google.dart.compiler.backend.js.ast.JsBinaryOperation;
+import com.google.dart.compiler.backend.js.ast.JsBooleanLiteral;
import com.google.dart.compiler.backend.js.ast.JsExpression;
import com.google.dart.compiler.backend.js.ast.JsNew;
import com.google.dart.compiler.util.AstUtil;
@@ -30,11 +31,14 @@ public final class PrimitiveRangeToIntrinsic implements FunctionIntrinsic {
@NotNull TranslationContext context) {
assert arguments.size() == 1 : "RangeTo must have one argument.";
JsExpression rangeEnd = arguments.get(0);
- JsBinaryOperation rangeSize = AstUtil.subtract(rangeEnd, rangeStart);
+ JsBinaryOperation rangeSize = AstUtil.sum(AstUtil.subtract(rangeEnd, rangeStart),
+ context.program().getNumberLiteral(1));
//TODO: provide a way not to hard code this value
JsNew numberRangeConstructorInvocation
= new JsNew(AstUtil.newQualifiedNameRef("Kotlin.NumberRange"));
- numberRangeConstructorInvocation.setArguments(Arrays.asList(rangeStart, rangeSize));
+ //TODO: add tests and correct expression for reversed ranges.
+ JsBooleanLiteral isRangeReversed = context.program().getFalseLiteral();
+ numberRangeConstructorInvocation.setArguments(Arrays.asList(rangeStart, rangeSize, isRangeReversed));
return numberRangeConstructorInvocation;
}
}
diff --git a/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java b/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java
index ea67febc22b..3efa7cb4381 100644
--- a/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java
+++ b/translator/src/org/jetbrains/k2js/translate/operation/IncrementTranslator.java
@@ -11,6 +11,7 @@ import org.jetbrains.k2js.translate.context.TranslationContext;
import org.jetbrains.k2js.translate.general.AbstractTranslator;
import org.jetbrains.k2js.translate.reference.AccessTranslator;
+import static org.jetbrains.k2js.translate.utils.BindingUtils.isStatement;
import static org.jetbrains.k2js.translate.utils.BindingUtils.isVariableReassignment;
import static org.jetbrains.k2js.translate.utils.PsiUtils.*;
import static org.jetbrains.k2js.translate.utils.TranslationUtils.isIntrinsicOperation;
@@ -64,9 +65,7 @@ public abstract class IncrementTranslator extends AbstractTranslator {
}
private boolean returnValueIgnored() {
- //TODO: it's a hack but for now there is now legal way to know whether expression is statement or not.
- return false;
- //return isStatement(context().bindingContext(), expression);
+ return isStatement(context().bindingContext(), expression);
}
@NotNull
diff --git a/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java b/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java
index 0b80ef75cc2..96bbae2ed32 100644
--- a/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java
+++ b/translator/src/org/jetbrains/k2js/translate/reference/CallTranslator.java
@@ -19,17 +19,19 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import static com.google.dart.compiler.util.AstUtil.not;
import static org.jetbrains.k2js.translate.utils.BindingUtils.getDescriptorForReferenceExpression;
import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionDescriptorForCallExpression;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getVariableDescriptorForVariableAsFunction;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.isConstructorDescriptor;
-import static org.jetbrains.k2js.translate.utils.PsiUtils.isInOperation;
+import static org.jetbrains.k2js.translate.utils.PsiUtils.isInOrNotInOperation;
+import static org.jetbrains.k2js.translate.utils.PsiUtils.isNotInOperation;
import static org.jetbrains.k2js.translate.utils.TranslationUtils.*;
/**
* @author Talanov Pavel
*/
-//TODO: move translate() static method into builder (consider!)
+//TODO: move translate() static methods into builder (consider!)
//TODO: write tests on calling backing fields as functions
public final class CallTranslator extends AbstractTranslator {
@@ -76,12 +78,28 @@ public final class CallTranslator extends AbstractTranslator {
(context.bindingContext(), binaryExpression.getOperationReference());
assert descriptor instanceof FunctionDescriptor;
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
- if (isInOperation(binaryExpression)) {
- return translateWithReceiverAndArgumentSwapped(context, receiver, arguments, functionDescriptor);
+ if (isInOrNotInOperation(binaryExpression)) {
+ JsExpression inRangeCheck = translateAsInOperation(context, receiver, arguments, functionDescriptor);
+ return mayBeWrapWithNegation(inRangeCheck, isNotInOperation(binaryExpression));
}
return translate(context, receiver, arguments, functionDescriptor);
}
+ public static JsExpression mayBeWrapWithNegation(@NotNull JsExpression expression, boolean shouldWrap) {
+ if (shouldWrap) {
+ return not(expression);
+ } else {
+ return expression;
+ }
+ }
+
+ private static JsExpression translateAsInOperation(@NotNull TranslationContext context,
+ @NotNull JsExpression receiver,
+ @NotNull List arguments,
+ @NotNull FunctionDescriptor functionDescriptor) {
+ return translateWithReceiverAndArgumentSwapped(context, receiver, arguments, functionDescriptor);
+ }
+
@NotNull
private static JsExpression translateWithReceiverAndArgumentSwapped(@NotNull TranslationContext context,
@NotNull JsExpression receiver,
diff --git a/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java
index e9588901a4f..1c65f998405 100644
--- a/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java
+++ b/translator/src/org/jetbrains/k2js/translate/utils/PsiUtils.java
@@ -52,8 +52,16 @@ public final class PsiUtils {
return expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER;
}
- public static boolean isInOperation(@NotNull JetBinaryExpression binaryExpression) {
- return binaryExpression.getOperationToken() == JetTokens.IN_KEYWORD;
+ public static boolean isInOrNotInOperation(@NotNull JetBinaryExpression binaryExpression) {
+ return isInOperation(binaryExpression) || isNotInOperation(binaryExpression);
+ }
+
+ public static boolean isNotInOperation(@NotNull JetBinaryExpression binaryExpression) {
+ return (binaryExpression.getOperationToken() == JetTokens.NOT_IN);
+ }
+
+ private static boolean isInOperation(@NotNull JetBinaryExpression binaryExpression) {
+ return (binaryExpression.getOperationToken() == JetTokens.IN_KEYWORD);
}
@NotNull
diff --git a/translator/test/org/jetbrains/k2js/test/SystemTest.java b/translator/test/org/jetbrains/k2js/test/SystemTest.java
index 12f680ddbd3..6e910d110b4 100644
--- a/translator/test/org/jetbrains/k2js/test/SystemTest.java
+++ b/translator/test/org/jetbrains/k2js/test/SystemTest.java
@@ -5,6 +5,7 @@ import org.junit.Test;
/**
* @author Talanov Pavel
*/
+//TODO: move most of the cases to other suites
public final class SystemTest extends JavaClassesTest {
final private static String MAIN = "system/";
@@ -50,5 +51,13 @@ public final class SystemTest extends JavaClassesTest {
checkOutput("nullChecks.kt", "6", "2", "3");
}
+ @Test
+ public void ranges() throws Exception {
+ checkOutput("ranges.kt", "OK\n" +
+ " 1 2 3 4 5\n" +
+ "Out: array has only 3 elements. x = 4\n" +
+ "Yes: array contains aaa\n" +
+ "No: array doesn't contains ddd\n", "4");
+ }
}
diff --git a/translator/testFiles/expression/misc/cases/intRange.kt b/translator/testFiles/expression/misc/cases/intRange.kt
index 8811094f239..989985fd296 100644
--- a/translator/testFiles/expression/misc/cases/intRange.kt
+++ b/translator/testFiles/expression/misc/cases/intRange.kt
@@ -2,9 +2,17 @@ namespace foo
class RangeIterator(val start : Int, var count : Int, val reversed : Boolean) {
+ var i = start
+
fun next() : Int {
--count
- return start + if (reversed) -count else count;
+ if (reversed) {
+ i--
+ return i + 1
+ } else {
+ i++
+ return i - 1
+ }
}
@@ -14,7 +22,7 @@ class RangeIterator(val start : Int, var count : Int, val reversed : Boolean) {
class NumberRange(val start : Int, val size : Int, val reversed : Boolean) {
val end : Int
- get() = start + size
+ get() = if (reversed) start - size + 1 else start + size - 1
fun contains(number : Int) : Boolean {
if (reversed) {
@@ -44,7 +52,7 @@ fun testRange() : Boolean {
if (!oneToFive.contains(4)) return false;
if (!(oneToFive.start == 1)) return false;
if (!(oneToFive.size == 4)) return false;
- if (!(oneToFive.end == 5)) return false;
+ if (!(oneToFive.end == 4)) return false;
var sum = 0;
for (i in oneToFive) {
@@ -62,7 +70,7 @@ fun testRange() : Boolean {
fun testReversedRange() : Boolean {
- System.out?.println("Testing revesed range.");
+ System.out?.println("Testing reversed range.");
val tenToFive = NumberRange(10, 5, true);
@@ -76,6 +84,10 @@ fun testReversedRange() : Boolean {
if (!tenToFive.contains(9)) return false;
if (!tenToFive.contains(10)) return false;
+ if (!(tenToFive.start == 10)) return false;
+ if (!(tenToFive.size == 5)) return false;
+ if (!(tenToFive.end == 6)) return false;
+
for (i in tenToFive) {
System.out?.println(i)
}
diff --git a/translator/testFiles/java/system/cases/ranges.kt b/translator/testFiles/java/system/cases/ranges.kt
new file mode 100644
index 00000000000..e64fc693342
--- /dev/null
+++ b/translator/testFiles/java/system/cases/ranges.kt
@@ -0,0 +1,35 @@
+import java.util.ArrayList;
+
+fun main(args : Array) {
+ val x = Integer.parseInt(args[0])
+ //Check if a number lies within a range:
+ val y = 10
+ if (x in 1..y-1)
+ System.out?.println("OK")
+
+ //Iterate over a range:
+ for (a in 1..5)
+ System.out?.print(" ${a}")
+
+ //Check if a number is out of range:
+ System.out?.println()
+ val array = ArrayList();
+
+ array.add("aaa")
+ array.add("bbb")
+ array.add("ccc")
+
+ if (x !in 0..array.size())
+ System.out?.println("Out: array has only ${array.size()} elements. x = ${x}")
+
+ //Check if a collection contains an object:
+ if ("aaa" in array) // collection.contains(obj) is called
+ System.out?.println("Yes: array contains aaa")
+
+ if ("ddd" in array) // collection.contains(obj) is called
+ System.out?.println("Yes: array contains ddd")
+ else
+ System.out?.println("No: array doesn't contains ddd")
+}
+
+
diff --git a/translator/testFiles/kotlin_lib.js b/translator/testFiles/kotlin_lib.js
index 1f6adc9ca3e..be3a11ca5d4 100644
--- a/translator/testFiles/kotlin_lib.js
+++ b/translator/testFiles/kotlin_lib.js
@@ -451,6 +451,14 @@ Kotlin.Namespace = Namespace;
Kotlin.Trait = Trait;
Kotlin.isType = isType;
+Kotlin.equals = function (obj1, obj2) {
+ if (typeof obj1 == "object") {
+ if (obj1.equals != undefined) {
+ return obj1.equals(obj2);
+ }
+ }
+ return (obj1 === obj2);
+};
Kotlin.Exceptions = {}
Kotlin.Exceptions.IndexOutOfBounds = {}
@@ -529,6 +537,14 @@ Kotlin.ArrayList = Class.create({
this.array[i] = this.array[i + 1];
}
this.$size--;
+ },
+ contains:function (obj) {
+ for (var i = 0; i < this.$size; ++i) {
+ if (Kotlin.equals(this.array[i], obj)) {
+ return true;
+ }
+ }
+ return false;
}
});
@@ -560,10 +576,12 @@ Kotlin.System = function () {
var output = "";
var print = function (obj) {
- output += obj;
+ if (obj !== undefined) {
+ output += obj;
+ }
};
var println = function (obj) {
- output += obj;
+ this.print(obj);
output += "\n";
};
@@ -598,6 +616,7 @@ Kotlin.RangeIterator = Kotlin.Class.create({initialize:function (start, count, r
this.$start = start;
this.$count = count;
this.$reversed = reversed;
+ this.$i = this.get_start();
}, get_start:function () {
return this.$start;
}, get_count:function () {
@@ -606,9 +625,20 @@ Kotlin.RangeIterator = Kotlin.Class.create({initialize:function (start, count, r
this.$count = tmp$0;
}, get_reversed:function () {
return this.$reversed;
+}, get_i:function () {
+ return this.$i;
+}, set_i:function (tmp$0) {
+ this.$i = tmp$0;
}, next:function () {
this.set_count(this.get_count() - 1);
- return this.get_start() + (this.get_reversed() ? -this.get_count() : this.get_count());
+ if (this.get_reversed()) {
+ this.set_i(this.get_i() - 1);
+ return this.get_i() + 1;
+ }
+ else {
+ this.set_i(this.get_i() + 1);
+ return this.get_i() - 1;
+ }
}, hasNext:function () {
return this.get_count() > 0;
}
@@ -625,7 +655,7 @@ Kotlin.NumberRange = Kotlin.Class.create({initialize:function (start, size, reve
}, get_reversed:function () {
return this.$reversed;
}, get_end:function () {
- return this.get_start() + this.get_size();
+ return this.get_reversed() ? this.get_start() - this.get_size() + 1 : this.get_start() + this.get_size() - 1;
}, contains:function (number) {
if (this.get_reversed()) {
return number <= this.get_start() && number > this.get_start() - this.get_size();
@@ -636,4 +666,4 @@ Kotlin.NumberRange = Kotlin.Class.create({initialize:function (start, size, reve
}, iterator:function () {
return new Kotlin.RangeIterator(this.get_start(), this.get_size(), this.get_reversed());
}
-});
\ No newline at end of file
+});
diff --git a/translator/testFiles/range/cases/explicitRange.kt b/translator/testFiles/range/cases/explicitRange.kt
index 13ba9becfca..e6f2978d5d5 100644
--- a/translator/testFiles/range/cases/explicitRange.kt
+++ b/translator/testFiles/range/cases/explicitRange.kt
@@ -14,7 +14,7 @@ fun box() : Boolean {
if (!oneToFive.contains(4)) return false;
if (!(oneToFive.start == 1)) return false;
if (!(oneToFive.size == 4)) return false;
- if (!(oneToFive.end == 5)) return false;
+ if (!(oneToFive.end == 4)) return false;
var sum = 0;
for (i in oneToFive) {
@@ -28,4 +28,8 @@ fun box() : Boolean {
return true;
+}
+
+fun main() {
+ box()
}
\ No newline at end of file
diff --git a/translator/testFiles/range/cases/intInRange.kt b/translator/testFiles/range/cases/intInRange.kt
index 575351d6e7b..bfdcfa25f59 100644
--- a/translator/testFiles/range/cases/intInRange.kt
+++ b/translator/testFiles/range/cases/intInRange.kt
@@ -2,12 +2,16 @@ namespace foo
fun box() : Boolean {
- if (1 in -2..1) return false;
- if (1 in -10..0) return false;
+ if (1 in -2..0) return false;
+ if (1 in -10..-4) return false;
if (!(1 in 0..2)) return false;
if (!(1 in 1..2)) return false;
if (!(1 in -2..5)) return false;
return true;
+}
+
+fun main() {
+ box()
}
\ No newline at end of file
diff --git a/translator/testFiles/range/cases/rangeSugarSyntax.kt b/translator/testFiles/range/cases/rangeSugarSyntax.kt
index 717cc6188ac..647071a5b3a 100644
--- a/translator/testFiles/range/cases/rangeSugarSyntax.kt
+++ b/translator/testFiles/range/cases/rangeSugarSyntax.kt
@@ -4,7 +4,7 @@ fun box() : Boolean {
var oneToFive = 1..5
- if (oneToFive.contains(5)) return false;
+ if (!oneToFive.contains(5)) return false;
if (oneToFive.contains(0)) return false;
if (oneToFive.contains(-100)) return false;
if (oneToFive.contains(10)) return false;
@@ -13,7 +13,7 @@ fun box() : Boolean {
if (!oneToFive.contains(3)) return false;
if (!oneToFive.contains(4)) return false;
if (!(oneToFive.start == 1)) return false;
- if (!(oneToFive.size == 4)) return false;
+ if (!(oneToFive.size == 5)) return false;
if (!(oneToFive.end == 5)) return false;
var sum = 0;
@@ -24,8 +24,12 @@ fun box() : Boolean {
System.out?.print(i)
}
- if (sum != 10) return false;
+ if (sum != 15) return false;
return true;
+}
+
+fun main() {
+ box()
}
\ No newline at end of file