[Pkg-haskell-commits] [SCM] Debian package for MissingH branch, master, updated. debian/1.1.0.1-2-49-gdaefc69
John Goerzen
jgoerzen at complete.org
Tue Feb 16 22:45:25 UTC 2010
The following commit has been merged in the master branch:
commit 71c337cd4c833e24db117c6fcc443d9d7a1f4ce1
Author: John Goerzen <jgoerzen at complete.org>
Date: Tue Feb 16 14:48:53 2010 -0600
Revert "Imported Upstream version 1.1.0.1"
This reverts commit 7c5282730eed2b5d0f6c079e2619de46af53c363.
diff --git a/3rd-party-licenses/BSD b/3rd-party-licenses/BSD
new file mode 100644
index 0000000..c01b032
--- /dev/null
+++ b/3rd-party-licenses/BSD
@@ -0,0 +1,29 @@
+Copyright (c) The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+# arch-tag: 3-clause BSD license text
+
diff --git a/3rd-party-licenses/LGPL-2.1 b/3rd-party-licenses/LGPL-2.1
new file mode 100644
index 0000000..c8a1386
--- /dev/null
+++ b/3rd-party-licenses/LGPL-2.1
@@ -0,0 +1,511 @@
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs must
+be allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least
+ three years, to give the same user the materials specified in
+ Subsection 6a, above, for a charge no more than the cost of
+ performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+ Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+# arch-tag: LGPL 2.1 license text
+
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..6647dbb
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,60 @@
+=========================================
+INSTALLATION INSTRUCTIONS
+For Linux, Unix, BSD, and POSIX platforms
+=========================================
+
+Please see the file INSTALL-win.txt for Windows platform instructions.
+
+PREREQUISITES
+-------------
+
+You must satisfy one or more of these major categories:
+
+1. GHC 6.6 or above (including cpphs)
+ (for GHC 6.4.0 or 6.4.1, use MissingH 0.14.3 or below)
+
+2. Hugs 2005xx or above, plus cpphs
+
+ If you don't already have cpphs, get it from
+ http://www.cs.york.ac.uk/fp/cpphs/.
+
+If you need Cabal, get it from http://www.haskell.org/cabal.
+
+Debian users can install the packages cpphs and ghc6
+
+3. GHC extralibs collection, or the individual
+ libraries mentioned in MissingH.cabal
+
+ You can conveniently download them all in one package; see
+
+http://software.complete.org/missingh/wiki/RelatedSoftware#RequisiteLibraries
+
+
+INSTALLATION
+------------
+
+The first step is to generate your setup file. To do that, run:
+
+ make setup
+
+Now, for GHC:
+
+ ./setup configure
+ ./setup build
+ ./setup install
+
+Or, for Hugs:
+
+ ./setup configure --hugs
+ ./setup build
+ ./setup install
+
+Optionally, to run the unit tests, you'll need to install HUnit. Then:
+
+ make test-ghc6
+
+or:
+
+ make test-hugs
+
+(More to come in this file)
diff --git a/INSTALL-win.txt b/INSTALL-win.txt
new file mode 100644
index 0000000..44edc92
--- /dev/null
+++ b/INSTALL-win.txt
@@ -0,0 +1,33 @@
+=========================
+INSTALLATION INSTRUCTIONS
+For Microsoft platforms
+=========================
+
+For Unix, Linux, BSD, and other POSIX platforms (including Cygwin),
+see the INSTALL file instead of this one.
+
+PREREQUISITES
+-------------
+
+You need GHC 6.6 or above plus the packages listed at
+http://software.complete.org/missingh/wiki/RelatedSoftware#RequisiteLibraries
+
+INSTALLATION
+------------
+
+Before doing anything, open up a command prompt and cd into the
+top-level missingh directory.
+
+Now, run the script to build the program:
+
+ winbuild
+
+To install, run:
+
+ setup install
+
+To compile and run the unit tests, run:
+
+ wintest
+
+(More to come in this file)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9920ea8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,84 @@
+# arch-tag: Main Makefile
+# Copyright (C) 2004 - 2005 John Goerzen <jgoerzen at complete.org>
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+PROJECT := MissingH
+GHCPARMS := -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -cpp
+
+.PHONY: all hugsbuild
+all: setup # GHC build
+ ./setup configure
+ ./setup build
+
+hugsbuild: setup
+ ./setup configure --hugs
+ ./setup build
+
+setup: Setup.hs $(PROJECT).cabal
+ ghc -package Cabal Setup.hs -o setup
+
+doctmp/%.hs: %.lhs doctmp
+ mkdir -p `dirname $@`
+ $(UNLIT) $< $@
+
+doctmp:
+ mkdir doctmp
+
+.PHONY: doc
+doc: $(LHSCONVSOURCES) setup
+ -rm -rf html
+ ./setup configure
+ ./setup haddock
+# haddock $(HADDOCKARGS) --package=$(PROJECT) \
+# --dump-interface=html/$(PROJECT).haddock \
+# -t '$(PROJECT) API Manual' -h -o html $(HUGSCONVSOURCES) $(LHSCONVSOURCES)
+ mv dist/doc/html .
+
+.PHONY: hugsbuild
+
+
+clean:
+ -./setup clean
+ -rm -rf html `find . -name "*.o"` `find . -name "*.hi"` \
+ `find . -name "*~"` *.a setup dist testsrc/runtests \
+ local-pkg doctmp
+ -rm -rf testtmp/*
+
+.PHONY: local-pkg
+local-pkg: all
+ echo "[" > local-pkg
+ cat .installed-pkg-config >> local-pkg
+ echo "]" >> local-pkg
+
+testsrc/runtests: all $(wildcard testsrc/*.hs) $(wildcard testsrc/*/*.hs) $(wildcard testsrc/*/*/*.hs)
+ cd testsrc && ghc --make -package hslogger -package filepath -package mtl -package HUnit $(GHCPARMS) -o runtests -i../dist/build:../src runtests.hs
+
+test-ghc6: testsrc/runtests
+ testsrc/runtests
+
+test-hugs:
+ runhugs -98 +o "-Fcpphs --noline" -P$(PWD)/src:$(PWD)/testsrc: testsrc/runtests.hs
+
+interact-hugs:
+ hugs -98 +o -P$(PWD)/dist/build:
+
+interact-ghci: all
+ ghci -idist/build -Ldist/build $(GHCPARMS)
+
+interact: interact-hugs
+
+test: test-ghc6 test-hugs
+
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..cc1da80
--- /dev/null
+++ b/TODO
@@ -0,0 +1,33 @@
+Document MissingH/Quantity and see if it has tests yet
+
+Test forceEitherMsg
+
+Cmd: pOpenBoth -- read and write, use forkIO for one of them
+
+tests for new Parsec stuff
+
+HVFStest:
+ test all sorts of exceptions
+ test .. et al
+
+FTP server:
+ timeouts
+ Proper error checking lots of places, esp. runDataChan
+
+CSVtest:
+ Test CSV generation
+
+Add Quantity and ProgressTracker to README
+
+--------------------------------------------------
+From: Jeremy Shaw
+The patch to MissingH.HUnit includes a modified version of the 'tests' function
+from Test.QuickCheck. That module has the license:
+
+-- Module : Test.QuickCheck
+-- Copyright : (c) Koen Claessen, John Hughes 2001
+-- License : BSD-style (see the file libraries/base/LICENSE)
+
+If this is problematic, let me know, and I can rewrite it.
+
+j.
diff --git a/examples/simplegrep.hs b/examples/simplegrep.hs
new file mode 100644
index 0000000..a8ed2a9
--- /dev/null
+++ b/examples/simplegrep.hs
@@ -0,0 +1,6 @@
+import MissingH.List
+main = do
+ c <- getContents
+ putStr (unlines(filter (\line -> contains "Haskell" line)
+ (lines c)))
+
diff --git a/examples/test2.hs b/examples/test2.hs
new file mode 100644
index 0000000..f10dc1b
--- /dev/null
+++ b/examples/test2.hs
@@ -0,0 +1,26 @@
+-- example code 2 for socketserver
+import MissingH.Network.SocketServer
+import MissingH.IO
+import MissingH.Logging.Logger
+import Data.Char
+import System.IO
+import MissingH.Str
+
+lineInteraction :: [String] -> [String]
+lineInteraction inp =
+ let realInteract :: [String] -> [String]
+ realInteract [] = []
+ realInteract ("QUIT":_) = ["Goodbye!"]
+ realInteract ("easeregg":_) = ["Yow!"]
+ realInteract (x:xs) = map toUpper x : realInteract xs
+ in
+ ("Welcome to the uppercase server. I'll echo everything back to\n" ++
+ "you in uppercase. When done, just type \"QUIT\" to exit.\n") :
+ realInteract (map rstrip inp)
+
+realhandler h = do hLineInteract h h lineInteraction
+ hClose h
+handler = threadedHandler $ loggingHandler "main" INFO $ handleHandler $
+ realhandler
+main = do updateGlobalLogger "main" (setLevel DEBUG)
+ serveTCPforever ((simpleInetOptions 12345) {reuse = True}) handler
diff --git a/examples/test3.hs b/examples/test3.hs
new file mode 100644
index 0000000..9fee0d7
--- /dev/null
+++ b/examples/test3.hs
@@ -0,0 +1,35 @@
+-- example code 3 for socketserver
+import MissingH.Network.SocketServer
+import MissingH.IO
+import MissingH.Logging.Logger
+import Data.Char
+import System.IO
+import MissingH.Str
+import System.Time
+
+realhandler h =
+ let loop = do e <- hIsEOF h
+ if e then return ()
+ else do c <- hGetLine h
+ case (rstrip c) of
+ "QUIT" -> hPutStr h "Goodbye!\n"
+ "COMMANDS" -> do hPutStrLn h "You can type TIME for the current time"
+ loop
+ "TIME" -> do ct <- getClockTime
+ calt <- toCalendarTime ct
+ hPutStrLn h $ calendarTimeToString calt
+ loop
+ x -> do hPutStrLn h (map toUpper x)
+ loop
+ in do hPutStrLn h "Welcome to the uppercase server. I'll echo"
+ hPutStrLn h "everything back to you in uppercase. When done,"
+ hPutStrLn h "just type \"QUIT\" to exit."
+ hPutStrLn h "You can also type \"COMMANDS\" for some fun stuff."
+ hPutStrLn h ""
+ loop
+ hClose h
+
+handler = threadedHandler $ loggingHandler "main" INFO $ handleHandler $
+ realhandler
+main = do updateGlobalLogger "main" (setLevel DEBUG)
+ serveTCPforever ((simpleInetOptions 12345) {reuse = True}) handler
diff --git a/notes.txt b/notes.txt
new file mode 100644
index 0000000..833d6de
--- /dev/null
+++ b/notes.txt
@@ -0,0 +1,27 @@
+ basename p = reverse $ takeWhile (/= '/') $ reverse p
+
+ dirname p = case reverse $ dropWhile (/= '/') $ reverse p of
+ [] -> "."
+ p' -> p'
+
+--------------------------------------------------
+
+From: Mark Carroll <mark at ixod.org>
+Date: Sat, 15 Jan 2005 19:17:09 -0500 (EST)
+To: John Goerzen <jgoerzen at complete.org>
+Subject: Re: [Haskell-cafe] Re: Utility functions
+
+You can take the original, or this version, as being Copyright (c) 2004
+Mark Carroll under the modified BSD license. At the time of writing, it's
+the one at http://www.opensource.org/licenses/bsd-license.php
+
+splitListBy :: (a -> Bool) -> [a] -> [[a]]
+
+splitListBy isElement =
+ unfoldr splitter . (ignored :)
+ where
+ splitter [] = Nothing
+ splitter xs = Just (span isElement (tail xs))
+ ignored = error "internal failure in splitListBy"
+
+-- Mark
diff --git a/pending/Gopher.hs b/pending/Gopher.hs
new file mode 100644
index 0000000..3a48e17
--- /dev/null
+++ b/pending/Gopher.hs
@@ -0,0 +1,86 @@
+{- arch-tag: Gopher support
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : MissingH.Network.Gopher
+ Copyright : Copyright (C) 2004 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen,
+ Maintainer : jgoerzen at complete.org
+ Stability : experimental
+ Portability: systems with networking
+
+This module provides types and generic support for Gopher clients or serves.
+
+Related standards: RFC1436 <http://www.faqs.org/rfcs/rfc1436.html>,
+Gopher+ spec <gopher://gopher.quux.org/1/Archives/mirrors/boombox.micro.umn.edu/pub/gopher/gopher_protocol/Gopher%2B/Gopher%2B.txt>
+
+Written by John Goerzen, jgoerzen\@complete.org
+-}
+
+module MissingH.Network.Gopher (-- * Types
+ GopherEntry(..)
+ )
+ where
+
+import MissingH.Printf
+import MissingH.Str
+import Data.FiniteMap
+
+{- | Type representing an entry in a Gopher directory.
+
+May add more Gopher+ stuff in here down the road.
+
+You can show a 'GopherEntry'. This will produce a one-line string suitable
+for use on a Gopher server.
+
+You can 'read' to a 'GopherEntry'. This will parse a string as a one-line
+piece of text suitable for use generating a 'GopherEntry'.
+
+Neither show nor read will consider the 'ea' member. -}
+data GopherEntry = GopherEntry
+ {
+ selector :: String, -- ^ Path to file on server
+ gophertype :: Char, -- ^ Gopher0 type character
+ name :: String, -- ^ Gopher menu name
+ host :: String, -- ^ Content host name
+ port :: Integer, -- ^ Remote port
+ gopherpsupport :: Bool, -- ^ Whether Gopher+ is supported
+ ea :: FiniteMap String String -- ^ Gopher+ extended attributes
+ }
+
+instance Show GopherEntry where
+ show x = let basic = vsprintf "%c%s\t%s\t%s\t%d"
+ (gophertype x) (name x) (selector x) (host x)
+ (port x)
+ in if gopherpsupport x then
+ basic ++ "\t+"
+ else basic
+
+instance Read GopherEntry where
+ read s = let parts = split "\t" s
+ in
+ GopherEntry {selector = parts !! 2,
+ gophertype = head (parts !! 0),
+ name = parts !! 1,
+ host = parts !! 3,
+ port = read (parts !! 4),
+ gopherpsupport = length parts > 5 && (parts !! 5 == "+"),
+ ea = emptyFM
+ }
diff --git a/pending/Maildir.disabled b/pending/Maildir.disabled
new file mode 100644
index 0000000..192ba17
--- /dev/null
+++ b/pending/Maildir.disabled
@@ -0,0 +1,76 @@
+{-
+Copyright (C) 2005 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : MissingH.Email.Mailbox.Maildir
+ Copyright : Copyright (C) 2005 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen <jgoerzen at complete.org>
+ Stability : provisional
+ Portability: portable
+
+Support for Maildir-style mailboxes.
+
+Information about the Maildir format can be found at:
+
+ * <http://www.qmail.org/qmail-manual-html/man5/maildir.html>
+
+ * <http://cr.yp.to/proto/maildir.html>
+
+Written by John Goerzen, jgoerzen\@complete.org
+-}
+
+module MissingH.Email.Mailbox.Maildir(Maildir(..), readMaildir)
+where
+
+import MissingH.Email.Mailbox
+import System.Posix.IO(OpenMode(..))
+import System.Directory
+import MissingH.Path
+import MissingH.Maybe
+import Control.Monad
+import Text.Regex
+
+data Maildir = Maildir
+ {loc :: FilePath}
+instance Show Maildir
+ where show x = loc x
+
+{-
+splitFN :: String -> (String, Flags)
+
+splitFN fn =
+
+ where (base, fstr) =
+ case span (/= ':') of
+ (h, []) = (h, [])
+ (h, f) = (h, tail f)
+
+-}
+{- | Open a Maildir mailbox. -}
+-- For reading only, for now.
+
+openMaildir :: FilePath -> IO Maildir
+openMaildir fp =
+ do cwd <- getCurrentDirectory
+ let abspath = forceMaybeMsg "abspath readMaildir" $ absNormPath cwd fp
+ c <- getDirectoryContents fp
+ unless ("cur" `elem` c && "new" `elem` c && "tmp" `elem` c)
+ $ error (fp ++ " is not a valid Maildir.")
+ return (Maildir fp)
diff --git a/src/System/IO/PlafCompat.hs b/pending/Tar.newhs
similarity index 50%
copy from src/System/IO/PlafCompat.hs
copy to pending/Tar.newhs
index f27591f..093f516 100644
--- a/src/System/IO/PlafCompat.hs
+++ b/pending/Tar.newhs
@@ -1,5 +1,4 @@
-{-# LANGUAGE CPP #-}
-{- Platform Compatibility Layer
+{-
Copyright (C) 2005 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -18,45 +17,45 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
- Module : System.IO.PlafCompat
+ Module : MissingH.FileArchive.Tar
Copyright : Copyright (C) 2005 John Goerzen
License : GNU GPL, version 2 or above
- Maintainer : John Goerzen <jgoerzen at complete.org>
+ Maintainer : John Goerzen <jgoerzen at complete.org>
Stability : provisional
Portability: portable
-On Unix, exports System.Posix.Types and System.Posix.Files.
+Tar file format handler
-On Windows, exports System.Posix.Types and "System.IO.WindowsCompat".
-
-The result should be roughly the same set of defined variables and types.
+Copyright (c) 2005 John Goerzen, jgoerzen\@complete.org
-}
+module MissingH.FileArchive.Tar (
-module System.IO.PlafCompat
- (nullFileName,
-#if (defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
- module System.IO.WindowsCompat,
-#else
- module System.Posix.Files,
-#endif
- module System.Posix.Types)
+ )
where
-import System.Posix.Types
-#if (defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
-import System.IO.WindowsCompat
-#else
-import System.Posix.Files
-#endif
-
-{- | The name of the null device. NUL: on Windows, \/dev\/null everywhere else.
--}
+import MissingH.Checksum.CRC32.GZip
+import MissingH.List
+import Data.List
+import Data.Bits
+import Control.Monad.Error
+import Control.Monad.State
+import Data.Char
+import Data.Word
+import MissingH.Bits
+import System.IO
+import Numeric
+
+type Section = (Header, [Word8])
+
+data GZipError = CRCError -- ^ CRC-32 check failed
+ | NotGZIPFile -- ^ Couldn't find a GZip header
+ | UnknownMethod -- ^ Compressed with something other than method 8 (deflate)
+ | UnknownError String -- ^ Other problem arose
+ deriving (Eq, Show)
+
+instance Error GZipError where
+ noMsg = UnknownError ""
+ strMsg = UnknownError
-nullFileName :: String
-#if (defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
-nullFileName = "NUL:"
-#else
-nullFileName = "/dev/null"
-#endif
diff --git a/pending/Tar/HeaderParser.newhs b/pending/Tar/HeaderParser.newhs
new file mode 100644
index 0000000..67f601e
--- /dev/null
+++ b/pending/Tar/HeaderParser.newhs
@@ -0,0 +1,98 @@
+{-
+Copyright (C) 2005 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : MissingH.FileArchive.Tar.HeaderParser
+ Copyright : Copyright (C) 2005 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen <jgoerzen at complete.org>
+ Stability : provisional
+ Portability: portable
+
+Parser for tar-format headers.
+
+Copyright (c) 2005 John Goerzen, jgoerzen\@complete.org
+
+-}
+module MissingH.FileArchive.Tar.HeaderParser
+ (
+
+ )
+
+where
+
+import Text.ParserCombinators.Parsec
+import Data.Word
+import Numeric
+
+{- | The data structure representing the Tar header. This occurs
+at the beginning of each 'Section'. -}
+data Header =
+ UStar {
+ name :: String,
+ mode :: Int,
+ uid :: Int,
+ gid :: Int,
+ size :: Integer,
+ mtime :: Integer,
+ chksum :: Word32,
+ typeflag :: Char,
+ linkname :: String,
+ magic :: String,
+ version :: String,
+ uname :: String,
+ gname :: String,
+ devmajor :: Integer,
+ devminor :: Integer,
+ prefix :: String}
+ deriving (Eq, Show)
+
+parseUStarHeader :: CharParser st Header
+parseUStarHeader =
+ do name <- (grab 100 >>= rchopstr)
+ mode <- (grab 8 >>= rreadoct)
+ uid <- (grab 8 >>= rreadoct)
+ gid <- (grab 8 >>= rreadoct)
+ size <- (grab 8 >>= rreadoct)
+ mtime <- (grab 12 >>= rreadoct)
+ chksum <- (grab 8 >>= rreadoct)
+ typeflag <- anyChar
+ linkname <- (grab 100 >>= rchopstr)
+ string "ustar\0" -- Magic
+ string "00" -- Version
+ uname <- (grab 32 >>= rchopstr)
+ gname <- (grab 32 >>= rchopstr)
+ devmajor <- (grab 8 >>= rreadoct)
+ devminor <- (grab 8 >>= rreadoct)
+ prefix <- (grab 155 >>= rchopstr)
+
+ return $ UStar {name = name, mode = mode, uid = uid, gid = gid,
+ size = size, mtime = mtime, chksum = chksum,
+ typeflag = typeflag, linkname = linkname,
+ magic = "", version = "",
+ uname = uname, gname = gname, devmajor = devmajor,
+ devminor = devminor, prefix = prefix}
+ where grab n = count n anyChar
+ chopstr = takeWhile (\c -> c /= '\0')
+ rchopstr = return . chopstr
+ chopsstr = takeWhile (\c -> c /= ' ') . chopstr
+ readoct :: (Num a) => String -> a
+ readoct = fst . head . readOct . chopsstr
+ rreadoct :: (Num a, Monad m) => String -> m a
+ rreadoct = return . readoct
\ No newline at end of file
diff --git a/renameit.sh b/renameit.sh
new file mode 100644
index 0000000..6f70d62
--- /dev/null
+++ b/renameit.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+set -e
+
+OLDNAME="$1"
+NEWNAME="$2"
+
+mod2fn () {
+ echo -n "$1" | sed 's,\.,/,g'
+ echo ".hs"
+}
+
+mod2destdir () {
+ dirname "src/`mod2fn "$1"`"
+}
+
+sedname () {
+ echo "$1" | sed 's/\./\\./g'
+}
+
+OLDFN=$(mod2fn "${OLDNAME}")
+NEWFN=src/$(mod2fn "${NEWNAME}")
+NEWDIR=$(mod2destdir "${NEWNAME}")
+echo "Old module name: ${OLDNAME}"
+echo "New module name: ${NEWNAME}"
+echo "Old module file: ${OLDFN}"
+echo "New module file: ${NEWFN}"
+echo "New module dir: ${NEWDIR}"
+
+mkdir -p ${NEWDIR}
+darcs add --recursive src || true
+darcs mv ${OLDFN} ${NEWFN}
+
+for FILE in \
+ MissingH.cabal \
+ COPYRIGHT \
+ debian/copyright \
+ `find src -name "*.hs"` \
+ `find src -name "*.lhs"` \
+ `find MissingH -name "*.hs"` \
+ `find MissingH -name "*.lhs"` \
+ `find testsrc -name "*.hs"`
+do
+ sed -i "s,`sedname ${OLDNAME}`,${NEWNAME},g" $FILE
+done
+
+darcs record -am "Renamed ${OLDNAME} to ${NEWNAME}"
+
+
diff --git a/testsrc/Bitstest.hs b/testsrc/Bitstest.hs
new file mode 100644
index 0000000..bd66d0c
--- /dev/null
+++ b/testsrc/Bitstest.hs
@@ -0,0 +1,52 @@
+{- arch-tag: Bits tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Bitstest(tests) where
+import Test.HUnit
+import Data.Bits.Utils
+import Data.Word
+
+test_fromBytes =
+ let f :: [Word32] -> Word32 -> Test
+ f inp exp = TestCase $ exp @=? fromBytes inp in
+ [
+ f [] 0
+ ,f [0] 0
+ ,f [1] 1
+ ,f [0xff, 0] 0xff00
+ ,f [0x0, 0xff] 0xff
+ ,f [0x12, 0x34, 0x56, 0x78] 0x12345678
+ ,f [0xff, 0xff, 0xff, 0xff] 0xffffffff
+ ,f [0xff, 0, 0, 0] 0xff000000
+ ]
+
+test_getBytes =
+ let f :: Word32 -> [Word32] -> Test
+ f inp exp = TestCase $ exp @=? getBytes inp in
+ [
+ f 0 [0, 0, 0, 0]
+ ,f 0x1200 [0, 0, 0x12, 0]
+ ,f 0x0012 [0, 0, 0, 0x12]
+ ,f 0xffffffff [0xff, 0xff, 0xff, 0xff]
+ ,f 0x12345678 [0x12, 0x34, 0x56, 0x78]
+ ,f 0xf0000000 [0xf0, 0, 0, 0]
+ ]
+
+tests = TestList [TestLabel "getBytes" (TestList test_getBytes),
+ TestLabel "fromBytes" (TestList test_fromBytes)
+ ]
diff --git a/testsrc/CRC32GZIPtest.hs b/testsrc/CRC32GZIPtest.hs
new file mode 100644
index 0000000..4345400
--- /dev/null
+++ b/testsrc/CRC32GZIPtest.hs
@@ -0,0 +1,37 @@
+{- arch-tag: Tests for Gzip CRC-32 module
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module CRC32GZIPtest(tests) where
+import Test.HUnit
+import Data.Hash.CRC32.GZip
+
+test_crcgzip =
+ let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp (calc_crc32 inp) in
+ [f "Simple" "Test 1" 0x9927f819
+ ,f "Empty" "" 0x0
+ --f "Empty" "" 4294967295,
+ --f "1" "1" 433426081,
+ --f "some numbers" "153141341309874102987412" 2083856642,
+ --f "Some text" "This is a test of the crc32 thing\n" 2449124888
+
+ ]
+
+tests = TestList [TestLabel "crcgzip" (TestList test_crcgzip)
+
+ ]
+
diff --git a/testsrc/runtests.hs b/testsrc/CRC32POSIXtest.hs
similarity index 60%
copy from testsrc/runtests.hs
copy to testsrc/CRC32POSIXtest.hs
index 68700ca..394ef84 100644
--- a/testsrc/runtests.hs
+++ b/testsrc/CRC32POSIXtest.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Test runner
+{- arch-tag: Tests for CRC-32 module
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -16,10 +16,21 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
-module Main where
-
+module CRC32POSIXtest(tests) where
import Test.HUnit
-import Tests
+import Data.Hash.CRC32.Posix
+
+test_crc32 =
+ let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp (crc32 inp) in
+ [
+ f "Empty" "" 4294967295,
+ f "1" "1" 433426081,
+ f "some numbers" "153141341309874102987412" 2083856642,
+ f "Some text" "This is a test of the crc32 thing\n" 2449124888
+
+ ]
+
+tests = TestList [TestLabel "crc32" (TestList test_crc32)
-main = runTestTT tests
+ ]
diff --git a/testsrc/Eithertest.hs b/testsrc/Eithertest.hs
new file mode 100644
index 0000000..3d0eb32
--- /dev/null
+++ b/testsrc/Eithertest.hs
@@ -0,0 +1,51 @@
+{- arch-tag: Data.Either.Utils tests
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Eithertest(tests) where
+import Test.HUnit
+import Data.Either.Utils
+import Test.HUnit.Tools
+import Control.Exception
+
+instance Eq ErrorCall where
+ (ErrorCall x) == (ErrorCall y) = x == y
+
+test_maybeToEither =
+ let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp inp in
+ [
+ f "Nothing" (maybeToEither "error" (Nothing::Maybe String))
+ (Left "error"),
+ f "Nothing diff types" (maybeToEither "error" (Nothing::Maybe Int))
+ (Left "error"),
+ f "Just" (maybeToEither "error" (Just "good")) (Right "good"),
+ f "Diff types" (maybeToEither "error" (Just (5::Int)))
+ (Right (5::Int))
+ ]
+
+test_forceEither =
+ let f msg inp exp = TestLabel msg $ TestCase $ assertEqual "" exp inp in
+ [
+ f "Right" (forceEither ((Right "foo")::Either Int String)) "foo",
+ TestLabel "Left" $ TestCase $ assertRaises "" (ErrorCall "\"wrong\"")
+ ("" @=? forceEither (Left "wrong"))
+ ]
+
+tests = TestList [TestLabel "test_maybeToEither" (TestList test_maybeToEither),
+ TestLabel "test_forceEither" (TestList test_forceEither)
+ ]
+
diff --git a/testsrc/GZiptest.hs b/testsrc/GZiptest.hs
new file mode 100644
index 0000000..eabac89
--- /dev/null
+++ b/testsrc/GZiptest.hs
@@ -0,0 +1,99 @@
+{- arch-tag: Tests for GZip module
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module GZiptest(tests) where
+import Test.HUnit
+import System.FileArchive.GZip
+import System.FilePath
+import Data.Compression.Inflate
+import System.IO.Binary
+import System.IO
+import Data.Either.Utils
+import Data.List
+
+mf fn exp conf = TestLabel fn $ TestCase $
+ do c <- readBinaryFile $
+ joinPath ["testsrc", "gzfiles", fn]
+ assertEqual "" exp (conf c)
+
+{-
+import System.FileArchive.GZip
+import System.IO
+import Data.Either.Utils
+
+main = do
+ c <- hGetContents stdin
+ let x = snd . forceEither . read_header $ c
+ putStr x
+
+test_bunches =
+ let f fn exp conv = mf fn exp (conv . snd . forceEither . read_header)
+ f2 c = let fn = "t/z" ++ (show c) ++ ".gz" in
+ f fn c (length . inflate_string)
+ in
+ map f2 [0..1000]
+-}
+test_inflate =
+ let f fn exp conv = mf fn exp (conv . snd . forceEither . read_header) in
+ [
+ f "t1.gz" "Test 1" inflate_string
+ ,f "t1.gz" 6 (length . inflate_string)
+ ,f "t1.gz" ("Test 1",
+ "\x19\xf8\x27\x99\x06\x00\x00\x00") inflate_string_remainder
+ ,f "empty.gz" "" inflate_string
+ --,f "zeros.gz" 10485760 (length . inflate_string)
+ -- BAD BAD ,f "zeros.gz" (replicate (10 * 1048576) '\0') inflate_string
+ -- This line tests Igloo's code:
+ --,f "zeros.gz" True (\x -> (replicate 10485760 '\0') == inflate_string x)
+ ]
+
+test_header =
+ let f fn exp = mf fn exp (fst . forceEither . read_header)
+ in
+ [
+ f "t1.gz" Header {method = 8, flags = 0, extra = Nothing,
+ filename = Nothing, comment = Nothing,
+ mtime = 1102111446, xfl = 2, os = 3}
+ ,f "empty.gz" Header {method = 8, flags = 8, extra = Nothing,
+ filename = Just "empty",
+ comment = Nothing,
+ mtime = 1102127257, xfl = 0, os = 3}
+ ]
+
+test_gunzip =
+ let f fn exp = mf fn exp decompress
+ in
+ [
+ f "t1.gz" ("Test 1", Nothing)
+ ,f "t1bad.gz" ("Test 1", Just CRCError)
+ ,f "t2.gz" ("Test 1Test 2", Nothing)
+ -- The following tests my code
+ {-
+ ,mf "zeros.gz" True (\x -> case decompress x of
+ (y, _) -> y == replicate 10485760 '\0'
+ )
+ -}
+ ]
+
+tests = TestList [TestLabel "inflate" (TestList test_inflate),
+ TestLabel "header" (TestList test_header),
+-- TestLabel "bunches" (TestList test_bunches),
+ TestLabel "gunzip" (TestList test_gunzip)
+
+ ]
+
diff --git a/testsrc/Globtest.hs b/testsrc/Globtest.hs
new file mode 100644
index 0000000..d254032
--- /dev/null
+++ b/testsrc/Globtest.hs
@@ -0,0 +1,113 @@
+{-
+Copyright (C) 2006 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+
+module Globtest(tests) where
+import Test.HUnit
+import System.Path.Glob
+import System.Path
+import Test.HUnit.Tools
+import System.IO.HVFS
+import System.Directory(createDirectory)
+#if !(defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
+import System.Posix.Directory hiding (createDirectory)
+import System.Posix.Files
+#endif
+import Control.Exception
+import Data.List
+
+bp = "testtmp"
+touch x = writeFile x ""
+
+globtest thetest =
+ bracket_ (setupfs)
+ (recursiveRemove SystemFS bp)
+ thetest
+ where setupfs =
+ do mapM_ (\x -> createDirectory x)
+ [bp, bp ++ "/a", bp ++ "/aab", bp ++ "/aaa",
+ bp ++ "/ZZZ", bp ++ "/a/bcd",
+ bp ++ "/a/bcd/efg"]
+ mapM_ touch [bp ++ "/a/D", bp ++ "/aab/F", bp ++ "/aaa/zzzF",
+ bp ++ "/a/bcd/EF", bp ++ "/a/bcd/efg/ha",
+ bp ++ "/a/foo", bp ++ "/a/afoo",
+ bp ++ "/a/a-foo", bp ++ "/a/a.foo"]
+#if !(defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
+ createSymbolicLink (preppath "broken") (preppath "sym1")
+ createSymbolicLink (preppath "broken") (preppath "sym2")
+#endif
+
+eq msg exp res =
+ assertEqual msg (sort exp) (sort res)
+mf msg func = TestLabel msg $ TestCase $ globtest func
+f func = TestCase $ globtest func
+preppath x = bp ++ "/" ++ x
+
+test_literal =
+ map f
+ [glob (preppath "a") >>= eq "" [preppath "a"]
+ ,glob (preppath "a/D") >>= eq "" [preppath "a/D"]
+ ,glob (preppath "aab") >>= eq "" [preppath "aab"]
+ ,glob (preppath "nonexistant") >>= eq "empty" []
+ ]
+
+test_one_dir =
+ map f
+ [glob (preppath "a*") >>= eq "a*" (map preppath ["a", "aab", "aaa"]),
+ glob (preppath "*a") >>= eq "*a" (map preppath ["a", "aaa"]),
+ glob (preppath "aa?") >>= eq "aa?" (map preppath ["aaa", "aab"]),
+ glob (preppath "aa[ab]") >>= eq "aa[ab]" (map preppath ["aaa", "aab"]),
+ glob (preppath "*q") >>= eq "*q" []
+ ]
+
+test_nested_dir =
+ map f
+ [glob (preppath "a/bcd/E*") >>= eq "a/bcd/E*" [preppath "a/bcd/EF"],
+ glob (preppath "a/bcd/*g") >>= eq "a/bcd/*g" [preppath "a/bcd/efg"],
+ glob (preppath "a/*.foo") >>= eq "a/*.foo" [preppath "a/a.foo"]
+ ]
+
+test_dirnames =
+ map f
+ [glob (preppath "*/D") >>= eq "*/D" [preppath "a/D"],
+ glob (preppath "*/*a") >>= eq "*/*a" [],
+ glob (preppath "a/*/*/*a") >>= eq "a/*/*/*a" [preppath "a/bcd/efg/ha"],
+ glob (preppath "?a?/*F") >>= eq "?a?/*F" (map preppath ["aaa/zzzF", "aab/F"])
+ ]
+
+test_brokensymlinks =
+#if !(defined(mingw32_HOST_OS) || defined(mingw32_TARGET_OS) || defined(__MINGW32__))
+ map f
+ [glob (preppath "sym*") >>= eq "sym*" (map preppath ["sym1", "sym2"]),
+ glob (preppath "sym1") >>= eq "sym1" [preppath "sym1"],
+ glob (preppath "sym2") >>= eq "sym2" [preppath "sym2"]
+ ]
+#else
+ []
+#endif
+
+
+tests = TestList [TestLabel "test_literal" (TestList test_literal),
+ TestLabel "test_one_dir" (TestList test_one_dir),
+ TestLabel "test_nested_dir" (TestList test_nested_dir),
+ TestLabel "test_dirnames" (TestList test_dirnames),
+ TestLabel "test_brokensymlinks" (TestList test_brokensymlinks)]
+
+
+
+
diff --git a/testsrc/HVFStest.hs b/testsrc/HVFStest.hs
new file mode 100644
index 0000000..bd242d6
--- /dev/null
+++ b/testsrc/HVFStest.hs
@@ -0,0 +1,126 @@
+{- arch-tag: HVFS tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module HVFStest(tests) where
+import Test.HUnit
+import System.IO.HVIO
+import System.IO.HVFS
+import System.IO.HVFS.InstanceHelpers
+import System.IO.HVFS.Combinators
+import Test.HUnit.Tools
+import System.IO
+import System.IO.Error
+import Control.Exception
+
+ioeq :: (Show a, Eq a) => a -> IO a -> Assertion
+ioeq exp inp = do x <- inp
+ exp @=? x
+
+testTree = [("test.txt", MemoryFile "line1\nline2\n"),
+ ("file2.txt", MemoryFile "line3\nline4\n"),
+ ("emptydir", MemoryDirectory []),
+ ("dir1", MemoryDirectory
+ [("file3.txt", MemoryFile "line5\n"),
+ ("test.txt", MemoryFile "subdir test"),
+ ("dir2", MemoryDirectory [])
+ ]
+ )
+ ]
+
+test_nice_slice =
+ let f exp fp = TestLabel fp $ TestCase $ exp @=? nice_slice fp
+ in [
+ f [] "/"
+ ,f ["foo", "bar"] "/foo/bar"
+ --,f [] "."
+ ]
+
+test_content =
+ let f exp fp = TestLabel fp $ TestCase $
+ do x <- newMemoryVFS testTree
+ h <- vOpen x fp ReadMode
+ case h of
+ HVFSOpenEncap h2 -> exp `ioeq` vGetContents h2
+ in
+ [
+ f "line1\nline2\n" "test.txt",
+ f "line1\nline2\n" "/test.txt",
+ f "line5\n" "dir1/file3.txt",
+ f "subdir test" "/dir1/test.txt"
+ ]
+
+test_chroot =
+ let f msg testfunc = TestLabel msg $ TestCase $
+ do x <- newMemoryVFS testTree
+ vSetCurrentDirectory x "/emptydir"
+ y <- newHVFSChroot x "/dir1"
+ testfunc y
+ in
+ [
+ f "root" (\x -> ["file3.txt", "test.txt", "dir2"]
+ `ioeq` vGetDirectoryContents x "/")
+ ,f "cwd" (\x -> "/" `ioeq` vGetCurrentDirectory x)
+ ,f "dir2" (\x -> [] `ioeq` vGetDirectoryContents x "/dir2")
+ ,f "dot" (\x -> ["file3.txt", "test.txt", "dir2"]
+ `ioeq` vGetDirectoryContents x ".")
+ ,f "cwd tests" $
+ (\x -> do a <- vGetDirectoryContents x "/"
+ ["file3.txt", "test.txt", "dir2"] @=? a
+ vSetCurrentDirectory x "/dir2"
+ cwd <- vGetCurrentDirectory x
+ "/dir2" @=? cwd
+ y <- vGetDirectoryContents x "."
+ [] @=? y
+ vSetCurrentDirectory x ".."
+ "/" `ioeq` vGetCurrentDirectory x
+ --vSetCurrentDirectory x ".."
+ --"/" `ioeq` vGetCurrentDirectory x
+ )
+ --,f "test.txt" (\x -> "subdir test" `ioeq`
+ -- (vOpen x "/test.txt" ReadMode >>= vGetContents))
+ ]
+
+
+test_structure =
+ let f msg testfunc = TestLabel msg $ TestCase $ do x <- newMemoryVFS testTree
+ testfunc x
+ in
+ [
+ f "root" (\x -> ["test.txt", "file2.txt", "emptydir", "dir1"]
+ `ioeq` vGetDirectoryContents x "/")
+ ,f "dot" (\x -> ["test.txt", "file2.txt", "emptydir", "dir1"]
+ `ioeq` vGetDirectoryContents x ".")
+ ,f "dot2" (\x -> ["file3.txt", "test.txt", "dir2"]
+ `ioeq` do vSetCurrentDirectory x "./dir1"
+ vGetDirectoryContents x ".")
+ ,f "emptydir" (\x -> [] `ioeq` vGetDirectoryContents x "/emptydir")
+ ,f "dir1" (\x -> ["file3.txt", "test.txt", "dir2"] `ioeq`
+ vGetDirectoryContents x "/dir1")
+ ,f "dir1/dir2" (\x -> [] `ioeq` vGetDirectoryContents x "/dir1/dir2")
+ ,f "relative tests" (\x ->
+ do vSetCurrentDirectory x "dir1"
+ [] `ioeq` vGetDirectoryContents x "dir2"
+ )
+ ]
+
+
+tests = TestList [TestLabel "nice_slice" (TestList test_nice_slice)
+ ,TestLabel "structure" (TestList test_structure)
+ ,TestLabel "content" (TestList test_content)
+ ,TestLabel "chroot" (TestList test_chroot)
+ ]
diff --git a/testsrc/HVIOtest.hs b/testsrc/HVIOtest.hs
new file mode 100644
index 0000000..bfd09fd
--- /dev/null
+++ b/testsrc/HVIOtest.hs
@@ -0,0 +1,95 @@
+{- arch-tag: HVIO tests main file
+Copyright (C) 2004-2009 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module HVIOtest(tests) where
+import Test.HUnit
+import System.IO.HVIO
+import Test.HUnit.Tools
+import System.IO
+import System.IO.Error
+import Control.Exception
+
+ioeq :: (Show a, Eq a) => a -> IO a -> Assertion
+ioeq exp inp = do x <- inp
+ exp @=? x
+
+test_MemoryBuffer =
+ let f inp testfunc = TestLabel inp $ TestCase $ do x <- newMemoryBuffer inp mbDefaultCloseFunc
+ testfunc x
+ in
+ [
+ f "" (\x -> do True `ioeq` vIsOpen x
+ assertRaises "eof error" (mkIOError eofErrorType "" Nothing Nothing) (vGetChar x)
+ vPutStrLn x "Line1"
+ vPutStrLn x "Line2"
+ vRewind x
+ "Line1" `ioeq` vGetLine x
+ "Line2" `ioeq` vGetLine x
+ 12 `ioeq` vTell x
+ vSeek x AbsoluteSeek 1
+ "ine1" `ioeq` vGetLine x
+ vSeek x RelativeSeek (-3)
+ "e1" `ioeq` vGetLine x
+ vSeek x SeekFromEnd (-3)
+ "e2" `ioeq` vGetLine x
+ vSeek x AbsoluteSeek 1
+ vPutStr x "IN"
+ vRewind x
+ "LINe1" `ioeq` vGetLine x
+ "Line2" `ioeq` vGetLine x
+ vSeek x SeekFromEnd 0
+ vPutChar x 'c'
+ assertRaises "eof error" (mkIOError eofErrorType "" Nothing Nothing) (vGetLine x)
+ vRewind x
+ "LINe1\nLine2\nc" `ioeq` vGetContents x
+ )
+ ]
+
+test_StreamReader =
+ let f inp testfunc = TestLabel inp $ TestCase $ do x <- newStreamReader inp
+ testfunc x
+ in
+ [
+ f "" (\x -> do True `ioeq` vIsEOF x
+ True `ioeq` vIsOpen x
+ assertRaises "eof error" (mkIOError eofErrorType "" Nothing Nothing) (vGetChar x)
+ vClose x
+ False `ioeq` vIsOpen x
+
+ )
+ ,f "abcd" (\x -> do False `ioeq` vIsEOF x
+ True `ioeq` vIsOpen x
+ 'a' `ioeq` vGetChar x
+ "bcd" `ioeq` vGetContents x
+ vClose x
+ )
+ ,f "line1\nline2\n\n\nline5\nlastline"
+ (\x -> do False `ioeq` vIsEOF x
+ "line1" `ioeq` vGetLine x
+ "line2" `ioeq` vGetLine x
+ "" `ioeq` vGetLine x
+ "" `ioeq` vGetLine x
+ "line5" `ioeq` vGetLine x
+ "lastline" `ioeq` vGetLine x
+ assertRaises "eof error" (mkIOError eofErrorType "" Nothing Nothing) (vGetLine x)
+ )
+ ]
+
+tests = TestList [TestLabel "streamReader" (TestList test_StreamReader),
+ TestLabel "MemoryBuffer" (TestList test_MemoryBuffer)
+ ]
diff --git a/testsrc/runtests.hs b/testsrc/IOtest.hs
similarity index 88%
copy from testsrc/runtests.hs
copy to testsrc/IOtest.hs
index 68700ca..eb71ca4 100644
--- a/testsrc/runtests.hs
+++ b/testsrc/IOtest.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Test runner
+{- arch-tag: IO tests main file
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -16,10 +16,13 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
-module Main where
-
+module IOtest() where
import Test.HUnit
-import Tests
+import System.IO
+import Test.HUnit.Tools
+
+
+
+
-main = runTestTT tests
diff --git a/testsrc/Listtest.hs b/testsrc/Listtest.hs
new file mode 100644
index 0000000..b3fd77e
--- /dev/null
+++ b/testsrc/Listtest.hs
@@ -0,0 +1,256 @@
+{- arch-tag: List tests main file
+Copyright (C) 2004-2005 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Listtest(tests) where
+import Test.HUnit
+import Data.List.Utils
+import Data.List
+import Test.HUnit
+import Test.QuickCheck as QC
+import Test.HUnit.Tools
+
+test_delFromAL =
+ let f :: [(String, Int)] -> [(String, Int)] -> Test
+ f inp exp = TestCase $ exp @=? (delFromAL inp "testkey") in
+ [
+ f [] []
+ ,f [("one", 1)] [("one", 1)]
+ ,f [("1", 1), ("2", 2), ("testkey", 3)] [("1", 1), ("2", 2)]
+ ,f [("testkey", 1)] []
+ ,f [("testkey", 1), ("testkey", 2)] []
+ ,f [("testkey", 1), ("2", 2), ("3", 3)] [("2", 2), ("3", 3)]
+ ,f [("testkey", 1), ("2", 2), ("testkey", 3), ("4", 4)]
+ [("2", 2), ("4", 4)]
+ ]
+
+test_addToAL =
+ let f :: [(String, Int)] -> [(String, Int)] -> Test
+ f inp exp = TestCase $ exp @=? (addToAL inp "testkey" 101) in
+ [
+ f [] [("testkey", 101)]
+ ,f [("testkey", 5)] [("testkey", 101)]
+ ,f [("testkey", 5), ("testkey", 6)] [("testkey", 101)]
+ ]
+
+test_split =
+ let f delim inp exp = TestCase $ exp @=? split delim inp in
+ [
+ f "," "foo,bar,,baz," ["foo", "bar", "", "baz", ""]
+ ,f "ba" ",foo,bar,,baz," [",foo,","r,,","z,"]
+ ,f "," "" []
+ ,f "," "," ["", ""]
+ ]
+
+test_join =
+ let f :: (Eq a, Show a) => [a] -> [[a]] -> [a] -> Test
+ f delim inp exp = TestCase $ exp @=? join delim inp in
+ [
+ f "|" ["foo", "bar", "baz"] "foo|bar|baz"
+ ,f "|" [] ""
+ ,f "|" ["foo"] "foo"
+ -- f 5 [[1, 2], [3, 4]] [1, 2, 5, 3, 4]
+ ]
+
+test_replace =
+ let f old new inp exp = TestCase $ exp @=? replace old new inp in
+ [
+ f "" "" "" ""
+ ,f "foo" "bar" "" ""
+ ,f "foo" "bar" "foo" "bar"
+ ,f "foo" "bar" "footestfoothisisabarfoo" "bartestbarthisisabarbar"
+ ,f "," ", " "1,2,3,4" "1, 2, 3, 4"
+ ,f "," "." "1,2,3,4" "1.2.3.4"
+ ]
+
+test_genericJoin =
+ let f delim inp exp = TestCase $ exp @=? genericJoin delim inp in
+ [
+ f ", " [1, 2, 3, 4] "1, 2, 3, 4"
+ ,f ", " ([] :: [Int]) ""
+ ,f "|" ["foo", "bar", "baz"] "\"foo\"|\"bar\"|\"baz\""
+ ,f ", " [5] "5"
+ ]
+
+test_flipAL =
+ let f inp exp = TestCase $ exp @=? flipAL inp in
+ [
+ f ([]::[(Int,Int)]) ([]::[(Int,[Int])])
+ ,f [("a", "b")] [("b", ["a"])]
+ ,f [("a", "b"),
+ ("c", "b"),
+ ("d", "e"),
+ ("b", "b")] [("b", ["b", "c", "a"]),
+ ("e", ["d"])]
+ ]
+
+test_uniq =
+ let f inp exp = TestCase $ exp @=? uniq inp in
+ [f ([]::[Int]) [],
+ f "asdf" "asdf",
+ f "aabbcc" "abc",
+ f "abcabc" "abc",
+ f "aaaaaa" "a",
+ f "aaaaaab" "ab",
+ f "111111111111111" "1",
+ f "baaaaaaaaa" "ba",
+ f "baaaaaaaaab" "ba",
+ f "aaacccdbbbefff" "acdbef",
+ f "foo" "fo",
+ f "15553344409" "153409",
+ f "Mississippi" "Misp"]
+
+test_trunc =
+ let f len inp exp = TestCase $ exp @=? take len inp in
+ [
+ f 2 "Hello" "He"
+ ,f 1 "Hello" "H"
+ ,f 0 "Hello" ""
+ ,f 2 "H" "H"
+ ,f 2 "" ""
+ ,f 2 [1, 2, 3, 4, 5] [1, 2]
+ ,f 10 "Hello" "Hello"
+ ,f 0 "" ""
+ ]
+
+test_contains =
+ let f msg sub testlist exp = TestCase $ assertEqual msg exp (contains sub testlist) in
+ [
+ f "t1" "Haskell" "I really like Haskell." True
+ ,f "t2" "" "Foo" True
+ ,f "t3" "" "" True
+ ,f "t4" "Hello" "" False
+ ,f "t5" "Haskell" "Haskell" True
+ ,f "t6" "Haskell" "1Haskell" True
+ ,f "t7" "Haskell" "Haskell1" True
+ ,f "t8" "Haskell" "Ocaml" False
+ ,f "t9" "Haskell" "OCamlasfasfasdfasfd" False
+ ,f "t10" "a" "Hello" False
+ ,f "t11" "e" "Hello" True
+ ]
+
+test_elemRIndex =
+ let f item inp exp = TestCase $ exp @=? elemRIndex item inp in
+ [
+ f "foo" [] Nothing
+ ,f "foo" ["bar", "baz"] Nothing
+ ,f "foo" ["foo"] (Just 0)
+ ,f "foo" ["foo", "bar"] (Just 0)
+ ,f "foo" ["bar", "foo"] (Just 1)
+ ,f "foo" ["foo", "bar", "foo", "bar", "foo"] (Just 4)
+ ,f 'f' ['f', 'b', 'f', 'f', 'b'] (Just 3)
+ ,f 'f' ['b', 'b', 'f'] (Just 2)
+ ]
+
+test_alwaysElemRIndex =
+ let f item inp exp = TestCase $ exp @=? alwaysElemRIndex item inp in
+ [
+ f "foo" [] (-1)
+ ,f 'f' ['b', 'q'] (-1)
+ ,f 'f' ['f', 'b', 'f', 'f', 'b'] 3
+ ]
+
+test_subIndex =
+ let f item inp exp = TestCase $ exp @=? subIndex item inp in
+ [f "foo" "asdfoobar" (Just 3)
+ ,f "foo" [] (Nothing)
+ ,f "" [] (Just 0)
+ ,f "" "asdf" (Just 0)
+ ,f "test" "asdftestbartest" (Just 4)
+ ,f [(1::Int), 2] [0, 5, 3, 2, 1, 2, 4] (Just 4)
+ ]
+
+test_fixedWidth =
+ let f inplen inplist exp = TestLabel ((show inplen) ++ ", " ++
+ (show inplist)) $ TestCase $
+ wholeMap (fixedWidth inplen) inplist @=? exp in
+ [
+ f [] ([]::[Int]) ([]::[[Int]])
+ ,f [1] [5] [[5]]
+ ,f [1] [3, 4, 5, 6] [[3], [4, 5, 6]]
+ ,f [1] ([]::[Int]) ([]::[[Int]])
+ ,f [2] [3] [[3]]
+ ,f [2] [3, 4, 5, 6] [[3, 4], [5, 6]]
+ ,f [2] [3, 4, 5] [[3, 4], [5]]
+ ,f [1, 2, 3] "1234567890" ["1","23","456","7890"]
+ ,f (repeat 2) "123456789" ["12","34","56","78","9"]
+ ,f [] "123456789" ["123456789"]
+ ,f [5, 3, 6, 1] "Hello, This is a test."
+ ["Hello",", T","his is"," ","a test."]
+ ]
+
+test_strToAL =
+ let f inp exp = TestLabel (show inp) $ TestCase $ do let r = strFromAL inp
+ exp @=? r
+ inp @=? strToAL r
+ in
+ [
+ f ([]::[(String, String)]) ""
+ ,f [("foo", "bar")] "\"foo\",\"bar\"\n"
+ ,f [("foo", "bar"), ("baz", "quux")] "\"foo\",\"bar\"\n\"baz\",\"quux\"\n"
+ ,f [(1::Int, 2::Int), (3, 4)] "1,2\n3,4\n"
+ ,f [(1::Int, "one"), (2, "two")] "1,\"one\"\n2,\"two\"\n"
+ ,f [("one", 1::Double), ("n\nl", 2::Double)]
+ "\"one\",1.0\n\"n\\nl\",2.0\n"
+ ]
+
+test_spanList =
+ let f func inp exp = TestLabel (show inp) $ TestCase $ exp @=? spanList func inp
+ in
+ [f (contains "foo") "Testfoobar" ("Testf", "oobar"),
+ f (\_ -> True) "Testasdf" ("Testasdf", ""),
+ f (\_ -> False) "Testasdf" ("", "Testasdf"),
+ f (contains "foo") "" ("", ""),
+ f (contains "foo") "foo" ("f", "oo")]
+
+
+test_merge =
+ qctest "prop_merge" prop_merge
+
+prop_merge xs ys =
+ merge (sort xs) (sort ys) == sort (xs ++ ys)
+ where types = xs :: [Int]
+
+test_mergeBy =
+ qctest "test_mergeBy" prop_mergeBy
+
+prop_mergeBy xs ys =
+ mergeBy cmp (sortBy cmp xs) (sortBy cmp ys) == sortBy cmp (xs ++ ys)
+ where types = xs :: [Int]
+ cmp = compare
+
+tests = TestList [test_merge,
+ test_mergeBy,
+ TestLabel "delFromAL" (TestList test_delFromAL),
+ TestLabel "uniq" (TestList test_uniq),
+ TestLabel "addToAL" (TestList test_addToAL),
+ TestLabel "split" (TestList test_split),
+ TestLabel "join" (TestList test_join),
+ TestLabel "genericJoin" (TestList test_genericJoin),
+ TestLabel "trunc" (TestList test_trunc),
+ TestLabel "flipAL" (TestList test_flipAL),
+ TestLabel "elemRIndex" (TestList test_elemRIndex),
+ TestLabel "alwaysElemRIndex" (TestList test_alwaysElemRIndex),
+ TestLabel "replace" (TestList test_replace),
+ TestLabel "contains" (TestList test_contains),
+ TestLabel "strFromAL & strToAL" (TestList test_strToAL),
+ TestLabel "fixedWidth" (TestList test_fixedWidth),
+ TestLabel "subIndex" (TestList test_subIndex),
+ TestLabel "spanList" (TestList test_spanList)]
+
+
+
diff --git a/testsrc/MIMETypestest.hs b/testsrc/MIMETypestest.hs
new file mode 100644
index 0000000..be6416d
--- /dev/null
+++ b/testsrc/MIMETypestest.hs
@@ -0,0 +1,75 @@
+{- arch-tag: MIMETypes tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module MIMETypestest(tests) where
+import Test.HUnit
+import Data.List
+import Data.MIME.Types
+
+test_readMIMETypes =
+ let omtd = readMIMETypes defaultmtd True "testsrc/mime.types.test"
+ f = \strict inp exp -> TestCase $ do
+ mtd <- omtd
+ exp @=? guessType mtd strict inp
+ fe = \strict inp exp -> TestCase $ do mtd <- omtd
+ (sort exp) @=? sort (guessAllExtensions mtd strict inp)
+ in [
+ f True "foo.bar.baz" (Nothing, Nothing)
+ ,f True "" (Nothing, Nothing)
+ ,f True "foo.ez" (Just "application/andrew-inset", Nothing)
+ ,fe True "application/andrew-inset" [".ez"]
+ ,f True "foo.dv" (Just "video/x-dv", Nothing)
+ ,fe True "video/x-dv" [".dif", ".dv"]
+ ,f True "test.h++" (Just "text/x-c++hdr", Nothing)
+ ,fe True "text/x-c++hdr" [".h++", ".hpp", ".hxx", ".hh"]
+ ,f True "foo.tgz" (Just "application/x-tar", Just "gzip")
+ ]
+
+
+test_guessAllExtensions =
+ let f strict inp exp = TestCase $ (sort exp) @=? sort (guessAllExtensions defaultmtd strict inp) in
+ [
+ f True "" []
+ ,f True "foo" []
+ ,f True "application/octet-stream" [".obj", ".so", ".bin", ".a", ".dll", ".exe", ".o"]
+ ,f True "text/plain" [".pl", ".ksh", ".bat", ".c", ".h", ".txt"]
+ ,f True "application/rtf" []
+ ,f False "application/rtf" [".rtf"]
+ ]
+
+test_guessType =
+ let f strict inp exp = TestCase $ exp @=? guessType defaultmtd strict inp in
+ [
+ f True "" (Nothing, Nothing)
+ ,f True "foo" (Nothing, Nothing)
+ ,f True "foo.txt" (Just "text/plain", Nothing)
+ ,f True "foo.txt.gz" (Just "text/plain", Just "gzip")
+ ,f True "foo.txt.blah" (Nothing, Nothing)
+ ,f True "foo.tar" (Just "application/x-tar", Nothing)
+ ,f True "foo.tar.gz" (Just "application/x-tar", Just "gzip")
+ ,f True "foo.tgz" (Just "application/x-tar", Just "gzip")
+ ,f True "http://foo/test.dir/blah.rtf" (Nothing, Nothing)
+ ,f False "http://foo/test.dir/blah.rtf" (Just "application/rtf", Nothing)
+ ,f True "foo.pict" (Nothing, Nothing)
+ ,f False "foo.pict" (Just "image/pict", Nothing)
+ ]
+
+tests = TestList [TestLabel "guessType" (TestList test_guessType),
+ TestLabel "guessAllExtensions" (TestList test_guessAllExtensions),
+ TestLabel "readMIMETypes" (TestList test_readMIMETypes)
+ ]
diff --git a/testsrc/Maptest.hs b/testsrc/Maptest.hs
new file mode 100644
index 0000000..4f102cf
--- /dev/null
+++ b/testsrc/Maptest.hs
@@ -0,0 +1,47 @@
+{-
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Maptest(tests) where
+import Test.HUnit
+import Data.Map.Utils
+import Data.Map as M
+
+test_flipM =
+ let f inp exp = TestCase $ (M.fromList exp) @=? flipM (M.fromList inp) in
+ [
+ f ([]::[(Int,Int)]) ([]::[(Int,[Int])])
+ ,f [("a", "b")] [("b", ["a"])]
+ ,f [("a", "b"),
+ ("c", "b"),
+ ("d", "e"),
+ ("b", "b")] [("b", ["c", "b", "a"]),
+ ("e", ["d"])]
+ ]
+
+test_flippedLookupM =
+ let f item inp exp = TestCase $ exp @=? flippedLookupM item (M.fromList inp) in
+ [
+ f 'a' ([]::[(Char, Char)]) []
+ ,f 'a' [("Test1", 'a'), ("Test2", 'b')] ["Test1"]
+ ,f 'a' [("Test1", 'b'), ("Test2", 'b')] []
+ ,f 'a' [("Test1", 'a'), ("Test2", 'a')] ["Test2", "Test1"]
+ ]
+
+tests = TestList [TestLabel "flipM" (TestList test_flipM),
+ TestLabel "flippedLookupM" (TestList test_flippedLookupM)
+ ]
diff --git a/testsrc/Pathtest.hs b/testsrc/Pathtest.hs
new file mode 100644
index 0000000..7da2aa3
--- /dev/null
+++ b/testsrc/Pathtest.hs
@@ -0,0 +1,77 @@
+{- arch-tag: Path tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Pathtest(tests) where
+import Test.HUnit
+import System.Path
+
+test_absNormPath =
+ let f base p exp = TestLabel (show (base, p)) $ TestCase $ exp @=? absNormPath base p
+ f2 = f "/usr/1/2" in
+ [
+ f "/" "" (Just "/")
+ ,f "/usr/test" "" (Just "/usr/test")
+ ,f "/usr/test" ".." (Just "/usr")
+ ,f "/usr/1/2" "/foo/bar" (Just "/foo/bar")
+ ,f2 "jack/./.." (Just "/usr/1/2")
+ ,f2 "jack///../foo" (Just "/usr/1/2/foo")
+ ,f2 "../bar" (Just "/usr/1/bar")
+ ,f2 "../" (Just "/usr/1")
+ ,f2 "../.." (Just "/usr")
+ ,f2 "../../" (Just "/usr")
+ ,f2 "../../.." (Just "/")
+ ,f2 "../../../" (Just "/")
+ ,f2 "../../../.." Nothing
+ ]
+
+test_secureAbsNormPath =
+ let f base p exp = TestLabel (show (base, p)) $ TestCase $ exp @=? secureAbsNormPath base p
+ f2 = f "/usr/1/2" in
+ [
+ f "/" "" (Just "/")
+ ,f "/usr/test" "" (Just "/usr/test")
+ ,f "/usr/test" ".." Nothing
+ ,f "/usr/1/2" "/foo/bar" Nothing
+ ,f "/usr/1/2" "/usr/1/2" (Just "/usr/1/2")
+ ,f "/usr/1/2" "/usr/1/2/foo/bar" (Just "/usr/1/2/foo/bar")
+ ,f2 "jack/./.." (Just "/usr/1/2")
+ ,f2 "jack///../foo" (Just "/usr/1/2/foo")
+ ,f2 "../bar" Nothing
+ ,f2 "../" Nothing
+ ,f2 "../.." Nothing
+ ,f2 "../../" Nothing
+ ,f2 "../../.." Nothing
+ ,f2 "../../../" Nothing
+ ,f2 "../../../.." Nothing
+ ]
+
+test_splitExt =
+ let f inp exp = TestCase $ exp @=? splitExt inp in
+ [
+ f "" ("", "")
+ ,f "/usr/local" ("/usr/local", "")
+ ,f "../foo.txt" ("../foo", ".txt")
+ ,f "../bar.txt.gz" ("../bar.txt", ".gz")
+ ,f "foo.txt/bar" ("foo.txt/bar", "")
+ ,f "foo.txt/bar.bz" ("foo.txt/bar", ".bz")
+ ]
+
+tests = TestList [TestLabel "splitExt" (TestList test_splitExt)
+ ,TestLabel "absNormPath" (TestList test_absNormPath)
+ ,TestLabel "secureAbsNormPath" (TestList test_secureAbsNormPath)
+ ]
diff --git a/testsrc/ProgressTrackertest.hs b/testsrc/ProgressTrackertest.hs
new file mode 100644
index 0000000..56157da
--- /dev/null
+++ b/testsrc/ProgressTrackertest.hs
@@ -0,0 +1,144 @@
+{-
+Copyright (C) 2006 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module ProgressTrackertest(tests) where
+import Data.Progress.Tracker
+import Test.HUnit
+import Control.Concurrent.MVar
+
+setup =
+ do timem <- newMVar 0
+ let timesource = readMVar timem
+ po <- newProgress' (ProgressStatus 0 100 0 "" timesource) []
+ return (po, timem)
+
+settime timem newval = swapMVar timem newval >> return ()
+
+test_incrP =
+ do (po, timem) <- setup
+ incrP po 5
+ withStatus po $ \s ->
+ do assertEqual "completedUnits" 5 (completedUnits s)
+ assertEqual "totalUnits" 100 (totalUnits s)
+ incrP po 95
+ withStatus po $ \s ->
+ do assertEqual "completedUnits" 100 (completedUnits s)
+ assertEqual "totalUnits" 100 (totalUnits s)
+ incrP po 5
+ withStatus po $ \s ->
+ do assertEqual "completedUnits" 105 (completedUnits s)
+ assertEqual "totalUnits" 105 (totalUnits s)
+ incrP' po 5
+ withStatus po $ \s ->
+ do assertEqual "completedUnits" 110 (completedUnits s)
+ assertEqual "totalUnits" 105 (totalUnits s)
+ incrTotal po 10
+ withStatus po $ \s ->
+ do 110 @=? completedUnits s
+ 115 @=? totalUnits s
+
+test_setP =
+ do (po, timem) <- setup
+ setP po 5
+ withStatus po $ \s ->
+ do 5 @=? completedUnits s
+ 100 @=? totalUnits s
+ setP po 100
+ withStatus po $ \s ->
+ do 100 @=? completedUnits s
+ 100 @=? totalUnits s
+ setP po 105
+ withStatus po $ \s ->
+ do 105 @=? completedUnits s
+ 105 @=? totalUnits s
+ setP' po 110
+ withStatus po $ \s ->
+ do 110 @=? completedUnits s
+ 105 @=? totalUnits s
+ setTotal po 115
+ withStatus po $ \s ->
+ do 110 @=? completedUnits s
+ 115 @=? totalUnits s
+
+test_speed =
+ do (po, timem) <- setup
+ getSpeed po >>= assertEqual "initial speed" 0
+ getETR po >>= assertEqual "initial ETR" 0
+ getETA po >>= assertEqual "initial ETA" 0
+
+ incrP po 10
+ getSpeed po >>= assertEqual "speed after incr" 0
+ getETR po >>= assertEqual "ETR after incr" 0
+ getETA po >>= assertEqual "ETA after incr" 0
+
+ settime timem 5
+ getSpeed po >>= assertEqual "first speed" 2.0
+ getETR po >>= assertEqual "first ETR" 45
+ getETA po >>= assertEqual "first ETA" 50
+
+ incrP po 90
+ getSpeed po >>= assertEqual "speed 2" 20.0
+ getETR po >>= assertEqual "etr 2" 0
+ getETA po >>= assertEqual "eta 2" 5
+
+ settime timem 400
+ setP po 90
+ getSpeed po >>= assertEqual "speed 3" 0.225
+ getETR po >>= assertEqual "etr 2" 44
+ getETA po >>= assertEqual "eta 2" 444
+
+test_callback =
+ do (po, _) <- setup
+ mcounter <- newMVar (0::Int)
+ mcounter1 <- newMVar (0::Int)
+ mcounter2 <- newMVar (0::Int)
+ (po2, _) <- setup
+ (po3, _) <- setup
+
+ addCallback po (minc mcounter)
+ addParent po po2
+ incrP po 5
+ readMVar mcounter >>= assertEqual "cb1" 1
+ withStatus po (\x -> 5 @=? completedUnits x)
+ withStatus po2 (\x -> do 5 @=? completedUnits x
+ 200 @=? totalUnits x)
+
+ addCallback po2 (minc mcounter2)
+ incrP po 100
+ readMVar mcounter2 >>= (\x -> assertBool "cb2" (0 /= x))
+ withStatus po2 (\x -> do 105 @=? completedUnits x
+ 205 @=? totalUnits x)
+
+ incrP' po 5
+ withStatus po2 (\x -> do 110 @=? completedUnits x
+ 205 @=? totalUnits x)
+
+ finishP po
+ withStatus po2 (\x -> do 110 @=? completedUnits x
+ 210 @=? totalUnits x)
+
+
+ where minc mv _ _ = modifyMVar_ mv (\x -> return $ x + 1)
+
+tests = TestList [TestLabel "incrP" (TestCase test_incrP),
+ TestLabel "setP" (TestCase test_setP),
+ TestLabel "speed" (TestCase test_speed),
+ TestLabel "test_callback" (TestCase test_callback)]
+
+
+
diff --git a/testsrc/Str/CSVtest.hs b/testsrc/Str/CSVtest.hs
new file mode 100644
index 0000000..af44d48
--- /dev/null
+++ b/testsrc/Str/CSVtest.hs
@@ -0,0 +1,42 @@
+{- arch-tag: CSV tests main file
+Copyright (C) 2005 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Str.CSVtest(tests) where
+import Test.HUnit
+import Data.CSV
+import Text.ParserCombinators.Parsec
+
+test_csv =
+ let f inp exp = TestLabel inp $ TestCase $
+ exp @=? case parse csvFile "" inp of
+ Right x -> Right x
+ Left y -> Left (show y)
+ in [
+ f "" (Right []),
+ f "\n" (Right [[""]]),
+ f "1,2,3\n" (Right [["1", "2", "3"]]),
+ f "This is a,Test,Really\n" (Right [["This is a", "Test", "Really"]]),
+ f "l1\nl2\n" (Right [["l1"], ["l2"]]),
+ f "NQ,\"Quoted\"\n" (Right [["NQ", "Quoted"]]),
+ f "1Q,\"\"\"\"\n" (Right [["1Q", "\""]]),
+ f ",\"\"\n" (Right [["", ""]]),
+ f "\"Embedded\"\"Quote\"\n" (Right [["Embedded\"Quote"]])
+ ]
+
+tests = TestList [TestLabel "csv" (TestList test_csv)]
+
diff --git a/testsrc/Strtest.hs b/testsrc/Strtest.hs
new file mode 100644
index 0000000..fb38c59
--- /dev/null
+++ b/testsrc/Strtest.hs
@@ -0,0 +1,85 @@
+{- arch-tag: Str tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Strtest(tests) where
+import Test.HUnit
+import Data.String.Utils
+import Test.HUnit.Tools
+import Text.Regex
+import Data.Char
+
+test_lstrip =
+ mapassertEqual "lstrip" lstrip
+ [("", ""),
+ ("a", "a"),
+ (" a ", "a "),
+ (" abas", "abas"),
+ ("\n\t fdsa", "fdsa"),
+ ("abc def", "abc def")]
+
+test_rstrip =
+ mapassertEqual "rstrip" rstrip
+ [("", ""),
+ ("a", "a"),
+ (" a ", " a"),
+ ("abas ", "abas"),
+ ("fdsa \n\t", "fdsa"),
+ ("abc def", "abc def")]
+
+test_strip =
+ mapassertEqual "strip" strip
+ [("", ""),
+ ("a", "a"),
+ (" a ", "a"),
+ ("abas ", "abas"),
+ (" abas", "abas"),
+ ("asdf\n\t ", "asdf"),
+ ("\nbas", "bas"),
+ ("abc def", "abc def")]
+
+test_splitWs =
+ let f exp inp = TestCase $ exp @=? splitWs inp
+ in [
+ f [] " ",
+ f [] "",
+ f ["asdf"] " asdf\n",
+ f ["one", "two", "three"] " one\ntwo \tthree \n"
+ ]
+
+
+test_escapeRe =
+ map (\i -> TestLabel (show $ chr i) $ TestCase $ assertEqual [chr i] (Just [])
+ (matchRegex (mkRegex $ escapeRe $ [chr i]) [chr i]))
+ [1..255]
+ ++
+ [TestCase $ assertEqual "big string"
+ (Just ([], teststr, [], []))
+ (matchRegexAll (mkRegex $ escapeRe teststr) teststr)
+ ]
+ where teststr = map chr [1..255]
+
+tests = TestList [TestLabel "lstrip" (TestList test_lstrip),
+ TestLabel "rstrip" $ TestList test_rstrip,
+ TestLabel "strip" $ TestList test_strip,
+ TestLabel "splitWs" $ TestList test_splitWs,
+ TestLabel "escapeRe" $ TestList test_escapeRe
+ ]
+
+
+
+
diff --git a/testsrc/Tests.hs b/testsrc/Tests.hs
new file mode 100644
index 0000000..039a0c0
--- /dev/null
+++ b/testsrc/Tests.hs
@@ -0,0 +1,61 @@
+{- arch-tag: Tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Tests(tests) where
+import Test.HUnit
+import qualified MIMETypestest
+import qualified Listtest
+import qualified Maptest
+import qualified Pathtest
+import qualified Strtest
+import qualified IOtest
+import qualified Bitstest
+import qualified Eithertest
+import qualified CRC32POSIXtest
+import qualified CRC32GZIPtest
+import qualified GZiptest
+import qualified HVIOtest
+import qualified HVFStest
+import qualified Timetest
+import qualified Str.CSVtest
+import qualified WildMatchtest
+import qualified Globtest
+import qualified ProgressTrackertest
+
+test1 = TestCase ("x" @=? "x")
+
+tests = TestList [TestLabel "test1" test1,
+ TestLabel "List" Listtest.tests,
+ TestLabel "Str" Strtest.tests,
+ TestLabel "CSV" Str.CSVtest.tests,
+ TestLabel "Time" Timetest.tests,
+ TestLabel "Map" Maptest.tests,
+ TestLabel "ProgressTracker" ProgressTrackertest.tests,
+ TestLabel "Path" Pathtest.tests,
+ TestLabel "WildMatch" WildMatchtest.tests,
+ TestLabel "HVIO" HVIOtest.tests,
+ TestLabel "HVFS" HVFStest.tests,
+ TestLabel "Glob" Globtest.tests,
+ TestLabel "MIMETypes" MIMETypestest.tests,
+ TestLabel "Bitstest" Bitstest.tests,
+ TestLabel "Eithertest" Eithertest.tests,
+ TestLabel "CRC32POSIXtest" CRC32POSIXtest.tests,
+ TestLabel "CRC32GZIPtest" CRC32GZIPtest.tests,
+ TestLabel "GZiptest" GZiptest.tests]
+
+
diff --git a/testsrc/Timetest.hs b/testsrc/Timetest.hs
new file mode 100644
index 0000000..7f5c993
--- /dev/null
+++ b/testsrc/Timetest.hs
@@ -0,0 +1,54 @@
+{- arch-tag: Time tests main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+module Timetest(tests) where
+import Test.HUnit
+import System.Time.Utils
+import System.Time
+
+base =CalendarTime {ctYear = 2005, ctMonth = January, ctDay = 21,
+ ctHour = 1, ctMin = 1, ctSec = 20,
+ ctPicosec = 0, ctWDay = Sunday, ctYDay = 0,
+ ctTZName = "", ctTZ = 0, ctIsDST = False}
+test_ctu2e =
+ let f base exp = TestLabel (show base) $ TestCase $ exp @=? timegm base in
+ [
+ f (base {ctYear = 2005, ctMonth = January, ctDay = 21,
+ ctHour = 1, ctMin = 1, ctSec = 20})
+ 1106269280
+
+ ,f (base {ctYear = 2004, ctMonth = July, ctDay = 1,
+ ctHour = 17, ctMin = 0, ctSec = 0})
+ 1088701200
+
+ ]
+
+test_ct2e =
+ let f base exp = TestLabel (show base) $ TestCase $
+ do r <- timelocal base
+ exp @=? r in
+ [
+ f (base {ctYear = 2005, ctMonth = January, ctDay = 20,
+ ctHour = 19, ctMin = 1, ctSec = 20})
+ 1106269280
+ ,f (base {ctYear = 2004, ctMonth = July, ctDay = 1,
+ ctHour = 12, ctMin = 0, ctSec = 0})
+ 1088701200
+ ]
+
+tests = TestList [TestLabel "ctu2e" (TestList test_ctu2e)]
diff --git a/testsrc/WildMatchtest.hs b/testsrc/WildMatchtest.hs
new file mode 100644
index 0000000..8022e3c
--- /dev/null
+++ b/testsrc/WildMatchtest.hs
@@ -0,0 +1,52 @@
+{-
+Copyright (C) 2006 John Goerzen <jgoerzen at complete.org>
+
+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
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+
+module WildMatchtest(tests) where
+import Test.HUnit
+import System.Path.WildMatch
+import Test.HUnit.Tools
+
+test_wildCheckCase =
+ let f patt name = TestCase $ assertBool (patt ++ "," ++ name ++ " was false")
+ (wildCheckCase patt name)
+ f0 patt name = TestCase $ assertBool (patt ++ "," ++ name ++ " was true")
+ (not $ wildCheckCase patt name)
+ in
+ [f "asdf" "asdf",
+ f "?*?" "abc",
+ f "???*" "asd",
+ f "*???" "asd",
+ f "???" "asd",
+ f "*" "asd",
+ f "ab[cd]" "abc",
+ f "ab[!de]" "abc",
+ f0 "ab[de]" "abc",
+ f0 "??" "a",
+ f0 "a" "b",
+ f "[\\]" "\\",
+ f "[!\\]" "a",
+ f0 "[!\\]" "\\",
+ f0 "*.deb" "thedebianthing",
+ f0 "a/*.foo" "testtmp/a/D"]
+
+tests = TestList [TestLabel "wildCheckCase" (TestList test_wildCheckCase)]
+
+
+
+
diff --git a/tolgpl b/tolgpl
new file mode 100644
index 0000000..7e3f0c9
--- /dev/null
+++ b/tolgpl
@@ -0,0 +1,7 @@
+#!/bin/bash
+ssed -i -e 's/GNU General/GNU Lesser General/g' \
+ -e 's/ GPL/ LGPL/g' \
+ -e 's/version 2 /version 2.1 /g' \
+ -e 's/59 Temple Place, Suite 330, Boston, MA 02111-1307/51 Franklin St, Fifth Floor, Boston, MA 02110-1301/g' \
+ $1
+
diff --git a/winbuild.bat b/winbuild.bat
new file mode 100644
index 0000000..2bd4482
--- /dev/null
+++ b/winbuild.bat
@@ -0,0 +1,4 @@
+ghc -package Cabal Setup.hs -o setup.exe
+setup configure
+setup build
+
diff --git a/wintest.bat b/wintest.bat
new file mode 100644
index 0000000..c4bb4c9
--- /dev/null
+++ b/wintest.bat
@@ -0,0 +1,5 @@
+cd testsrc
+ghc --make -package hslogger -package FilePath -package mtl -package HUnit -fallow-overlapping-instances -fallow-undecidable-instances -fglasgow-exts -cpp -o runtests.exe -i..\dist\build:..\src runtests.hs
+cd ..
+testsrc\runtests
+
--
Debian package for MissingH
More information about the Pkg-haskell-commits
mailing list