From a5f8f0f300b0e2f65e265d5c270602629d823b3d Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Wed, 10 Apr 2024 15:02:52 +0200 Subject: [PATCH] pretty rough fix for an off-by-one --- src/org/rascalmpl/interpreter/DefaultTestResultListener.java | 2 ++ .../tests/library/analysis/statistics/DescriptiveTests.rsc | 2 -- .../rascal/tests/library/analysis/statistics/RangeUtils.rsc | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/org/rascalmpl/interpreter/DefaultTestResultListener.java b/src/org/rascalmpl/interpreter/DefaultTestResultListener.java index 1f42e0a9e6b..9d4ced0c270 100644 --- a/src/org/rascalmpl/interpreter/DefaultTestResultListener.java +++ b/src/org/rascalmpl/interpreter/DefaultTestResultListener.java @@ -84,6 +84,8 @@ public void done() { if (ignored != 0) { out.println("\t" + ignored + "/" + count + " tests ignored"); } + + out.flush(); } } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc index f18334e2e60..6be61b2b829 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/DescriptiveTests.rsc @@ -15,7 +15,6 @@ bool leq(num a, num b) = a < b ? true : eq(a,b); test bool geometricLessThanArithmeticMean(list[num] nums) { if (nums == []) return true; nums = abs(nums); - println(nums); nums = assureRange(nums, 0.1, 30); return leq(geometricMean(nums), mean(nums)); } @@ -41,7 +40,6 @@ test bool percentileRelation(list[num] nums, int a, int b) { test bool varianceIsPositive(list[num] nums) { if (nums == []) return true; - println("varianceIsPositive: "); nums = assureRange(nums, 0.0001, 400); return variance(nums) >= 0; } diff --git a/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/RangeUtils.rsc b/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/RangeUtils.rsc index ed93fd8a01e..8fc77fc990b 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/RangeUtils.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/library/analysis/statistics/RangeUtils.rsc @@ -2,6 +2,7 @@ module lang::rascal::tests::library::analysis::statistics::RangeUtils import util::Math; +import IO; @synopsis{list of absolute numbers for every list element.} list[&T <: num] abs(list[&T <: num] nums) = [abs(n) | n <- nums]; @@ -20,12 +21,12 @@ best if `y - x >= high - low`, otherwise parts of the target range may be unreac window = high - low; // jump above the lower bound into the range with steps sized `window` - if (target < low) { + while (target < low) { target += ceil(low / window - target / window) * window; } // or jump below the high bound into the range with steps sized `window` - if (high < target) { + while (high < target) { target -= ceil(target / window - high / window) * window; }