diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-10-14 16:21:16 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-10-14 16:25:44 +0300 |
commit | ffe010595a025ec6d9f0e2c248548b3dc2050cf7 (patch) | |
tree | 60ec5e69e32b980dd2b527105c296f0b19d7aad8 /tests | |
parent | 4253839e72aebd5a71684a13d5a40d70cb34e593 (diff) | |
download | eclat-ffe010595a025ec6d9f0e2c248548b3dc2050cf7.tar.gz eclat-ffe010595a025ec6d9f0e2c248548b3dc2050cf7.tar.bz2 |
Improve the sort function.
* grecs: Upgrade.
* lib/forlan.c (strtots): New function.
(func_sort): Rewrite. The "sort" built-in takes two
optional arguments: a path to the node to use as a key,
and a string of flags that set the comparison function and
sorting order.
* lib/forlangrm.y: Bugfix in argument verification code.
* src/dscrsnap-cl.opt: Document filters.
* tests/sortnum.at: New file.
* tests/sortrevnum.at: New file.
* tests/sortstring.at: New file.
* tests/sortts.at: New file.
* tests/Makefile.am: Add new test cases.
* tests/testsuite.at: Likewise.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/sortnum.at | 67 | ||||
-rw-r--r-- | tests/sortrevnum.at | 67 | ||||
-rw-r--r-- | tests/sortstring.at | 67 | ||||
-rw-r--r-- | tests/sortts.at | 67 | ||||
-rw-r--r-- | tests/testsuite.at | 6 |
6 files changed, 278 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 9d0de89..1d61882 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -68,6 +68,10 @@ TESTSUITE_AT = \ print02.at\ print03.at\ seqmap.at\ + sortnum.at\ + sortrevnum.at\ + sortstring.at\ + sortts.at\ start-instances.at\ stop-instances.at\ tagshairy.at\ diff --git a/tests/sortnum.at b/tests/sortnum.at new file mode 100644 index 0000000..c701bd8 --- /dev/null +++ b/tests/sortnum.at @@ -0,0 +1,67 @@ +# This file is part of Eclat -*- Autotest -*- +# Copyright (C) 2012 Sergey Poznyakoff +# +# Eclat is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Eclat is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Eclat. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Numeric sort]) +AT_KEYWORDS([sort sortnum]) + +AT_DATA([input], +[<input> + <collection> + <item> + <key>7</key> + <value>syv</value> + </item> + <item> + <key>3</key> + <value>tre</value> + </item> + <item> + <key>10</key> + <value>ti</value> + </item> + <item> + <key>6</key> + <value>seks</value> + </item> + <item> + <key>1</key> + <value>en</value> + </item> + </collection> +</input> +]) + +AT_DATA([prog],[sort(.input.collection,".item.key","n"); +dump(.); +]) + +AT_CHECK([tforlan prog input|trws], +[0], +[.input.collection.item.key: "1" +.input.collection.item.value: "en" +.input.collection.item.key: "3" +.input.collection.item.value: "tre" +.input.collection.item.key: "6" +.input.collection.item.value: "seks" +.input.collection.item.key: "7" +.input.collection.item.value: "syv" +.input.collection.item.key: "10" +.input.collection.item.value: "ti" +]) + +AT_CLEANUP + +
\ No newline at end of file diff --git a/tests/sortrevnum.at b/tests/sortrevnum.at new file mode 100644 index 0000000..5adc41c --- /dev/null +++ b/tests/sortrevnum.at @@ -0,0 +1,67 @@ +# This file is part of Eclat -*- Autotest -*- +# Copyright (C) 2012 Sergey Poznyakoff +# +# Eclat is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Eclat is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Eclat. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Reverse numeric sort]) +AT_KEYWORDS([sort sortrev sortrevnum]) + +AT_DATA([input], +[<input> + <collection> + <item> + <key>7</key> + <value>syv</value> + </item> + <item> + <key>3</key> + <value>tre</value> + </item> + <item> + <key>10</key> + <value>ti</value> + </item> + <item> + <key>6</key> + <value>seks</value> + </item> + <item> + <key>1</key> + <value>en</value> + </item> + </collection> +</input> +]) + +AT_DATA([prog],[sort(.input.collection,".item.key","nr"); +dump(.); +]) + +AT_CHECK([tforlan prog input|trws], +[0], +[.input.collection.item.key: "10" +.input.collection.item.value: "ti" +.input.collection.item.key: "7" +.input.collection.item.value: "syv" +.input.collection.item.key: "6" +.input.collection.item.value: "seks" +.input.collection.item.key: "3" +.input.collection.item.value: "tre" +.input.collection.item.key: "1" +.input.collection.item.value: "en" +]) + +AT_CLEANUP + +
\ No newline at end of file diff --git a/tests/sortstring.at b/tests/sortstring.at new file mode 100644 index 0000000..4f722d3 --- /dev/null +++ b/tests/sortstring.at @@ -0,0 +1,67 @@ +# This file is part of Eclat -*- Autotest -*- +# Copyright (C) 2012 Sergey Poznyakoff +# +# Eclat is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Eclat is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Eclat. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([String sort]) +AT_KEYWORDS([sort sortstring]) + +AT_DATA([input], +[<input> + <collection> + <item> + <key>7</key> + <value>syv</value> + </item> + <item> + <key>3</key> + <value>tre</value> + </item> + <item> + <key>10</key> + <value>ti</value> + </item> + <item> + <key>6</key> + <value>seks</value> + </item> + <item> + <key>1</key> + <value>en</value> + </item> + </collection> +</input> +]) + +AT_DATA([prog],[sort(.input.collection,".item.key"); +dump(.); +]) + +AT_CHECK([tforlan prog input|trws], +[0], +[.input.collection.item.key: "1" +.input.collection.item.value: "en" +.input.collection.item.key: "10" +.input.collection.item.value: "ti" +.input.collection.item.key: "3" +.input.collection.item.value: "tre" +.input.collection.item.key: "6" +.input.collection.item.value: "seks" +.input.collection.item.key: "7" +.input.collection.item.value: "syv" +]) + +AT_CLEANUP + +
\ No newline at end of file diff --git a/tests/sortts.at b/tests/sortts.at new file mode 100644 index 0000000..1500728 --- /dev/null +++ b/tests/sortts.at @@ -0,0 +1,67 @@ +# This file is part of Eclat -*- Autotest -*- +# Copyright (C) 2012 Sergey Poznyakoff +# +# Eclat is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Eclat is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Eclat. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Timestamp sort]) +AT_KEYWORDS([sort sortts]) + +AT_DATA([input], +[<input> + <collection> + <item> + <key>2012-02-20T16:27:51.000Z</key> + <value>tolvte februar 2012, seksten tjuefem femtien</value> + </item> + <item> + <key>2012-10-14T15:51:00.000Z</key> + <value>fjortende oktober 2012, femten femtien</value> + </item> + <item> + <key>2011-01-22T00:00:00.000Z</key> + <value>tjueandre januar 2011, null null</value> + </item> + <item> + <key>2012-02-20T16:25:34.000Z</key> + <value>tjuende februar 2012, seksten tjuefem trettifire</value> + </item> + <item> + <key>2012-02-22T01:21:22.000Z</key> + <value>tjueandre februar 2012, ett tjueen tjueto</value> + </item> + </collection> +</input> +]) + +AT_DATA([prog],[sort(.input.collection,".item.key","t"); +dump(.); +]) + +AT_CHECK([tforlan prog input|trws], +[0], +[.input.collection.item.key: "2011-01-22T00:00:00.000Z" +.input.collection.item.value: "tjueandre januar 2011, null null" +.input.collection.item.key: "2012-02-20T16:25:34.000Z" +.input.collection.item.value: "tjuende februar 2012, seksten tjuefem trettifire" +.input.collection.item.key: "2012-02-20T16:27:51.000Z" +.input.collection.item.value: "tolvte februar 2012, seksten tjuefem femtien" +.input.collection.item.key: "2012-02-22T01:21:22.000Z" +.input.collection.item.value: "tjueandre februar 2012, ett tjueen tjueto" +.input.collection.item.key: "2012-10-14T15:51:00.000Z" +.input.collection.item.value: "fjortende oktober 2012, femten femtien" +]) + +AT_CLEANUP + +
\ No newline at end of file diff --git a/tests/testsuite.at b/tests/testsuite.at index 8a7d8ab..f9da96c 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -68,6 +68,12 @@ m4_include([get-console-output.at]) m4_include([start-instances.at]) m4_include([stop-instances.at]) +AT_BANNER([Sort]) +m4_include([sortstring.at]) +m4_include([sortnum.at]) +m4_include([sortrevnum.at]) +m4_include([sortts.at]) + AT_BANNER([Maps]) m4_include([nullmap.at]) m4_include([filemap.at]) |