From 632adb595cfa6ed0e17eeb790100418c1a787656 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Sun, 6 Oct 2013 15:13:52 +0400 Subject: [PATCH] Some tests for loops --- test/org/jetbrains/eval4j/test/TestData.java | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/test/org/jetbrains/eval4j/test/TestData.java b/test/org/jetbrains/eval4j/test/TestData.java index 693e07a4e6d..60ffb645e71 100644 --- a/test/org/jetbrains/eval4j/test/TestData.java +++ b/test/org/jetbrains/eval4j/test/TestData.java @@ -62,4 +62,73 @@ class TestData { return 1; } } + + static int loop() { + int i = 0; + while (i < 10) i++; + return i; + } + + static int loopWithBreak() { + int i = 0; + while (true) { + if (i > 10) break; + i++; + } + return i; + } + + static int loopWithReturn() { + int i = 0; + while (true) { + if (i > 10) return i; + i++; + } + } + + static int testSimpleFinally() { + int i = 5; + try { + return i; + } + finally { + i = 3; + } + } + + static int testSimpleFinallyWithReturn() { + int i = 5; + try { + return i; + } + finally { + return 3; + } + } + + static int testSimpleFinallyWithContinueInLoop() { + int i = 5; + while (true) { + try { + if (i % 2 == 0) continue; + if (i > 10) return i; + } + finally { + i++; + } + } + } + + static int testSimpleFinallyWithBreakInLoop() { + int i = 5; + while (true) { + try { + if (i % 2 == 0) break; + } + finally { + i++; + } + } + return i; + } }