Commit Graph

322 Commits

Author SHA1 Message Date
Julien Fischer
2ae3fa61da Update programming style in some tests.
tests/general/string_format_test.m:
tests/general/string_format_test_2.m:
tests/general/string_format_test_3.m:
      As above.
2021-01-05 14:58:54 +11:00
Peter Wang
88047bbb45 Delete Erlang from tests.
tests/general/float_test.exp3:
tests/general/float_test.m:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
tests/hard_coded/remove_file.exp2:
tests/hard_coded/remove_file.m:
    Delete Erlang backend specific expected outputs.

tests/hard_coded/Mmakefile:
tests/hard_coded/erlang_deconstruct.exp:
tests/hard_coded/erlang_deconstruct.m:
tests/hard_coded/existential_list.exp:
tests/hard_coded/existential_list.m:
tests/valid/Mmakefile:
tests/valid/erl_ite_vars.m:
tests/valid/zf_erlang_bug.m:
    Delete erlang target specific tests.

tests/*:
    Delete Erlang foreign procs and foreign types.
2020-10-27 11:10:11 +11:00
Zoltan Somogyi
58ea6ffff2 Delete old obsolete predicates and functions.
library/*.m:
    Specifically, delete any predicates and functions whose `pragma obsolete'
    dates from 2018 or before. Keep the ones that were obsoleted
    only this year or last year.

NEWS:
    Announce the changes.

tests/debugger/io_tab_goto.m:
tests/debugger/tabled_read.m:
tests/declarative_debugger/io_stream_test.m:
tests/declarative_debugger/tabled_read_decl.m:
tests/declarative_debugger/tabled_read_decl_goto.m:
tests/general/array_test.m:
tests/hard_coded/mutable_init_impure.m:
tests/hard_coded/remove_file.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug2.m:
tests/valid/mercury_java_parser_follow_code_bug.m:
    Replace references to predicates and functions that this diff deletes
    with their suggested replacements.

    In several test cases, bring the programming style up to date.

tests/hard_coded/shift_test.{m,exp}:
    Most of this test case tested the now-deleted legacy shift operations.
    Replace these with tests of their non-legacy versions, including
    testing for the expected exceptions.

tests/hard_coded/shift_test.{m,exp}:
    Don't pass --no-warn-obsolete when compiling shift_test.m anymore.
2020-08-18 11:57:47 +10:00
Zoltan Somogyi
4d815b358d Fix a compiler abort when looking up invalid procs.
compiler/passes_aux.m:
    The bug that this diff "fixes", Mantis bug #516, surfaced when
    in an earlier change, I "fixed" an inconsistency in passes_aux.m,
    which was that the names of many predicate said that they iterated
    over *all* procedures, but actually they iterated over only the *valid*
    procedures. The fix was to iterate over all the procedures.

    As it happens, in the rare circumstances represented by Mantis #516,
    this can lead a compiler pass in the middle end (loop_inv.m)
    processing an invalid procedure, whose invalid contents unsurprisingly
    caused the abort. I thought such procedures should never be kept
    in the HLDS once the front end has done its job, but I was wrong.

    This diff restores the "status quo ante" by once again iterating over
    only the valid procedures, but fixes the inconsistency in another way:
    by replacing "all" with "valid" in the names of the affected predicates.

compiler/modes.m:
    The actual root cause of Mantis #516 lies *not* in passes_aux.m,
    but here, since it is modes.m that leaves the invalid procedure
    in the HLDS. Document both the scenario that caused Mantis #516,
    (which now causes only some overhead), and another performance problem.
    And document a probable correctness problem that this diff *does not* fix,
    for two reasons. First, the fix would require rewriting most or all
    of the mode inference mechanism; second, since we haven't bumped into it
    by now, we probably never will. (At least those of us who always declare
    the modes of all predicates.)

compiler/deforest.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/par_loop_control.m:
compiler/ssdebug.m:
compiler/structure_reuse.analysis.m:
compiler/structure_sharing.analysis.m:
    Conform to the name changes in passes_aux.m.

compiler/hlds_out_pred.m:
    Make it possible to diagnose problems with invalid procedures,
    like this one, by (a) actually *printing* invalid procedures as well as
    valid ones, but (b) *marking* them as being invalid.

tests/general/mode_inference_reorder.m:
    Bring up to date the programming style of the test case that exhibited
    the bug. Document its nonstandard naming scheme.
2020-08-08 04:23:49 +10: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
012530a7a9 Update programming style. 2020-04-30 16:00:58 +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
Peter Wang
3621cfa650 Delete deprecated substring predicates and functions.
library/string.m:
    Delete long-deprecated substring/3 function and substring/4 predicate.
    The newly introduced `string_piece' type has a substring/3 data
    constructor which takes (start, end) offsets into the base string,
    whereas the function and predicate take (start, count) arguments.
    To reduce potential confusion, delete the deprecated function and
    predicate.

    Delete other deprecated substring predicates and functions as well.

tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
    Delete tests for deprecated predicates.

tests/tabling/mercury_java_parser_dead_proc_elim_bug.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug2.m:
tests/valid/mercury_java_parser_follow_code_bug.m:
    Replace calls to unsafe_substring with unsafe_between.

NEWS:
    Announce the changes.
2019-11-08 14:25:23 +11:00
Peter Wang
d2c3ede17d Make string.replace_all with empty pattern preserve ill-formed sequences.
library/string.m:
    Define behaviour of string.replace_all on ill-formed code unit
    sequences when the pattern is empty.

    Implement that behaviour.

    Use better variable names in documentation of string.replace and
    string.replace_all.

tests/general/string_replace.exp:
tests/general/string_replace.exp2:
tests/general/string_replace.m:
    Extend test case.

    Update code style.
2019-11-08 13:57:38 +11:00
Peter Wang
8a3404d59c Extend string_replace test case.
tests/general/string_replace.exp:
tests/general/string_replace.m:
    As above.
2019-11-08 13:57:38 +11:00
Zoltan Somogyi
d704a883f8 Misc style cleanups. 2019-07-04 23:02:10 +02:00
Zoltan Somogyi
26cfe7bc19 Fix general/string_to_float for C# and Java.
Add an expected out file which expects the behavior on these backends,
which prints -0 as 0.

Update the programming style of the test source code.
2019-06-24 17:31:47 +02:00
Zoltan Somogyi
15df6f9323 Update the style of some tests. 2019-06-18 00:08:10 +02:00
Julien Fischer
e73d30ad85 More documentation of expected outputs.
tests/general/environment.m:
tests/general/read_dir_regression.m:
tests/general/string_format_tests.m:
tests/general/test_parsing_utils.m:
tests/general/test_string_to_int_overflow.m:
    As above.
2018-09-11 16:42:32 +10:00
Julien Fischer
ada4e79bdc Document how "next integer" operations handle infinite values.
Fix a test case failure in spf grades.

library/math.m:
     Document how the "next integer" operations handle arguments of infinite
     magnitude.

tests/general/float_test.m:
    s/ceil/ceiling/ in a spot.

    Test next integer operations with +/-infinity (and zero).

    In the erlang grades, avoid running parts of these tests that
    rely on library functionality that is NYI.

    Document what the expected outputs correspond to.

tests/general/float_test.exp:
    Update this expected output.

tests/general/float_test.exp2:
    Replace the contents of this file: previously it contained output for
    some ancient version of MSVC; it now contains the spf version of the
    output.

tests/general/float_test.exp3:
    A new expected output for the erlang grades.
2018-09-05 02:19:01 +00:00
Julien Fischer
3848d58571 Update syntax in a test case.
tests/general/float_test.m:
    As above; the actual test has not changed (yet).
2018-09-04 06:15:49 +00:00
Peter Wang
d8c59a8d79 Do not use stateful-error style in io.m; minor bug fixes.
library/io.m:
    Make remaining I/O primitives return error codes directly to Mercury
    wrapper predicates, instead of saving the error in a global variable
    to be looked up separately.

    Delete stateful-error predicates and global variables.

    Delete unnecessary foreign exported procedures.

    Add `no_error' helper function.

    Add `result_code' type to indicate whether a primitive succeeded,
    reach the end-of-file, or an error occurred.

    Make `read_char_code' and `read_byte_val' return the result code
    and error separately from the value.

    Add efficient implementations of `do_read_bitmap' for C# and Java.

    Add Java methods `read_pushback' and `read_non_pushback' for binary
    input streams to support `do_read_bitmap'.

    Use a purpose-specific type for the return value of
    `read_line_as_string_2'.

    Fix a bug: the C version of `read_line_as_string_2' returned -2
    (null character found) instead of -1 for an I/O error.

    Move Mercury value construction for `read_file_as_string' out of
    foreign procs.

    In C version of `read_char_code', if we hit EOF or an error in the
    middle of a multi-byte sequence then stop reading, and report `errno'
    or EILSEQ. The old code would try to read the rest of the multi-byte
    sequence and decode it, which should fail, then report EILSEQ.

    Simplify how `do_open_text' and `do_open_binary' report attempts to
    open directories as streams.

    Fix a bug: the C version of `read_symlink' passed the wrong buffer
    size to readlink(); fortunately it would only truncate very long
    symbolic link targets.

    Add comments for future changes.

tests/general/read_dir_regression.exp:
    Update expected error message.
2016-09-28 11:10:33 +10:00
Paul Bone
675b9ce087 Don't allow directories to be opened as files in C grades.
Some OSs allow you fopen a directory, which could cause confusion.  This
doesn't make sense for Mercury file streams so test for and raise an error
when this happens.

library/io.m:
    fstat files as we open them to determine if they are directories, if
    they are close them and return an error.

tests/general/read_dir_regression.m:
tests/general/read_dir_regression.exp:
tests/general/read_dir_regression.exp2:
tests/general/read_dir_regression.exp3:
tests/general/read_dir_regression.exp4:
    Update test case, differentiate between errors opening the file, and
    reading from the file.
2016-09-06 14:13:49 +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
16b54cf5fd Fix failure of general/environment in java grade.
tests/general/environment.exp2:
    Update to conform to recent changes.
2016-04-26 15:21:54 +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
Peter Wang
6a267a8f07 Make base_string_to_int check overflow/underflow for all bases.
Make base_string_to_int check for overflow and underflow when converting
from strings in all bases, not only base 10.  Fixes bug #376.

Previously it was stated that "numbers not in base 10 are assumed to
denote bit patterns and are not checked for overflow."  Though not a
safe assumption in general, in Mercury source files it is useful to be
able to write values with the high bit set, e.g. 0x80000000 on 32-bit
machines, that would be greater than max_int if interpreted as a
positive integer.

The changed behaviour of base_string_to_int would reject such literals
from Mercury sources, so additional changes are required to maintain
that usage.  However, unlike before, the compiler will report an
error if some non-zero bits of the literal would be discarded.

library/string.m:
	Enable overflow/underflow checking for base_string_to_int for
	any base.

	Update documentation.

library/lexer.m:
	Allow `big_integer' token functor to represent non-base 10
	literals as well.

	Add `integer_base' type.

library/term.m:
	Add `big_integer' term functor.

	Add `integer_base' type.

library/term_io.m:
	Add private helper functions `integer_base_int' and
	`integer_base_prefix'.

	Conform to changes.

library/parser.m:
	Pass through `big_integer' tokens as `big_integer' terms.

	Conform to changes.

compiler/prog_util.m:
	Add predicate to convert integer terms to ints with the
	aforementioned concession for bit patterns.

	`make_functor_cons_id' can now fail due to integer tokens
	exceeding the range of `int'.

compiler/superhomogeneous.m:
	Make `unravel_var_functor_unification' convert `big_integer'
	tokens on the RHS to a simple `int' with the aforementioned
	concession for bit patterns, or add an error message if any
	significant bits would be discarded.

compiler/fact_table.m:
compiler/mercury_to_mercury.m:
compiler/module_imports.m:
compiler/prog_io_util.m:
	Conform to changes.

compiler/make.util.m:
	Delete unused predicate.

tests/general/test_string_to_int_overflow.m:
tests/general/test_string_to_int_overflow.exp:
tests/general/test_string_to_int_overflow.exp2:
tests/general/test_string_to_int_overflow.exp3:
        Rewrite test case.

tests/hard_coded/lexer_bigint.exp:
tests/hard_coded/lexer_bigint.exp2:
tests/hard_coded/read_min_int.exp:
tests/hard_coded/read_min_int.exp2:
	Update expected outputs due to the lexer and term module changes.

tests/invalid/Mmakefile:
tests/invalid/invalid_int.err_exp:
tests/invalid/invalid_int.err_exp2:
tests/invalid/invalid_int.m:
	Add new test case.

NEWS:
	Announce the changes.
2015-02-17 12:14:16 +11:00
Peter Wang
c89017a096 Add integer.to_base_string.
library/integer.m:
	Add to_base_string/2.

tests/general/base_string_to_integer.exp:
tests/general/base_string_to_integer.m:
	Extend test case.

NEWS:
	Announce addition.
2015-02-17 12:14:16 +11:00
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the debugger tests,
    specify the new line numbers in .inp files and expect them in .exp files.
2015-02-14 20:14:03 +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
d9a1050af6 Flatten the test directories, step 1.
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:43:02 +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
Zoltan Somogyi
ae5b901254 Make the array_binsearch test work on 32 bit systems.
tests/general/array_binsearch.m:
    Don't build up the arrays to test using random numbers, since these
    produce different results on 32 and 64 bit systems. Instead, just
    use manifest constant terms that happen to be identical to what
    the random approach generated on 64 bit systems.
2014-12-26 23:31:26 +11:00
Zoltan Somogyi
35fe4814ce Fix Mantis bug #367.
library/array.m:
    When doing a binary search using a user-supplied comparison function,
    do not use the builtin term comparison operation to compare elements.

    Use separate loops for binary_search and approx_binary_search, since
    using the loop for approx_binary_search in the implementation of
    binary_search executes some unnecessary extra tests.

    Improve the documentation of both binary_search and approx_binary_search.

tests/general/array_binsearch.{m,exp}:
    Rewrite this test case to make it much tougher, testing the operation
    of binary_search and approx_binary_search with both the builtin and
    user-supplied comparison operations, and in the presence of repeated
    elements, and with automatic verification of the results.
2014-12-03 18:20:36 +11:00
Zoltan Somogyi
52ffbd1057 Generate better error messages for string.format.
library/string.format.m:
    We used to parse format strings, and pair up format specifiers with
    the list of input poly_types, using semidet code, throwing
    exceptions with generic messages if the semidet code failed.
    This diff switches to using det code that returns a list of
    situation-specific error messages. Since errors after the first
    may be caused by the first error, we now throw exceptions whose
    message is a detailed description of the first error, but that
    decision is easily changeable.

    Simplify some existing code.

tests/general/string_format_test_{2,3}.{exp,exp2,exp3,...}:
tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
    Update the expected error messages.
2014-11-15 19:38:53 +11:00
Julien Fischer
4e15777451 Standardise formatting of float special values.
The string representation of float special values is currently dependent on the
target language and, for C grades, the underlying platform.  As a result,
values like NaN and Infinity are being printed or converted into strings in
variety of ways.  (See, for example bug #348 in Mantis.)

This diff changes float->string conversion to detect float special values and
use a consistent string representation for them.

library/string.m:
library/io.m:
runtime/mercury_float.c:
    Check if a float is not-a-number or of infinite magnitude when converting
    floats into strings.  If so, then use a standard representation of the
    value: "nan" for not-a-number values, and "infinity" / "-infinity" for
    values of infinite magnitude.
    For uppercase conversion specifiers in format strings, we output the above
    strings in uppercase (e.g. "NAN", "INFINITY").

library/float.m:
    Add is_infinite/1 and is_nan_or_infinite/1 as synonyms for is_inf/1 and
    is_nan_or_inf/1 respectively.

    Group float classification predicates into their own section.  Upcoming
    change will add more of them.

NEWS:
    Announce the above changes.

tests/general/string_format_special_floats.m:
tests/general/string_format_special_floats.exp:
    Modify this test to check that we actually print float special values as
    above.

tests/hard_coded/write_float_special.exp:
    Conform to the above change.

tests/EXPECT_FAIL_TESTS.all_grades:
    Do not expect the write_float_special test case to fail any more since
    the expected outputs should be the same on every platform.
2014-09-16 14:27:26 +10: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
a3c59abaaa Fix weak pointer test.
This test was broken in non-C grades due to an omission.

general/weak_ptr.m:
general/weak_ptr.exp2:
    As above.
2014-08-01 15:21:31 +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
Julien Fischer
e1132d6eae Fix string.format with special float values in non-C grades.
The Mercury implementation of string formatting used by the non-C grades did
not handle the various special float values (i.e. nan, inf and -inf) correctly.
For example, nan was with the '%f' conversion specifier was being formatted as
"nan.0".  Similarly, for -inf and inf.

library/string.m:
	In the Mercury implementation of string formatting handle special
	float values correctly.  (We format them as per C99.)

tests/general/string_format_special_floats.{m,exp}:
	Extend this test to cover the capitalized versions of the float
	conversion specifiers.

	Update the formatting of this module.
NEWS:
	Announce the above fix.
2014-06-30 14:50:22 +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
Peter Wang
bfe14f9128 Fix string.base_string_to_int succeeding incorrectly.
string.base_string_to_int would incorrectly succeed on an input string
containing a code point of multiple code units.  string.foldl_between
expects the length of the string in code units, but was passed the
length of the string in code points.

library/string.m:
	As above.

tests/general/base_string_to_int_test.exp:
tests/general/base_string_to_int_test.m:
	Extend test case.
2013-02-11 11:04:21 +11:00
Julien Fischer
b635ebf80b Convert .cvsignore -> .gitignore files in tests directory.
tests/*/.cvsignore:
    As above.

library/.gitignore:
    Ignore files generated by the namespace cleanliness check.
2013-01-07 14:33:25 +11:00
Peter Wang
a5797d6cf9 Let float_literal, float_literal_as_string accept an optional plus sign
Branches: main, 11.07

library/parsing_utils.m:
	Let float_literal, float_literal_as_string accept an optional plus sign
	in the exponent.  This matches the syntax for Mercury and many other
	languages.

tests/general/test_parsing_utils.m:
tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.exp2:
	Update test case.
2012-06-13 06:41:56 +00:00
Julien Fischer
b2f25476d0 Fix bug #248: make the argument order of the singleton_set/2 predicates in the
Branches: main, 11.07 (partial)

Fix bug #248: make the argument order of the singleton_set/2 predicates in the
various set modules in the standard library consistent.  (This breaks backwards
compatibility but in a fairly minor way.)

Add the predicate is_singleton/2 to those set modules that do not already
provide it.

Fix a bug in the implementation of set_unordlist.singleton_set/2.

library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_unordlist.m:
	Swap the argument order of singleton_set/2.

	Add is_singleton/2 where it wasn't already present.

library/set_unordlist.m:
	Fix a bug: singleton_set/2 failed to take account of
	the fact that the representation could contain duplicates
	in the singleton_setT::out, set_unordlist(T)::in) mode.
	The fix is to sort and remove the duplicates before checking
	whether the set is singleton.

NEWS:
	Announce the above changes.

library/eqvclass.m:
library/tree234.m:
compiler/accumulator.m:
compiler/code_info.m:
compiler/graph_colour.m:
compiler/higher_order.m:
compiler/lp_rational.m:
compiler/ml_tag_switch.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/proc_gen.m:
compiler/prog_mode.m:
compiler/term_pass1.m:
compiler/type_constraints.m:
compiler/unneeded_code.m:
compiler/var_locn.m:
deep_profiler/autopar_costs.m:
deep_profiler/var_use_analysis.m:
tests/general/set_test.m:
	Conform to the above changes.

tests/hard_coded/Mmakefile:
tests/hard_coded/singleton_dups.{m,exp}:
	Add a regression test for the problem with set_unordlist.singleton_set/2.
2012-01-17 15:49:47 +00:00
Julien Fischer
a60beb42e7 Make the none.gc.memprof grade work with MSVC again.
Branches: main, 11.07

Make the none.gc.memprof grade work with MSVC again.

Avoid more warnings when compiling with MSVC.

compiler/layout_out.m:
	Avoid an incomplete type in the declaration of the alloc_sites
	array.  (Similar changes need to be made for the layout structures
	related to debugging and deep profiling - I am in the process of
	testing the former, the latter doesn't currently work on Windows
	any way.)

browser/listing.m:
	Use don't-care variables in some foreign_procs.
	This avoids warnings about assignments from uninitialized
	variables with MSVC.

*/.cvsignore:
	Update cvsignore entries.

	Ignore files generated by mprof.
2011-10-20 06:37:35 +00: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
Peter Wang
0b8a0e1941 parsing_utils.src_to_line_numbers crashed if given an input string
Branches: main, 11.07

parsing_utils.src_to_line_numbers crashed if given an input string
containing multi-code-unit characters, i.e. non-ASCII.

library/parsing_utils.m:
	Rewrite src_to_line_numbers.

tests/general/test_parsing_utils.exp:
tests/general/test_parsing_utils.m:
	Add test case.

tests/general/test_parsing_utils.exp2:
	Add expected output for grades using UTF-16 string encoding.
2011-09-05 06:15:32 +00:00
Zoltan Somogyi
a96d918a00 Remove an unnecessary RCS id string from the source code, since it can
Estimated hours taken: 0.1
Branches: main

tests/general/mode_inf_bug.m:
	Remove an unnecessary RCS id string from the source code, since it can
	generate spurious differences on machines with different versions of
	CVS.
2011-09-01 03:20:59 +00:00
Peter Wang
b1af59cb29 Deprecate string.substring, string.foldl_substring, etc. in favour of
Branches: main

Deprecate string.substring, string.foldl_substring, etc. in favour of
new procedures named string.between, string.foldl_between, etc.
The "between" procedures take a pair of [Start, End) endpoints instead
of Start, Count arguments.  The reasons for this change are:

- the "between" procedures are more convenient

- "between" should be unambiguous.  You can guess that it takes an End
  argument instead of a Count argument without looking up the manual.

- Count arguments necessarily counted code units, but when working with
  non-ASCII strings, almost the only way that the values would be arrived at
  is by substracting one end point from another.

- it paves the way for a potential change to replace string offsets with an
  abstract type.  We cannot do that if users regularly have to perform a
  subtraction between two offsets.

library/string.m:
	Add string.foldl_between, string.foldl2_between,
	string.foldr_between, string.between.

	Deprecate the old substring names.

	Replace string.substring_by_codepoint by string.between_codepoints.

compiler/elds_to_erlang.m:
compiler/error_util.m:
compiler/rbmm.live_variable_analysis.m:
compiler/timestamp.m:
extras/posix/samples/mdprof_cgid.m:
library/bitmap.m:
library/integer.m:
library/lexer.m:
library/parsing_utils.m:
mdbcomp/trace_counts.m:
profiler/demangle.m:
	Conform to changes.

tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
	Test both between and substring procedures.

tests/hard_coded/string_codepoint.exp:
tests/hard_coded/string_codepoint.exp2:
tests/hard_coded/string_codepoint.m:
	Update names in test outputs.

NEWS:
	Announce the change.
2011-06-15 01:05:34 +00:00