From 932746a4f22951abcba7b7c4c94c27b1bf164272 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Thu, 22 Sep 2011 18:57:50 -0700 Subject: Stack overflow error and unit test. Change-Id: Ie7198569207b1b87c50d986df002c551ad5d7d3a --- test/IntMath/IntMath.java | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/IntMath') diff --git a/test/IntMath/IntMath.java b/test/IntMath/IntMath.java index c43d09e..e5fa806 100644 --- a/test/IntMath/IntMath.java +++ b/test/IntMath/IntMath.java @@ -786,6 +786,25 @@ class IntMath extends IntMathBase { return res; } + static long recursion_count_; + static void throwStackOverflow(long l) { + recursion_count_++; + throwStackOverflow(recursion_count_); + } + + static long testStackOverflow() { + try { + throwStackOverflow(0); + if (recursion_count_ != 0) { + return recursion_count_; + } else { + return -1; + } + } catch(StackOverflowError soe) { + return 0; + } + } + public static void main(String[] args) { boolean failure = false; int res; @@ -947,6 +966,14 @@ class IntMath extends IntMathBase { failure = true; } + lres= testStackOverflow(); + if (lres == 0) { + System.out.println("testStackOverflow PASSED"); + } else { + System.out.println("testStackOverflow FAILED: " + lres); + failure = true; + } + res = manyArgs(0, 1L, 2, 3L, 4, 5L, 6, 7, 8.0, 9.0f, 10.0, (short)11, 12, (char)13, 14, 15, (byte)-16, true, 18, 19, 20L, 21L, 22, 23, 24, 25, 26); -- cgit v1.1