Commit Graph

331 Commits

Author SHA1 Message Date
Zoltan Somogyi
d769b04a96 Base string.format_table{,_max} on common code.
library/string.m:
    Even though format_table_max is a minor tweak on format_table,
    its implementation used to be completely separate. Act on an old XXX
    and make format_table use the same primitive ops as format_table_max.

    Document the operation of format_table a bit better.

    Change the way that format_table_max handles column-width limits,
    by accepting overlong column contents *without* starting a new line.
    Document the new semantics.

    Use predmode decls when possible.

tests/general/string_test.{m,exp}:
    Add a test of format_table_max, which previously did not have one.
2023-05-22 19:23:37 +10:00
Julien Fischer
f3a34e4651 Replace uses of __ as a module qualifier.
samples/muz.zbstract.m:
tests/*/*.m:
    As above.
2022-04-14 20:25:10 +10:00
Zoltan Somogyi
c02eb5163e Carve io.{call_system,environment}.m out of io.m.
library/io.call_system.m:
    Move the code in the "system access predicates" section of io.m
    to this new module.

library/io.environment.m:
    Move the predicates dealing with environment variables in io.m
    to this new module.

library/io.m:
    Delete the code moved to the new modules.

    Leave behind in io.m "forwarding predicates", predicates that do nothing
    except call the moved predicates in the new modules, to provide backward
    compatibility. But do mark the forwarding predicates as obsolete,
    to tell people to update their (at their leisure, since the obsoleteness
    warning can be turned off).

    Also leave behind in io.m the definitions of the types used
    by some parameters of some of the moved predicates.

library/MODULES_DOC:
    List the new modules among the documented modules.

library/library.m:
    List the new modules, including io.file.m (added in a previous change)
    among the documented standard library modules.

NEWS:
    Announce the changes.

browser/browse.m:
browser/interactive_query.m:
compiler/fact_table.m:
compiler/handle_options.m:
compiler/make.module_target.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/optimize.m:
compiler/options_file.m:
deep_profiler/conf.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_test.m:
library/io.file.m:
mdbcomp/trace_counts.m:
ssdb/ssdb.m:
tests/general/environment.m:
tests/hard_coded/closeable_channel_test.m:
tests/hard_coded/setenv.m:
tests/hard_coded/system_sort.m:
    Call the moved predicates directly in their new modules,
    not indirectly through io.m.
2022-03-08 09:38:27 +11:00
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
cd4d855390 Delete read_term* predicates from term_io.m.
Their replacements are the corresponding predicates in mercury_term_parser.m,
which they forwarded all their work to anyway.

library/term_io.m:
    As above.

library/mercury_term_parser.m:
    Move the definition of a type needed by the read_term* predicates
    here from term_io.m.

NEWS:
    Document the deletion.

browser/interactive_query.m:
compiler/fact_table.m:
compiler/parse_module.m:
compiler/recompilation.used_file.m:
library/io.m:
    Conform to the change above.

tests/debugger/interpreter.m:
tests/general/interpreter.m:
    Use read_term* from mercury_term_parser, not term_io.

    These two tests started out as versions of the same file once upon a time,
    but have diverged since. Replace them both with a single version that
    works in both test directories, and has updated programming style.

tests/debugger/interpreter.exp2:
tests/debugger/interpreter.inp:
tests/general/interpreter.exp:
    Conform to the changes (renames of some predicates, inlining of others,
    using explicit streams, never complaining about empty argument lists,
    and always printing query results) in interpreter.m.

tests/hard_coded/bug383.m:
tests/hard_coded/term_io_test.m:
    Use read_term* from mercury_term_parser, not term_io.

    In bug383.m, resolve an old type ambiguity to avoid a warning.
2022-03-04 12:58:17 +11:00
Zoltan Somogyi
3beb6b8eb8 Fix non-rafeism. 2021-09-29 22:50:39 +10:00
Zoltan Somogyi
3445e21ce4 Fix rafe-isms. 2021-09-28 02:15:35 +10:00
Zoltan Somogyi
ecb5e4a9e6 Update the style of many test cases.
tests/declarative_debugger/*.m:
tests/exceptions/*.m:
tests/general/*.m:
tests/grade_subdirs/*.m:
tests/purity/*.m:
tests/submodules/*.m:
tests/typeclasses/*.m:
    Update programming style.

tests/declarative_debugger/*.inp:
    Update line numbers in breakpoint commands.
tests/declarative_debugger/*.exp:
    Update expected line numbers.

tests/exceptions/Mercury.options:
tests/general/Mercury.options:
    Disable some warnings that are irrelevant to the test.
2021-07-25 23:26:17 +10:00
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