From c50121b54eea7f7221a03e1e9549afe76e2b3122 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 6 Jun 2010 12:43:10 -0700 Subject: [PATCH] MOMENTS: Avoid lexical corner case in test case. The DEBUG MOMENTS command, used only for testing, used the lex_rest_of_line() function. I'd like to eventually get rid of all of the uses of this function and other unusual lexical corner cases, so this commit starts off by removing this one. --- src/language/tests/moments-test.c | 3 +-- tests/automake.mk | 2 +- tests/math/moments.at | 29 +++++++++++++++++++++++++++++ tests/testsuite.at | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/math/moments.at diff --git a/src/language/tests/moments-test.c b/src/language/tests/moments-test.c index 91a67939..795c7297 100644 --- a/src/language/tests/moments-test.c +++ b/src/language/tests/moments-test.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -84,7 +84,6 @@ cmd_debug_moments (struct lexer *lexer, struct dataset *ds UNUSED) lex_force_match (lexer, '/'); goto done; } - fprintf (stderr, "%s => ", lex_rest_of_line (lexer)); lex_get (lexer); if (two_pass) diff --git a/tests/automake.mk b/tests/automake.mk index c9fd8680..6cd1c284 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -141,7 +141,6 @@ dist_TESTS = \ tests/data/datasheet-test.sh \ tests/libpspp/sparse-xarray-test.sh \ tests/output/paper-size.sh \ - tests/stats/moments.sh \ tests/expressions/expressions.sh \ tests/expressions/epoch.sh \ tests/expressions/randist.sh \ @@ -427,6 +426,7 @@ TESTSUITE_AT = \ tests/language/stats/frequencies.at \ tests/language/xforms/compute.at \ tests/language/xforms/recode.at \ + tests/math/moments.at \ tests/output/render.at \ tests/perl-module.at TESTSUITE = $(srcdir)/tests/testsuite diff --git a/tests/math/moments.at b/tests/math/moments.at new file mode 100644 index 00000000..774d17bd --- /dev/null +++ b/tests/math/moments.at @@ -0,0 +1,29 @@ +AT_BANNER([calculating moments]) + +m4_define([MOMENTS_TESTCASES], + [[[1 2 3 4], [W=4.000 M1=2.500 M2=1.667 M3=0.000 M4=-1.200]], + [[1*5 2*5 3*5 4*5], [W=20.000 M1=2.500 M2=1.316 M3=0.000 M4=-1.401]], + [[1*1 2*2 3*3 4*4], [W=10.000 M1=3.000 M2=1.111 M3=-0.712 M4=-0.450]], + [[1*0], [W=0.000 M1=sysmis M2=sysmis M3=sysmis M4=sysmis]], + [[1*1], [W=1.000 M1=1.000 M2=sysmis M3=sysmis M4=sysmis]], + [[1*2], [W=2.000 M1=1.000 M2=0.000 M3=sysmis M4=sysmis]], + [[1*3], [W=3.000 M1=1.000 M2=0.000 M3=sysmis M4=sysmis]], + [[1*2 3], [W=3.000 M1=1.667 M2=1.333 M3=1.732 M4=sysmis]], + [[1 1.00000001], [W=2.000 M1=1.000 M2=0.000 M3=sysmis M4=sysmis]], + [[1000001 1000002 1000003 1000004], [W=4.000 M1=1000002.500 M2=1.667 M3=0.000 M4=-1.200]]]) + +m4_define([TEST_MOMENTS], + [AT_SETUP([$1 moments]) + AT_CAPTURE_FILE([moments.sps]) + AT_DATA([moments.sps], +[m4_foreach([pair], [MOMENTS_TESTCASES], [DEBUG MOMENTS $2/m4_car(pair). +])]) + AT_CHECK([pspp --testing-mode --no-output moments.sps], [0], + [], + [m4_foreach([pair], [MOMENTS_TESTCASES], [m4_argn([2], pair) +])]) + AT_CLEANUP +]) + +TEST_MOMENTS([two-pass], []) +TEST_MOMENTS([one-pass], [ONEPASS]) diff --git a/tests/testsuite.at b/tests/testsuite.at index ecc95fd2..cac695ee 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -15,6 +15,7 @@ m4_include([tests/language/stats/factor.at]) m4_include([tests/language/stats/frequencies.at]) m4_include([tests/language/xforms/compute.at]) m4_include([tests/language/xforms/recode.at]) +m4_include([tests/math/moments.at]) m4_include([tests/output/render.at]) m4_include([tests/output/charts.at]) m4_include([tests/perl-module.at]) -- 2.30.2