Rewrite codegen tests which check time in deterministic way

Delete one useless test

 #KT-7621 Fixed
This commit is contained in:
Alexander Udalov
2015-04-29 15:27:21 +03:00
parent 90cdb19324
commit c860f54461
4 changed files with 15 additions and 30 deletions
@@ -26,8 +26,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.jetbrains.kotlin.codegen.CodegenTestUtil.assertIsCurrentTime;
public class PackageGenTest extends CodegenTestCase {
@Override
@@ -60,8 +58,13 @@ public class PackageGenTest extends CodegenTestCase {
public void testCurrentTime() throws Exception {
loadText("fun f() : Long { return System.currentTimeMillis(); }");
Method main = generateFunction();
long returnValue = (Long) main.invoke(null);
assertIsCurrentTime(returnValue);
long actual = (Long) main.invoke(null);
long expected = System.currentTimeMillis();
long diff = Math.abs(actual - expected);
assertTrue(
"Difference with current time: " + diff + " (this test is a bad one: it may fail even if the generated code is correct)",
diff <= 100
);
}
public void testIdentityHashCode() throws Exception {