Commit Graph

78 Commits

Author SHA1 Message Date
Zoltan Somogyi
84223268a0 Delete the tests/general/interpreter test case.
tests/general/interpreter.{m,inp,exp}:
tests/general/Mmakefile:
    As above: delete this test case.

samples/interpreter.m:
    Delete reference to the deleted test case.

tests/debugger/interpreter.m:
    Delete reference to the deleted test case in this copy of
    samples/interpreter.m.

tests/debugger/interpreter.exp:
tests/debugger/interpreter.exp2:
    The last update of interpreter.exp was in 2003. The command we invoke
    this test case with has changed several times since then, but none
    of them have been reflected in interpreter.exp, so now there is no way
    for it to be matched. This diff deletes interpreter.exp, and renames
    the old interpreter.exp2 to become the new interpreter.exp.

tests/general/arithmetic.nl:
tests/general/interpreter.nl:
tests/general/string_test.nl:
    Delete these relics of the time when we compared output generated
    by Mercury to output generated by NU-Prolog, since NU-Prolog is long dead.

tests/general/arithmetic.m:
tests/general/string_test.m:
    Update programming style, and factor out common code.
2022-03-04 17:25:20 +11:00
Zoltan Somogyi
92f60e5c70 Standardize on one interpreter.m.
samples/interpreter.m:
    Make this the primary copy of interpreter.m. Incorporate the improvements
    from the other two versions in tests, and generalize them to be suitable
    as a sample program.

tests/debugger/interpreter.m:
tests/general/interpreter.m:
    Make these copies of the primary version.

tests/debugger/Mmakefile:
tests/general/Mmakefile:
    Keep the tests copies of the primary version.

tests/general/interpreter.exp:
    Expect an output now generated for parameter-less invocations.
2022-03-04 14:45:01 +11:00
Zoltan Somogyi
1f45f91886 Make "mmake runtests" work again.
My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.

tests/Mmake.common:
    Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
    defined it as such, I overlooked the fact that tests/Mmakefile itself
    defined it ".", referring to the same directory from a different starting
    point. Document this easily-overlooked fact.

    Rename the old runtests target, which after afe2887 runs the tests
    in a single directory, as runtests_dir, to leave the target name
    "runtests" itself free for tests/Mmakefile to use.

tests/Mmakefile:
    Define "TESTS_DIR = .", and add a target "runtests" which invokes
    "mmake runtests_dir" in each test directory.

tools/bootcheck:
    Invoke "mmake runtests_dir" instead of "mmake runtests" in each
    test directory.

    Initialize a variable just before it is used.

tests/*/Mmakefile:
    Add back the definition "TESTS_DIR = .."
2020-06-10 01:05:15 +10:00
Zoltan Somogyi
afe2887882 Remove stale references to test subdirs.
A long time ago, test directories such as hard_coded had subdirectories
such as hard_coded/typeclasses. These have since been flattened out
(e.g. hard_coded/typeclasses is now just typeclasses), but there were
still remnants of the old approach. This diff deletes those remnants.

tests/*/Mmakefile:
    Delete the TESTS_DIR and the SUBDIRS mmake variables; TESTS_DIR
    was always set to "..", and SUBDIRS to the empty string.

    Delete any references to the make variable NOT_WORKING, since
    it is never used.

tests/Mmake.common:
    Document that Mmakefiles in test directories don't have to set
    TESTS_DIR and SUBDIRS anymore. Fix the formatting of the documentation
    of the make variables they do still have to set.

    Delete the targets and actions for handling subdirectories of
    test directories, since there aren't any.

tests/Mmakefile:
    Simplify some code.
2020-04-14 11:23:12 +10:00
Paul Bone
cffad33fd8 Fix a bug with I/O errors while reading files
Mercury did not properly test for I/O errors for file reading.  If an I/O
error occurred it would be reported as EOF.  If this happened at just the
right spot it could be silently ignored.  I found the mistake when trying to
open a directory as a file.  Opening the file succeeded but reading from it
incorrectly gave an EOF.

library/io.m:
    read_char_code has always been documented as returning -1 for EOF
    and -2 for an error.  But the C code did not correctly implement
    this.  fgetc will return EOF in either case and the caller must use
    ferror or feof to determine what has happened.

    Make it clearer that valid characters and bytes from read_char_code
    must be >= 0.

    Conform to changes in the runtime regarding supporting ferror

runtime/mercury_library_types.h:
    Add MR_FERROR macro

    Add ferror field to the MercuryFile struct.

runtime/mercury_file.[ch]:
    Add ferror field to the MercuryFile struct.

tests/general/Mmakefile:
tests/general/read_dir_regression.exp:
tests/general/read_dir_regression.exp2:
tests/general/read_dir_regression.exp3:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
    Add regression test.

tests/.gitignore
    Add *.java_date to .gitignore.
2016-08-31 14:58:43 +10:00
Julien Fischer
c38b683484 Fix failing string format tests in the C# grade.
test/general/Mmakefile:
     Filter out the stack trace due to an uncaught exception in the
     C# grade for the string_format_test_[23] test cases.

     Use sed to handle the Java case as well.
2016-02-22 10:54:08 +11:00
Julien Fischer
8ed0c3bd8a Fix failing string format tests cases in Java grade.
tests/general/Mmakefile:
     Filter out the Java stack trace that is printed by the
     string_format_test_[23] test cases in the Java grade.
2016-02-08 15:16:56 +11:00
Julien Fischer
f3bc84fdfa Fix failing test cases in the java grade.
tests/general/environment.m:
    Catch the exception that is thrown if io.set_environment_var/4 cannot
    modify the environment -- this is always the case for Java -- and print
    out what the exception is.  This avoids the stack trace that would otherwise
    be printed.

    Update the coding style in this test.

tests/general/environment.exp2:
    Add an alternative expected output for systems that do not support
    modifying the environment.

tests/general/Mmakefile:
    Shift the 'environment' test case to the list of those that
    require catching exceptions to be supported.

tests/general/float_roundtrip.exp2:
tests/hard_coded/deep_copy.exp4:
    Add new expected outputs to account for differences in the way floats are
    printed.

tests/hard_coded/dir_test.exp4:
tests/warnings/singleton_test.exp3:
    Update these expected outputs.
2016-02-07 16:02:13 +11:00
Julien Fischer
01995716e9 More test suite cleanups.
tests/benchmarks/Mmakefile:
    Delete variables only used with the IL or GCC back-ends.

tests/debugger/Mmakefile:
tests/declarative_debugger/Mmakefile:
tests/par_conj/Mmakefile:
    Delete references to the IL backend.

tests/par_conj/dep_par_10.m:
    Add missing C# and Java foreign procs.

tests/dppd/Mmakefile:
    Run these tests in the Java grade.

tests/general/Mmakefile:
    Delete a workaround for OSF/1 -- we no longer support it.

tests/hard_coded/Mmakefile:
    Delete the unused list of tests that will pass in the Java grade.

    Delete a reference to the IL backend.
2016-01-02 02:18:04 +11:00
Zoltan Somogyi
8a764392d9 Avoid warnings from make in test directories.
tests/Mmake.common:
    Don't invoke any actions in the clean_local and realclean_local
    targets, since if using mmc --make, the builtin mmake rules
    have actions for those targets as well, and make can't handle
    more than one action for a target having actions. Replace those
    actions with dependencies on other, unique targets that have
    the actions instead.

tests/*/Mmakefile:
    Avoid actions in clean_local and realclean_local targets the same way.

    Sort the test names in some directories that didn't already do so.

    Delete some obsolete comments.

    Fix style.

tests/valid/Mmake.valid.common:
    As for the Mmakefiles above, and also move the definition of a make
    variable before it is needed.
2015-09-08 05:57:53 +10:00
Zoltan Somogyi
73f0a36719 Allow the use of -jN in many test directories.
tests/Mmake.common:
    Replace the -j1 in the runtests_local target used by all the test
    directories with $(MAYBE_J1).

tests/*/Mmakefile:
    Define MAYBE_J1 it as the empty string in test directories in which
    different tests don't share source files.

    Define MAYBE_J1 as -j1 in test directories in which
    different tests do share source files.

tests/submodules/sub2_a.m:
    Add this copy of sub_a.m to allow tests in the submodules directory
    to be done in parallel.

tests/submodules/accessibility2.m:
    Import sub2_a.m instead of sub_a.m.

tests/warnings/ambig_types_high_level.m:
    Add this copy of ambig_types.m to allow tests in the warnings directory
    to be done in parallel.

tests/warnings/ambig_high_level.m:
    Import ambig_types_high_level.m instead of ambig_types.m.
2015-02-19 06:02:45 +11:00
Zoltan Somogyi
de2f7b2a0c Flatten the test directories, step 2.
Specifically, rename the following subdirectories of the test directory:

    old dir name                new dir name

    analysis/ext                analysis_external
    analysis/ctgc               analysis_ctgc
    analysis/excp               analysis_excp
    analysis/table              analysis_table
    analysis/trail              analysis_trail
    invalid/purity              invalid_purity
    analysis/sharing            analysis_sharing
    hard_coded/purity           purity
    general/accumulator         accumulator
    analysis/unused_args        analysis_unused_args
    debugger/declarative        declarative_debugger
    hard_coded/exceptions       exceptions
    general/string_format       string_format
    hard_coded/sub-modules      submodules
    hard_coded/typeclasses      typeclasses
    general/structure_reuse     structure_reuse

Some subdirectories are still there, to wit, the subdirs of the inactive
test directory stm, each of which (if I remember correctly) holds only one
test case.

The general/structure_reuse directory previously wasn't enabled; I think
this was a bug.

tests/Mmakefile:
tools/bootcheck:
    List the new test directories.

tests/Mmake.common:
    The analysis_* directories each need to know whether the workspace
    uses subdirs. This used to be controlled from one place,
    analysis/Mmakefile, but since analysis_* are not subdirs of analysis,
    we need a new central place to find this out.

tests/analysis/common.sh:
    Update documentation for the move.

tests/OLDDIRS/Mmakefile:
    Set the subdir list to empty.

tests/NEWDIRS/Mmakefile:
    Update the "this" directory's name, as well as TESTS_DIR.

    In analysis_*/Mmakefile, use the new mechanism for detecting the presence
    of subdirs.
2015-02-10 00:44:14 +11:00
Zoltan Somogyi
d33273d033 Tell vim not to expand tabs in Makefiles.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.

*/Makefile:
*/Mmakefile:
    As above.

tests/hard_coded/.gitignore:
    Don't ignore the purity subdir. This ignore must have been left over
    from when purity.m was a test in hard_coded, not hard_coded/purity,
    and it ignored an executable, not a directory.
2015-01-08 22:07:29 +11:00
Paul Bone
295c788773 Address weak_pointer test review comments.
tests/general/weak_ptr.m:
tests/general/weak_ptr.exp:
tests/hard_coded/Mmakefile:
tests/general/Mmakefile:
    Move week_ptr test into tests/hard_coded

    The weak_ptr test should te executed conditionally, this is easy to do in
    the hard_coded/ test suite.

tests/general/weak_ptr.m:
    Fix spelling error.

tests/general/weak_ptr.exp2:
    Remove unnecessary file.
2014-08-04 16:51:38 +10:00
Paul Bone
6ecc12e619 Add support for weak pointers to the C RTS
A weak pointer (aka weak reference) is a pointer to some garbage collector
(GC) allocated object or memory that is not considered by the GC when
deciding if the object is garbage or not.  Additionally, if the object is
reclaimed by the GC the GC will zero-out this pointer so that other code can
test if this object is still available.  Weak pointer can be useful when
implementing caches or cyclic data structures (my motivation for this
change).

This change introduces a weak pointer type (a typedef) in Mercury's runtime
system for the C backends.  Two macros are provided to create and deference
these weak pointers.  Extra documentation, and constraints on how these can
be used are described in mercury_memory.h.

runtime/mercury_memory.c:
runtime/mercury_memory.h:
    As above.

tests/general/weak_ptr.m:
tests/general/Mmakefile:
    Add a test for the C RTS's weak pointer support

tests/general/weak_ptr.exp:
    Expected output for the test.  This isn't the real program's output.
    weak_ptr's output is too volatile to use reliably (see weak_ptr.m).
2014-07-18 12:59:12 +10:00
Paul Bone
5c72797dc6 Implement map.equal/2
The unification operation on 2-3-4 trees tests if they are structurally
equal.  They might also be considered equal if their sets of key-value pairs
are equivalent.  I've created an equal/2 predicate in the tree234 and
map modules in the standard library to test this.

library/tree234.m:
    Implement a predicate to test for tree234 equivalence.

library/map.m:
    Forward map.equal/2 to tree234.equal/2.

NEWS:
    Announce this change in the news file.

tests/general/map_equal.m:
tests/general/map_equal.exp:
    Add test case for map.equal/2

tests/general/Mmakefile:
    Include the new test case.
2013-10-20 17:49:57 +11:00
Ian MacLarty
6538244691 Fix a bug in higher order specialization where it incorrectly specialized a
Branches: main

Fix a bug in higher order specialization where it incorrectly specialized a
call to a variable after a branch if the variable was constructed in the branch
and its value was known in one branch arm, but not the others.

higher_order.m uses a map to track the possible values of higher order
variables.  The map maps variables to either a constant value, or a
'multiple_values' functor to indicate that the variable can contain multiple
values (and is therefore not specializable).  The problem was there was
some confusion about what it meant if a variable did not appear in this map.

merge_post_branch_infos was expecting the post_branch_info maps it was merging
to contain all the higher order variables in the arms, when in fact it only
contained variables that the goal traversal routines had deemed specializable.
Any entries it found in one post_branch_info but not the other, would be
copied to the resulting post_branch_info.  This was incorrect, because if a
variable did not occur in one post_branch_info its value might simply be
unknown in that arm (in which case is should not be specializable after
the branch).

The fix is to remove the multiple_values functor altogether.  A variable now
only appears in the post_branch_info if its value is known and unique.
merge_post_branch_infos has been changed so that it drops variables that
don't appear in both post_branch_infos.

There is one exception to the above where one switch arm is reachable and the
others are unreachable.  In this case we can copy any variables with unique
known values in the reachable arm's post_branch_info to the merged
post_branch_info.  The reachablility of each arm is therefore now also included
in the post_branch_infos.

compiler/higher_order.m:
    As above.

    Also remove some comments about the complexity of the
    merge_post_branch_infos algorithm, as the current algorithm is the obvious
    one given the new meaning of the post_branch_info maps.

tests/general/Mercury.options:
tests/general/Mmakefile:
tests/general/ho_spec_branch_bug.exp:
tests/general/ho_spec_branch_bug.m:
    Add a regression test.
2011-10-19 04:55:18 +00:00
Zoltan Somogyi
280b36a037 Add a comment about a test case added by the state var rewrite diff.
Estimated hours taken: 0.1
Branches: main

Add a comment about a test case added by the state var rewrite diff.
2011-03-07 11:30:09 +00:00
Ralph Becket
f1c304939b Add approximate as well as exact binary search to array.m.
Estimated hours taken: 2
Branches: main

Add approximate as well as exact binary search to array.m.  An approximate
search looks for the index of the largest element in the array that is
not greater than the value for which we are searching.  This is useful for,
say, finding which line number corresponds to a particular offset into a file.

NEWS:
	Mention the new additions.

library/array.m:
	Added approx_binary_search and binary_search predicates.

tests/general/Mmakefile:
tests/general/array_binsearch.m:
tests/general/array_binsearch.exp:
	Test case.
2009-09-01 02:11:31 +00:00
Peter Wang
75771a9b6e Allow testing of java grade. Requires using `mmc --make' for now.
Branches: main

Allow testing of java grade.  Requires using `mmc --make' for now.
This patch does not attempt to fix test failures.

tests/Mmake.common:
        Delete unneeded Java-specific rule, which was broken.

tests/benchmarks/Mmakefile:
tests/general/Mmakefile:
tests/general/string_format/Mmakefile:
tests/grade_subdirs/Mmakefile:
tests/hard_coded/Mmakefile:
tests/recompilation/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
        Don't deliberately disable tests in java grade.

tests/*.m:
        Add Java foreign code.

        Write dummy procedures instead of abusing `:- external'.
2009-08-14 03:21:55 +00:00
Ralph Becket
51b8f762e8 Only check for overflow when converting strings to ints when the base is 10.
Estimated hours taken: 0.5
Branches: main

Only check for overflow when converting strings to ints when the base is 10.
Other number bases are assumed to denote bit patterns and no overflow test
is employed.

NEWS:
	Mention the change.

library/string.m:
	Amend accumulate_int to perform an overflow check on base 10 numbers.

tests/general/Mmakefile:
tests/general/test_string_to_int_overflow.m:
tests/general/test_string_to_int_overflow.exp:
	Add a test case.
2009-02-03 06:44:01 +00:00
Ralph Becket
4692b728e3 Add parsing_utils.m to the library, providing support for recursive descent
parsers.

NEWS:
	Report the addition of parsing_utils.m to the library.

library/library.m:
	Include parsing_utils.m.

library/parsing_utils.m:
	Added.

library/string.m:
	Make string.to_int fail on overflow.  Amend comments to reflect this.

tests/general/Mmakefile:
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
	Test case for parsing_utils.m.
2009-01-28 07:19:42 +00:00
Zoltan Somogyi
dcd2922eb4 Sort the lists of tests in each directory. (We usually keep each list
Estimated hours taken: 0.2
Branches: main

tests/*/Mmakefile:
	Sort the lists of tests in each directory. (We usually keep each list
	sorted, but then we concatenate several lists, which loses the order.)
	This gives you a better idea of how far a bootcheck still has to go.

tools/bootcheck:
	Build the interface files before the rest of the files in the library
	directory. Again, this gives you a better idea of how far a bootcheck
	still has to go.

	Make the dependencies for the slice subdirectory of the stage2 at the
	same time as the other subdirs; don't let it be caught later.

library/Mmakefile:
	Build the interface files in the right order.
2008-12-01 00:32:58 +00:00
Julien Fischer
c2e2d69a5c Add the functions integer.from_base_string/2 and
Estimated hours taken: 1.5
Branches: main

library/integer.m:
	Add the functions integer.from_base_string/2 and
	integer.det_from_base_string/2.

NEWS:
	Announce the addition.

tests/general/Mmakefile:
tests/general/.cvsignore:
tests/general/base_string_to_integer.{m,exp}:
	Test the new functions.
2007-05-10 05:55:38 +00:00
Ian MacLarty
90e997af6f Fix a bug in the hlc grades where generated C function names were not
Estimated hours taken: 1
Branches: main

Fix a bug in the hlc grades where generated C function names were not
being mangled correctly.  The generated function names contained the
Mercury module name verbatim, which meant that if the Mercury module name
wasn't a valid C identifier, then the generated C code would be invalid.

compiler/mlds_to_c.m:
	Mangle function names in generated high level C code.

tests/general/Mmakefile:
tests/general/hlc_name_mangling-helper-module.m:
tests/general/hlc_name_mangling.exp:
tests/general/hlc_name_mangling.m:
	Add a regression test.
2006-11-14 04:10:23 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Ralph Becket
e1c6ed1409 Added a test case for string.base_string_to_int/3.
Estimated hours taken: 0.2
Branches: main

tests/general/Mmakefile:
tests/general/base_string_to_int.m:
tests/general/base_string_to_int.exp:
	Added a test case for string.base_string_to_int/3.
2004-07-01 06:20:14 +00:00
Peter Ross
35834907f5 Improve the time, space and stack usage of string__replace and
string__replace_all.

library/string.m:
	Reimplement string__replace_all and string__replace using
	string__sub_string_search.
	Make string__replace_all tail recursive.
	Add a new version of string__sub_string_search which takes an
	index to begin searching from.
	Remove an infinite loop in string__sub_string_search_2.


tests/general/Mmakefile:
tests/general/string_replace.exp:
tests/general/string_replace.m:
	Test string__replace and string__replace_all.
2004-06-26 09:23:24 +00:00
Michael Wybrow
483d0c71a2 Modifications to the test suite to allow testing in grade java.
Estimated hours taken: 14
Branches: main

Modifications to the test suite to allow testing in grade java.


mercury/tools/test_mercury:
        Set-up the required CLASSPATH variable.

tests/Mmake.common:
        Added a rule to build `.out' files when the grade is java.

tests/benchmarks/Mmakefile:
        Enable only the working tests for the benckmarks directory.

tests/dppd/Mmakefile:
tests/general/Mmakefile:
tests/general/accumulator/Mmakefile:
tests/general/string_format/Mmakefile:
tests/general/structure_reuse/Mmakefile:a
tests/grade_subdirs/Mmakefile:
tests/hard_coded/Mmakefile:
tests/hard_coded/exceptions/Mmakefile:
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/typeclasses/Mmakefile:
tests/recompilation/Mmakefile
tests/term/Mmakefile:
tests/valid/Mmakefile:
        Disable test cases for grade java.

tests/recompilation/test_functions:
        Add framework needed to do recompilation testing for the java grade.
2003-01-12 22:33:35 +00:00
Peter Ross
d30184f483 Disable string_format_special_floats on DEC OSF as the OS throws a
Estimated hours taken: 0.5
Branches: main

tests/general/Mmakefile:
    Disable string_format_special_floats on DEC OSF as the OS throws a
    floating point exception when calculating the special floats.

tests/general/string_format/Mmakefile:
    Disable string_format_o on SunOS 5.8 as well.
2002-11-28 09:13:36 +00:00
Peter Ross
6a5e677055 Reorganize the string__format tests so that we only need one expected
Estimated hours taken: 2
Branches: main

Reorganize the string__format tests so that we only need one expected
output file for each test.

tests/general/string_format_special_floats.exp:
tests/general/string_format_special_floats.m:
	Test that NaNs and infinites are handled correctly, by
	internally checking in the test case that we generate a valid
	string rather than by checking the expected output.

tests/general/Mmakefile:
	Add the new test.

tests/general/string_format/string_format_f.exp:
tests/general/string_format/string_format_f.m:
	Remove the test cases of infinite_floats.
	Remove the testing of +/-float__max as each C version of
	sprintf seems to print the number out to a different
	precision.

tests/general/string_format/string_format_e.exp:
tests/general/string_format/string_format_e.m:
tests/general/string_format/string_format_g.exp:
tests/general/string_format/string_format_g.m:
	Remove the test cases of infinite_floats.
2002-11-21 14:27:16 +00:00
Peter Ross
2e66995c01 Fix the I/O routines for floats so that can roundtrip.
Estimated hours taken: 8
Branches: main

Fix the I/O routines for floats so that can roundtrip.

library/string.m:
    Ensure that string__float_to_string returns a float that is
    round-trippable.  On the C backend we do that by starting at the min
    precision required and increasing it until the float roundtrips.
    This functionality is provided by ML_sprintf_float, so that it can
    be reused in io.m. On the IL backend the R flag guarantees that a
    double will be round-trippable, so we just use that.
    Change string__to_float so that it uses the format string for the
    precision float that we are using, and export this predicate for use
    by the trace system.
    Delete the unused string__float_to_f_string.

library/io.m:
    Print round-tripable floats in io__write_float.
    For the C backend use ML_sprintf_float to avoid unnecessary string
    allocation.  For other backends use string__float_to_string to
    generate a valid float.

trace/mercury_trace_util.c:
    Rather than duplicating the code from the library, call the code in
    the library.

tests/general/Mmakefile:
tests/general/float_roundtrip.exp:
tests/general/float_roundtrip.m:
    Test that floats roundtrip for different required miniumum
    precisions.
2002-11-21 08:00:58 +00:00
Peter Ross
9ba037dcb9 Move the string__format tests to the string_format directory.
Estimated hours taken: 4
Branches: main

tests/general/Mmakefile:
	Move the string__format tests to the string_format directory.

tests/general/string_format/Mercury.options:
tests/general/string_format/Mmakefile:
	Only output the last 20 lines of output if a program aborts as
	the output can be very big and it is only the last few lines
	that we are interested in.
	If the acutal output doesn't match the expect output, don't
	output the diff to stdout because the files are generally too
	big.
	Sort the output files before comparing it because the C and IL
	backends use a different lexical ordering.

tests/general/string_format_p.exp:
tests/general/string_format_p.m:
	Remove completely from the test suite as how to print a
	pointer is implementation defined and we always get different
	results.

tests/general/string_format/string_format_c.exp:
tests/general/string_format/string_format_c.m:
tests/general/string_format/string_format_d.exp:
tests/general/string_format/string_format_d.m:
tests/general/string_format/string_format_e.exp:
tests/general/string_format/string_format_e.m:
tests/general/string_format/string_format_f.exp:
tests/general/string_format/string_format_f.m:
tests/general/string_format/string_format_g.exp:
tests/general/string_format/string_format_g.m:
tests/general/string_format/string_format_lib.m:
tests/general/string_format/string_format_o.exp:
tests/general/string_format/string_format_o.m:
tests/general/string_format/string_format_s.exp:
tests/general/string_format/string_format_s.m:
tests/general/string_format/string_format_u.exp:
tests/general/string_format/string_format_u.m:
tests/general/string_format/string_format_x.exp:
tests/general/string_format/string_format_x.m:
tests/general/string_format_c.exp:
tests/general/string_format_c.m:
tests/general/string_format_d.exp:
tests/general/string_format_d.m:
tests/general/string_format_e.exp:
tests/general/string_format_e.m:
tests/general/string_format_f.exp:
tests/general/string_format_f.m:
tests/general/string_format_g.exp:
tests/general/string_format_g.m:
tests/general/string_format_lib.m:
tests/general/string_format_o.exp:
tests/general/string_format_o.m:
tests/general/string_format_s.exp:
tests/general/string_format_s.m:
tests/general/string_format_u.exp:
tests/general/string_format_u.m:
tests/general/string_format_x.exp:
tests/general/string_format_x.m:
	Move the files and refactor the code a bit.
2002-11-19 09:42:35 +00:00
Peter Ross
e8dab90b2e Disable the string_format tests in preperation for moving them to a
Estimated hours taken: 0.25
Branches: main

tests/general/Mmakefile:
    Disable the string_format tests in preperation for moving them to a
    new directory.
2002-11-14 09:46:29 +00:00
Peter Ross
67413e8c07 Fully test the string__format predicate by automatically generating a
Estimated hours taken: 3
Branches: main

Fully test the string__format predicate by automatically generating a
comprehensive set of format strings.

tests/general/Mmakefile:
	Add the new test cases.

tests/general/string_format_lib.m:
	Predicate to generate all the interesting format strings for a
	particular type specifier.  We avoid generating format strings
	which are implementation dependent.

tests/general/string_format_c.exp:
tests/general/string_format_c.m:
tests/general/string_format_d.exp:
tests/general/string_format_d.m:
tests/general/string_format_e.exp:
tests/general/string_format_e.m:
tests/general/string_format_f.exp:
tests/general/string_format_f.m:
tests/general/string_format_g.exp:
tests/general/string_format_g.m:
tests/general/string_format_o.exp:
tests/general/string_format_o.m:
tests/general/string_format_p.exp:
tests/general/string_format_p.m:
tests/general/string_format_s.exp:
tests/general/string_format_s.m:
tests/general/string_format_u.exp:
tests/general/string_format_u.m:
tests/general/string_format_x.exp:
tests/general/string_format_x.m:
	Test the various type specifiers.
2002-11-12 15:20:49 +00:00
Ralph Becket
005902cc69 Added.
Estimated hours taken: 0.5
Branches: main

tests/general/string_foldl_substring.m:
tests/general/string_foldl_substring.exp:
	Added.

tests/general/Mmakefile:
	Added string_foldl_substring to test suite.
2002-10-29 07:10:57 +00:00
Ralph Becket
6ce7742051 Added.
Estimated hours taken: 0.5
Branches: main

tests/general/string_foldr_substring.m:
tests/general/string_foldr_substring.exp:
	Added.

tests/general/Mmakefile:
	Include string_foldr_substring test.
2002-10-28 06:06:08 +00:00
Simon Taylor
47a4d62dc1 Improve the test framework to make it easier to find out which tests
Estimated hours taken: 30
Branches: main

Improve the test framework to make it easier to find out which tests
failed and to reduce disk usage (important in debug grades).

Allow the tests to be run with `mmc --make' (still some failures).

Allow the user to run only the failing tests from a previous
run by using `mmake ERROR_FILE=runtests.errs', where runtests.errs
is the log file from the previous run.

tests/Mmake.common:
tests/*/Mmakefile:
	Move common code (such as the code to deal with subdirectories)
	to Mmake.common.

	Run the tests using `mmake runtests' rather than using slightly
	different runtests scripts in each directory.

	Add to the output from `mmake runtests' to make it easier to
	identify which tests failed in which grades.

	Move per-module options into Mercury.options files so they
	can be read by `mmc --make'.

	Remove the last of the NU-Prolog support.

	Consistently use the main module name when listing tests.
	Some directories (e.g. invalid) were using the source file
	name.

tests/process_log.awk:
	Collect the parts of the output relating to failing tests.

tests/generate_exp:
tests/handle_options:
tests/subdir_runtests:
tests/startup:
tests/shutdown:
tests/*/runtests:
tests/recompilation/TESTS:
	Removed.

tests/recompilation/test_functions:
	Make sure the old result file is removed before starting
	each test.

	Put the mmake output for tests which are supposed to fail
	into a different file for each test.

tests/warnings/Mmakefile:
	Use %.c rather than $(cs_subdir)%.c in a rule.
	The $(cs_subdir) part doesn't work with `mmc --make',
	and isn't necessary any more (modules.m generates a rule
	`module.c: $(cs_subdir)module.c').

tests/README:
	Updated.

tools/bootcheck:
tools/test_mercury:
	Use `mmake runtests' instead of the `runtests' script.

	Add a `-f' (`--failing-tests') option to bootcheck which
	runs only the failing tests from the last run.

tools/test_mercury:
tools/run_all_tests_from_cron:
	Use the new framework to summarize test failures.
2002-08-17 13:52:35 +00:00
Ralph Becket
b746233ac4 Implemented state variable transformation.
Estimated hours taken: 600
Branches: main

Implemented state variable transformation.

NEWS:
	Record new syntax and withdrawl of !/0 as Prolog cut.

compiler/hlds_goal.m:
compiler/hlds_out.m:
	Added implicit/1 constructor to unify_main_context for cases where
	variables are introduced by compiler transformations.

compiler/make_hlds.m:
	Integrated the state variable transformation with the conversion to
	HLDS.

	Changed references to foreign_type and du_type constructors to
	match recent changes to the foreign type interface.

compiler/mercury_compile.m:
	Removed two unnecessary Prolog cuts left over from the Dark
	Ages.

compiler/mercury_to_mercury.m:
	Added code to output the new goal_expr constructors for state
	variable quantifiers (some_state_vars and all_state_vars.)

	Adapted to handle changes to if_then and if_then_else
	goal_expr constructors which now include lists of state
	variables that scope over the condition- and then-goals.

compiler/module_qual.m:
compiler/prog_util.m:
	Changes to handle some_state_vars, all_state_vars, and changes
	to if_then and if_then_else goal_expr constructors.

compiler/prog_data.m:
	Added some_state_vars, all_state_vars constructors and changed
	if_then and if_then_else constructors in type goal_expr.

compiler/prog_io_dcg.m:
	Changes to handle quantified state variables.

compiler/prog_io_goal.m:
	parse_some_vars_goal now also separates out quantified state
	variables.

compiler/prog_io_util.m:
	Added pred parse_quantifier_vars/3 which also detects state
	variables.

compiler/typecheck.m:
	Added case to report_error_undef_cons to handle any uncaught
	uses of !/1.

doc/reference_manual.texi:
	Documented the transformation.

library/builtin.m:
library/prolog.m:
	Deleted code for `!' as fake Prolog cut.

library/lexer.m:
	Made `!' a graphic token rather char than a special token.

library/ops.m:
	Added `!', `!.' and `!:' as prefix ops.

library/term.m:
	Added func var_id/1 which returns an int associated with its
	var argument which is unique in the context of the given var
	and the varset it belongs to.

library/varset.m:
	Added pred new_uniquely_named_var/4 which creates a named
	variable with a unique (w.r.t. the varset) number suffix.

tests/general/Mmakefile:
tests/general/state_vars_tests.exp:
tests/general/state_vars_tests.m:
tests/general/state_vars_typeclasses.exp:
tests/general/state_vars_typeclasses.m:
tests/invalid/Mmakefile:
tests/invalid/state_vars_test1.err_exp:
tests/invalid/state_vars_test1.m:
tests/invalid/state_vars_test2.err_exp:
tests/invalid/state_vars_test2.m:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/state_vars_test3.m:
tests/invalid/state_vars_test4.err_exp:
tests/invalid/state_vars_test4.m:
tests/invalid/state_vars_test5.err_exp:
tests/invalid/state_vars_test5.m:
	Added.
2002-07-09 01:31:12 +00:00
Zoltan Somogyi
06d619dd53 Allow the deep profiling grade to bootstrap again.
Estimated hours taken: 10
Branches: main

Allow the deep profiling grade to bootstrap again.

compiler/deep_profiling.m:
	Fix an omission from a nonlocals set.

	Mark transformed some() goals that act as cuts as being non-removable.
	Without this, determinism analysis (reinvoked by simplify after the
	deep profiling transformation) could compute the wrong determinism
	for some some() goals with no output arguments. This happened if
	originally, the some() represented a cut, but after the goal being
	cut across was made inpure by the deep profiling transformation,
	determinism analysis decided that it needed to find all solutions
	to that goal to avoid removing some side effects.

compiler/det_analysis.m:
	Respect the non-removable markers placed by deep_profiling.m.

compiler/hlds_goal.m:
	Add a goal feature that acts as this marker.

tests/general/Mmakefile:
	In deep profiling grades, disable test cases that require catching
	exceptions, which we can't do (yet) in those grades.
2002-02-26 02:52:33 +00:00
Peter Ross
28b3015e9e Fix a bug where unused argument procedures were being called from the
Estimated hours taken: 4
Branches: main

Fix a bug where unused argument procedures were being called from the
wrong code_model in their parent procedure.  This bug only shows up on
the MLDS backends.

compiler/unused_args.m:
    Use the declared determinism for determining the determinism of a
    call to a unused argument procedure, not the actual determinism.

tests/general/Mmakefile:
tests/general/unused_arg_determinism.exp:
tests/general/unused_arg_determinism.m:
    Test case.
2002-02-12 15:47:58 +00:00
Ralph Becket
5c79e4e823 Fixed a bug in string__to_float/2 which did not fail when it
Estimated hours taken: 1
Branches: main

library/string.m:
	Fixed a bug in string__to_float/2 which did not fail when it
	should have (i.e. it now also fails if the string argument
	has preceding whitespace or any trailing characters.)

tests/general/string_to_float.m:
tests/general/string_to_float.exp:
tests/general/Mmakefile:
	Added test cases.
2002-02-12 01:39:58 +00:00
Simon Taylor
3d3e5f9411 Add io__input_stream_foldl', io__input_stream_foldl_io'
Estimated hours taken: 1

NEWS:
library/io.m:
	Add `io__input_stream_foldl', `io__input_stream_foldl_io'
	and `io__input_stream_foldl2_io', which apply a predicate
	to each character of an input stream in turn.

	Add a new result type `io__maybe_partial_res' which is
	used for operations which can return a partial result
	like io__input_stream_foldl* and io__read_file.

tests/general/io_regression.m:
extras/xml/xml.cat.m:
extras/xml/xml.parse.m:
extras/xml/tryit.m:
extras/morphine/source/coverage_util.m:
	Fix uses of io__read_file and io__read_file_as_string.

tests/general/Mmakefile:
tests/general/io_foldl.{m,exp}:
	Test case.
2002-01-22 14:21:52 +00:00
Ralph Becket
16ac427e1d Added signature for func version of unsafe_promise_unique.
Estimated hours taken: 0.1
Branches: main

library/builtin.m:
	Added signature for func version of unsafe_promise_unique.

NEWS:
	Mentioned the new addition.

tests/general/Mmakefile:
tests/general/unsafe_uniqueness.m:
tests/general/unsafe_uniqueness.exp:
	New test case and expected output for unsafe_promise_unique/1.
2001-12-19 02:54:13 +00:00
Simon Taylor
52d875b509 Prefix commands which recursively invoke mmake with `+'.
Estimated hours taken: 0.25

Mmakefile:
tests/Mmakefile:
tests/debugger/Mmakefile:
tests/general/Mmakefile:
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
	Prefix commands which recursively invoke mmake with `+'.
	This allow parallel make to work in the subdirectories,
	and avoids warnings such as:
		"gmake[1]: warning: jobserver unavailable: using -j1.
			Add `+' to parent make rule."
	Without the `+', the parent gmake does not attempt to
	communicate with the child gmake to decide how many processes
	the child gmake is allowed to run.
2001-09-02 10:33:07 +00:00
Fergus Henderson
bce6002b30 Add a test case to test that mode inference supports mode reordering.
Estimated hours taken: 0.25
Branches: main

tests/general/Mmakefile:
tests/general/mode_inference_reorder.m:
tests/general/mode_inference_reorder.exp:
tests/general/mode_inference_reorder.inp:
	Add a test case to test that mode inference supports mode reordering.
	(The test case in question is based on samples/calculator.m,
	with the type and mode declarations commented out, and with
	one of the clauses near the top rewritten so that the compiler
	has to reorder it to get the modes right.)
2001-04-10 01:17:23 +00:00
Fergus Henderson
20f44cf84c Re-enable to `univ' test in hl* grades, since we now pass it.
Estimated hours taken: 0.1

tests/general/Mmakefile:
	Re-enable to `univ' test in hl* grades, since we now pass it.
2000-10-23 13:56:09 +00:00
Tyson Dowd
fdaf7bf23b The xml parser wasn't working, because all the files read using
Estimated hours taken: 2

The xml parser wasn't working, because all the files read using
io__read_file_as_string/4 were empty.  It turns out this is a due to a
bug in the library.

library/io.m:
	Fix a bug that petdr introduced when changing the file stream
	structures.
	Make sure we use the return value of fread (or whatever is used
	to read the file) when reading into a buffer.

tests/general/Mmakefile:
tests/general/io_regression.exp:
tests/general/io_regression.inp:
tests/general/io_regression.m:
	Add a test case for this problem to the test suite.
2000-09-11 04:28:22 +00:00
Peter Ross
e403cc04e7 If we are compiling in the grade hl* disable the univ test as
Estimated hours taken: 0.5

tests/general/Mmakefile:
	If we are compiling in the grade hl* disable the univ test as
	unification of univ values are not yet supported.
	Strip any carriage returns from the string_format_test_* output.
	This is needed when running the tests under windows.
2000-08-10 10:36:38 +00:00
Zoltan Somogyi
66ac848b1e If the new --test-params option is given, copy the stage 2 Mmake.params
Estimated hours taken: 1

tools/bootcheck:
	If the new --test-params option is given, copy the stage 2 Mmake.params
	file to the tests directory. This capability is required to test
	changes such as compiling the library without special preds and
	the test cases with special preds. You get a lot of spurious errors
	if a test case assumes that since it was compiled with special
	preds, all other modules it is linked with are also compiled with
	special preds, and thus makes calls to non-existent special preds
	for the types defined in the library.

tests/*/Mmakefile:
tests/*/*/Mmakefile:
	Include Mmake.params from the top level tests directory if it exists.
2000-04-05 06:12:04 +00:00