Commit Graph

2 Commits

Author SHA1 Message Date
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
Julien Fischer
696829e6c1 Fix problems with the char module.
(1) The behaviour of digit_to_int/2 was inconsistent with that of is_digit/2.
The former succeeds for all of 0-9, a-z and A-Z while the latter succeeds only
for 0-9 (i.e. it was possible for digit_to_int/2 to succeed for non-decimal
characters, which is not what was intended in many of it uses).

(2) Predicates involving hexadecimal digits were inconsistently named, they
were "hex digits" in one predicate name, "hex chars" in another.

This change ensures that the following operations are supported for binary,
octal, decimal and hexadecimal digits and that we use a consistent naming
scheme for the predicates that implement them:
    - testing if a character is a digit of the given base
    - conversion to an int
    - conversion from an int

In addition, we also add predicates for supporting these operations for user
defined bases, ranging from 2-36.

library/char.m:
    Add the predicate is_decimal_digit/1, which is a synonym for is_digit/1.

    Add the predicate is_base_digit/2.

    Add the predicates int_to_{binary,octal,decimal,hex}_digit/2 and
    base_int_to_digit/3.

    Add the predicates {binary,octal,decimal,hex}_digit_to_int/2 and
    base_digit_to_int/3.

    Add det function versions of the above.

    Delete the function det_digit_to_int/1 that I added the other day.

    Mark the following as obsolete:
        - is_hex_digit/2
        - int_to_hex_char/2
        - int_to_digit/2
        - det_int_to_digit/1
        - det_int_to_digit/2

    Avoid redundant module qualification in the implementation.

    Mark some C foreign_procs as not modifying the trail.

    Re-order some declarations according to how the coding standard says they
    should be ordered.

library/bitmap.m:
library/integer.m:
library/parsing_utils.m:
library/string.m:
compiler/prog_rep_tables.m:
    Replace calls to obsolete predicates or functions.

NEWS:
    Announce the above changes.

    Add note advising users of digit_to_int/2 to check their code for the
    problem described above.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_char_digits.m:
tests/hard_coded/test_char_digits.exp:
    Add a systematic test for the above predicates.
2014-09-12 01:16:00 +10:00