mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix time-based test for worse timer resolution
This commit is contained in:
parent
fb81153ad2
commit
bc9ad315ff
|
@ -51,9 +51,10 @@ public class ThreadTest {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
fail("Exception expected");
|
fail("Exception expected");
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
assertEquals(Thread.currentThread(), mainThread);
|
assertEquals(Thread.currentThread(), mainThread);
|
||||||
assertFalse(mainThread.isInterrupted());
|
assertFalse(mainThread.isInterrupted());
|
||||||
assertTrue(System.currentTimeMillis() - start < 500);
|
assertTrue("Wait time " + (end - start), end - start < 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class ArrayBlockingQueueTest {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
queue.put(3);
|
queue.put(3);
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
assertTrue("Wait time " + (end - start), start + 50 < end && start + 500 > end);
|
assertTrue("Wait time " + (end - start), start + 50 < end && start + 5000 > end);
|
||||||
|
|
||||||
assertEquals(3, queue.remove().intValue());
|
assertEquals(3, queue.remove().intValue());
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class ArrayBlockingQueueTest {
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
int b = queue.take();
|
int b = queue.take();
|
||||||
|
|
||||||
assertTrue("Wait time " + (end - start), start + 100 < end && start + 900 > end);
|
assertTrue("Wait time " + (end - start), start + 100 < end && start + 5000 > end);
|
||||||
assertEquals(1, a);
|
assertEquals(1, a);
|
||||||
assertEquals(2, b);
|
assertEquals(2, b);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user