dbl -> toDouble

This commit is contained in:
Alex Tkachman
2012-02-22 13:14:41 +02:00
parent 18990e2c1b
commit 53bba59a4f
79 changed files with 335 additions and 298 deletions
@@ -41,7 +41,7 @@ public class AnnotationGenTest extends CodegenTestCase {
public void testPropSetter() throws NoSuchFieldException, NoSuchMethodException {
loadText("var x = 0\n" +
"[Deprecated] set");
System.out.println(generateToText());
// System.out.println(generateToText());
Class aClass = generateNamespaceClass();
assertNull(aClass.getDeclaredMethod("getX").getAnnotation(Deprecated.class));
assertNotNull(aClass.getDeclaredMethod("setX", int.class).getAnnotation(Deprecated.class));
@@ -78,7 +78,7 @@ public class ArrayGenTest extends CodegenTestCase {
public void testIterator () throws Exception {
loadText("fun box() { val x = Array<Int>(5, { it } ).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }");
System.out.println(generateToText());
// System.out.println(generateToText());
Method foo = generateFunction();
foo.invoke(null);
}
@@ -285,9 +285,9 @@ public class ArrayGenTest extends CodegenTestCase {
public void testLongDouble () throws Exception {
loadText(
"fun box() : Int { var l = IntArray(1); l[0.long] = 4; l[0.long] += 6; return l[0.long];}\n" +
"fun IntArray.set(index: Long, elem: Int) { this[index.int] = elem }\n" +
"fun IntArray.get(index: Long) = this[index.int]");
"fun box() : Int { var l = IntArray(1); l[0.toLong()] = 4; l[0.toLong()] += 6; return l[0.toLong()];}\n" +
"fun IntArray.set(index: Long, elem: Int) { this[index.toInt()] = elem }\n" +
"fun IntArray.get(index: Long) = this[index.toInt()]");
// System.out.println(generateToText());
Method foo = generateFunction("box");
assertTrue((Integer)foo.invoke(null) == 10);
@@ -314,6 +314,6 @@ public class ArrayGenTest extends CodegenTestCase {
public void testNonNullArray() throws Exception {
blackBoxFile("classes/nonnullarray.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
}
@@ -38,7 +38,7 @@ public class ClassGenTest extends CodegenTestCase {
public void testArrayListInheritance() throws Exception {
loadFile("classes/inheritingFromArrayList.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
final Class aClass = loadClass("Foo", generateClassesInFile());
assertInstanceOf(aClass.newInstance(), List.class);
}
@@ -214,7 +214,7 @@ public class ClassGenTest extends CodegenTestCase {
public void testKt508 () throws Exception {
loadFile("regressions/kt508.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
blackBox();
}
@@ -48,7 +48,7 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
public void testShared() throws Exception {
blackBoxFile("extensionFunctions/shared.kt");
System.out.println(generateToText());
// System.out.println(generateToText());
}
public void testKt475() throws Exception {
@@ -377,7 +377,7 @@ public class NamespaceGenTest extends CodegenTestCase {
}
public void testArrayAugAssignLong() throws Exception {
loadText("fun foo(c: LongArray) { c[0] *= 2.long }");
loadText("fun foo(c: LongArray) { c[0] *= 2.toLong() }");
// System.out.println(generateToText());
final Method main = generateFunction();
long[] data = new long[] { 5 };
@@ -147,20 +147,20 @@ public class PrimitiveTypesTest extends CodegenTestCase {
}
public void testDoubleToInt() throws Exception {
loadText("fun foo(a: Double): Int = a.int");
loadText("fun foo(a: Double): Int = a.toInt()");
// System.out.println(generateToText());
final Method main = generateFunction();
assertEquals(1, main.invoke(null, 1.0));
}
public void testCastConstant() throws Exception {
loadText("fun foo(): Double = 1.double");
loadText("fun foo(): Double = 1.toDouble()");
final Method main = generateFunction();
assertEquals(1.0, main.invoke(null));
}
public void testCastOnStack() throws Exception {
loadText("fun foo(): Double = System.currentTimeMillis().double");
loadText("fun foo(): Double = System.currentTimeMillis().toDouble()");
final Method main = generateFunction();
double currentTimeMillis = (double) System.currentTimeMillis();
double result = (Double) main.invoke(null);
@@ -327,7 +327,7 @@ public class PrimitiveTypesTest extends CodegenTestCase {
}
public void testKt737() throws Exception {
loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.byte.compareTo(10.long) >= 0) \"fail\" else \"OK\"");
loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.toByte().compareTo(10.toLong()) >= 0) \"fail\" else \"OK\"");
assertEquals("OK", blackBox());
}
@@ -125,7 +125,7 @@ public class PropertyGenTest extends CodegenTestCase {
public void testAccessorsWithoutBody() throws Exception {
loadText("class AccessorsWithoutBody() { protected var foo: Int = 349\n get\n private set\n fun setter() { foo = 610; } } ");
System.out.println(generateToText());
// System.out.println(generateToText());
final Class aClass = loadImplementationClass(generateClassesInFile(), "AccessorsWithoutBody");
final Object instance = aClass.newInstance();
final Method getFoo = findMethodByName(aClass, "getFoo");
@@ -167,7 +167,7 @@ public class PropertyGenTest extends CodegenTestCase {
public void testVolatileProperty() throws Exception {
loadText("abstract class Foo { public volatile var x: String = \"\"; }");
System.out.println(generateToText());
// System.out.println(generateToText());
final ClassFileFactory codegens = generateClassesInFile();
final Class aClass = loadClass("Foo", codegens);
Field x = aClass.getDeclaredField("x");
@@ -104,7 +104,7 @@ public class StdlibTest extends CodegenTestCase {
public void testForInString() throws Exception {
loadText("fun foo() : Int { var sum = 0\n" +
" for(c in \"239\")\n" +
" sum += (c.int - '0'.int)\n" +
" sum += (c.toInt() - '0'.toInt())\n" +
" return sum" +
"}" );
final Method main = generateFunction();
@@ -19,6 +19,6 @@ package org.jetbrains.jet.codegen;
public class TupleGenTest extends CodegenTestCase {
public void testBasic() {
blackBoxFile("/tuples/basic.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
}
@@ -147,12 +147,12 @@ public class TypeInfoTest extends CodegenTestCase {
public void testInner() throws Exception {
blackBoxFile("typeInfo/inner.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
public void testInheritance() throws Exception {
blackBoxFile("typeInfo/inheritance.jet");
System.out.println(generateToText());
// System.out.println(generateToText());
}
public void testkt1113() throws Exception {
@@ -58,7 +58,7 @@ public class VarArgTest extends CodegenTestCase {
}
public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException {
loadText("fun test() = testf(239.byte, 7.byte); fun testf(vararg ts: Byte?) = ts");
loadText("fun test() = testf(239.toByte(), 7.toByte()); fun testf(vararg ts: Byte?) = ts");
// System.out.println(generateToText());
final Method main = generateFunction("test");
Object res = main.invoke(null);
@@ -78,7 +78,7 @@ public class VarArgTest extends CodegenTestCase {
public void testArrayT () throws InvocationTargetException, IllegalAccessException {
loadText("fun test() = _array(2, 4); fun <T> _array(vararg elements : T) = elements");
System.out.println(generateToText());
// System.out.println(generateToText());
final Method main = generateFunction("test");
Object res = main.invoke(null);
assertTrue(((Integer[])res).length == 2);
@@ -79,14 +79,14 @@ public class JetTypeCheckerTest extends JetLiteFixture {
assertType("0b1", library.getIntType());
assertType("0B1", library.getIntType());
assertType("1.long", library.getLongType());
assertType("1.toLong()", library.getLongType());
assertType("1.0", library.getDoubleType());
assertType("1.0.double", library.getDoubleType());
assertType("1.0.toDouble()", library.getDoubleType());
assertType("0x1.fffffffffffffp1023", library.getDoubleType());
assertType("1.0.float", library.getFloatType());
assertType("0x1.fffffffffffffp1023.float", library.getFloatType());
assertType("1.0.toFloat()", library.getFloatType());
assertType("0x1.fffffffffffffp1023.toFloat()", library.getFloatType());
assertType("true", library.getBooleanType());
assertType("false", library.getBooleanType());
@@ -401,53 +401,53 @@ public class JetTypeCheckerTest extends JetLiteFixture {
assertType("f()", "Unit");
assertType("f(1)", "Int");
assertType("f(1.float, 1)", "Float");
assertType("f<String>(1.float)", "String");
assertType("f(1.toFloat(), 1)", "Float");
assertType("f<String>(1.toFloat())", "String");
}
public void testPlus() throws Exception {
assertType("1.0.plus(1.double)", "Double");
assertType("1.0.plus(1.float)", "Double");
assertType("1.0.plus(1.long)", "Double");
assertType("1.0.plus(1.toDouble())", "Double");
assertType("1.0.plus(1.toFloat())", "Double");
assertType("1.0.plus(1.toLong())", "Double");
assertType("1.0.plus(1)", "Double");
assertType("1.float.plus(1.double)", "Double");
assertType("1.float.plus(1.float)", "Float");
assertType("1.float.plus(1.long)", "Float");
assertType("1.float.plus(1)", "Float");
assertType("1.toFloat().plus(1.toDouble())", "Double");
assertType("1.toFloat().plus(1.toFloat())", "Float");
assertType("1.toFloat().plus(1.toLong())", "Float");
assertType("1.toFloat().plus(1)", "Float");
assertType("1.long.plus(1.double)", "Double");
assertType("1.long.plus(1.float)", "Float");
assertType("1.long.plus(1.long)", "Long");
assertType("1.long.plus(1)", "Long");
assertType("1.toLong().plus(1.toDouble())", "Double");
assertType("1.toLong().plus(1.toFloat())", "Float");
assertType("1.toLong().plus(1.toLong())", "Long");
assertType("1.toLong().plus(1)", "Long");
assertType("1.plus(1.double)", "Double");
assertType("1.plus(1.float)", "Float");
assertType("1.plus(1.long)", "Long");
assertType("1.plus(1.toDouble())", "Double");
assertType("1.plus(1.toFloat())", "Float");
assertType("1.plus(1.toLong())", "Long");
assertType("1.plus(1)", "Int");
assertType("'1'.plus(1.double)", "Double");
assertType("'1'.plus(1.float)", "Float");
assertType("'1'.plus(1.long)", "Long");
assertType("'1'.plus(1.toDouble())", "Double");
assertType("'1'.plus(1.toFloat())", "Float");
assertType("'1'.plus(1.toLong())", "Long");
assertType("'1'.plus(1)", "Int");
assertType("'1'.minus('1')", "Int"); // Plus is not available for char
assertType("(1:Short).plus(1.double)", "Double");
assertType("(1:Short).plus(1.float)", "Float");
assertType("(1:Short).plus(1.long)", "Long");
assertType("(1:Short).plus(1.toDouble())", "Double");
assertType("(1:Short).plus(1.toFloat())", "Float");
assertType("(1:Short).plus(1.toLong())", "Long");
assertType("(1:Short).plus(1)", "Int");
assertType("(1:Short).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1.double)", "Double");
assertType("(1:Byte).plus(1.float)", "Float");
assertType("(1:Byte).plus(1.long)", "Long");
assertType("(1:Byte).plus(1.toDouble())", "Double");
assertType("(1:Byte).plus(1.toFloat())", "Float");
assertType("(1:Byte).plus(1.toLong())", "Long");
assertType("(1:Byte).plus(1)", "Int");
assertType("(1:Byte).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1:Byte)", "Int");
assertType("\"1\".plus(1.double)", "String");
assertType("\"1\".plus(1.float)", "String");
assertType("\"1\".plus(1.long)", "String");
assertType("\"1\".plus(1.toDouble())", "String");
assertType("\"1\".plus(1.toFloat())", "String");
assertType("\"1\".plus(1.toLong())", "String");
assertType("\"1\".plus(1)", "String");
assertType("\"1\".plus('1')", "String");
}