From 43350f7c6b9bfbdce625d6ef66f9cece5873d7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Thu, 27 Feb 2020 03:56:43 -0800 Subject: [PATCH] [cost] Add Java tests for ZERO_EXECUTION_TIME Reviewed By: skcho Differential Revision: D20117064 fbshipit-source-id: 15c5eae64 --- .../tests/codetoanalyze/java/performance/Zero.java | 14 +++++++++++++- .../codetoanalyze/java/performance/issues.exp | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/infer/tests/codetoanalyze/java/performance/Zero.java b/infer/tests/codetoanalyze/java/performance/Zero.java index f1458a018..45b2b5987 100644 --- a/infer/tests/codetoanalyze/java/performance/Zero.java +++ b/infer/tests/codetoanalyze/java/performance/Zero.java @@ -4,7 +4,19 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ +import com.google.common.base.Preconditions; + class Zero { - void zero_cost() {}; + // cost: 1 + void unit_cost() {}; + + public void infeasible_path_zero() { + Preconditions.checkState(false); // pruned to bottom + } + + // we can't handle doubles properly in Inferbo + public void double_prune_FN(double fpp) { + Preconditions.checkArgument(fpp > 0.0 && fpp < 0.0); + } } diff --git a/infer/tests/codetoanalyze/java/performance/issues.exp b/infer/tests/codetoanalyze/java/performance/issues.exp index 78a8d0ee3..5458e0165 100644 --- a/infer/tests/codetoanalyze/java/performance/issues.exp +++ b/infer/tests/codetoanalyze/java/performance/issues.exp @@ -219,3 +219,5 @@ codetoanalyze/java/performance/UnknownCallsTest.java, UnknownCallsTest.read_max_ codetoanalyze/java/performance/UnknownCallsTest.java, UnknownCallsTest.read_sum_cost(java.io.InputStream,byte[],int,int,java.util.ArrayList):int, 3, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 15 + 6 ⋅ 2⋅byteCount, O(2⋅byteCount), degree = 1,{2⋅byteCount},Loop at line 33] codetoanalyze/java/performance/UnknownCallsTest.java, UnknownCallsTest.throw_exception():int, 0, UNREACHABLE_CODE, no_bucket, ERROR, [Here] codetoanalyze/java/performance/UnknownCallsTest.java, UnknownCallsTest.unmodeled_impure_linear(java.util.ArrayList):void, 0, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + 13 ⋅ list.length + 3 ⋅ (list.length + 1), O(list.length), degree = 1,{list.length + 1},Loop at line 61,{list.length},Loop at line 61] +codetoanalyze/java/performance/Zero.java, Zero.infeasible_path_zero():void, 0, UNREACHABLE_CODE, no_bucket, ERROR, [Here] +codetoanalyze/java/performance/Zero.java, Zero.infeasible_path_zero():void, 0, ZERO_EXECUTION_TIME, no_bucket, ERROR, []