Commit Graph

4 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
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
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