Skip to content

Commit

Permalink
nan and inf can't be passed to a function,
Browse files Browse the repository at this point in the history
so don't try to unit test them
  • Loading branch information
micsthepick committed Feb 28, 2024
1 parent cfd6330 commit 38c5752
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
9 changes: 0 additions & 9 deletions testing_defines.eel2
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// Helper functions to check for positive infinity, negative infinity, and nan
function is_pos_inf(x) (x == 1/0);
function is_neg_inf(x) (x == -1/0);
function is_nan(x) (x != x;);

function assert_equal_exact(expected, actual, message) global(failed_asserts, successful_asserts) (
is_nan(expected) && is_nan(actual) ? successful_asserts += 1 :
(is_pos_inf(expected) && is_pos_inf(actual)) || (is_neg_inf(expected) && is_neg_inf(actual)) ? successful_asserts += 1 :
expected !== actual ? (
fprintf(3, "\033[0;31mexpected: %g, was: %g. %s\033[0m\n", expected, actual, message);
failed_asserts += 1;
Expand All @@ -17,8 +10,6 @@ function assert_equal_exact(expected, actual) global() (
);

function assert_near_equal(expected, tolerance, actual, message) global(failed_asserts, successful_asserts) (
is_nan(expected) || is_nan(actual) || is_nan(tolerance) ? successful_asserts += 1 :
(is_pos_inf(expected) || is_neg_inf(expected)) && (is_pos_inf(actual) || is_neg_inf(actual)) ? successful_asserts += 1 :
abs(expected - actual) > tolerance ? (
fprintf(3, "\033[0;31mexpected: %g (±%g), was: %g. %s\033[0m\n", expected, tolerance, actual, message);
failed_asserts += 1;
Expand Down
9 changes: 5 additions & 4 deletions vocalrediso-jamesdsp.eel
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ slider6 = srate/2;
slider_code();

//DEBUGPRINT("SAMPLE_0_0_TEST\n");
// spl0=0 spl1=0 for buffer_length*2 samples
// spl0=0 spl1=0 for 100 output samples
sum_first_pdc_samples(0, 0);
assert_equal_exact(0, spl0sum, "spl0sum for init");
assert_equal_exact(0, spl1sum, "spl1sum for init");
Expand All @@ -353,7 +353,7 @@ assert_near_equal(0, 0.001, spl1sum, "SAMPLE_0_0_TEST: spl1sum was not as expect
//DEBUGPRINT("spl0sum=%g, spl1sum=%g\n", spl0sum, spl1sum);

//DEBUGPRINT("SAMPLE_1_0_TEST\n");
// spl0=1 spl1=0 for buffer_length*2 samples
// spl0=1 spl1=0 for for 100 output samples
sum_first_pdc_samples(1, 0);
assert_equal_exact(0, spl0sum, "spl0sum for init");
assert_equal_exact(0, spl1sum, "spl1sum for init");
Expand All @@ -370,7 +370,7 @@ assert_near_equal(0, 0.001, spl1sum, "SAMPLE_1_0_TEST: spl1sum was not as expect
//DEBUGPRINT("spl0sum=%g, spl1sum=%g\n", spl0sum, spl1sum);

//DEBUGPRINT("SAMPLE_0_1_TEST\n");
// spl0=0 spl1=1 for buffer_length*2 samples
// spl0=0 spl1=1 for for 100 output samples
sum_first_pdc_samples(0, 1);
assert_equal_exact(0, spl0sum, "spl0sum for init");
assert_equal_exact(0, spl1sum, "spl1sum for init");
Expand All @@ -387,7 +387,7 @@ assert_near_equal(100, 0.001, spl1sum, "SAMPLE_0_1_TEST: spl1sum was not as expe
//DEBUGPRINT("spl0sum=%g, spl1sum=%g\n", spl0sum, spl1sum);

//DEBUGPRINT("SAMPLE_1_1_TEST\n");
// spl0=1 spl1=1 for buffer_length*2 samples
// spl0=1 spl1=1 for for 100 output samples
sum_first_pdc_samples(1, 1);
assert_equal_exact(0, spl0sum, "spl0sum for init");
assert_equal_exact(0, spl1sum, "spl1sum for init");
Expand All @@ -405,6 +405,7 @@ assert_near_equal(200, 0.001, spl1sum, "SAMPLE_1_1_TEST: spl1sum was not as expe


//DEBUGPRINT("SETUP: fft range is [srate/4, srate/2] dry=100 wet=100\n");
// check no values before first output sample
slider1 = slider2 = 100;
slider5 = srate/4;
slider6 = srate/2;
Expand Down

0 comments on commit 38c5752

Please sign in to comment.