Files
mercury/tests/debugger/interactive.exp
Julien Fischer 4bbc1e48eb Make mdb interactive queries work on OS X.
browser/interactive_query.m:
    Use '.dylib' as the extension for the shared library we generate for
    interactive queries when on OS X.  (While '.so' would work in principle,
    its use is unusual on OS X and the Mercury compiler will always use
    '.dylib' anyway.)

    Replace some sequences of I/O operations with single calls to io.format
    so that message components are not spread over multiple lines.

    Add an XXX comment about object file extensions.

    Update comments that refer to 'libquery' rather than 'libmdb_query'.

README.MacOS:
    Delete interactive queries from the list of unsupported features.

tests/debugger/interactive.exp:
    Update this expected output.  The changes are due to earlier
    changes to the formatting and presentation of error messages.
2015-08-21 22:15:30 +10:00

135 lines
6.0 KiB
Plaintext

1: 1 1 CALL pred interactive.main/2-0 (cc_multi) interactive.m:23
mdb> echo on
Command echo enabled.
mdb> query interactive list
?- append(X, Y, ['a', 'b', 'c']).
<stdin>:026: Inferred :- pred query(list.list(character),
<stdin>:026: list.list(character)).
<stdin>:026: Inferred :- mode query(out, out) is multi.
X = [], Y = ['a', 'b', 'c'], true ;
X = ['a'], Y = ['b', 'c'], true ;
X = ['a', 'b'], Y = ['c'], true ;
X = ['a', 'b', 'c'], Y = [], true ;
fail.
No (more) solutions.
?- qperm([1,2,3], List).
<stdin>:026: Inferred :- pred query(list.list(int)).
<stdin>:026: Inferred :- mode query(out) is nondet.
List = [1, 2, 3], true ;
List = [1, 3, 2], true ;
List = [2, 1, 3], true ;
List = [2, 3, 1], true ;
List = [3, 1, 2], true ;
List = [3, 2, 1], true ;
fail.
No (more) solutions.
?- qperm([1,2,3], List), List = [2 | _].
<stdin>:001: In clause for predicate `mdb_query.query'/2:
<stdin>:001: warning: variable `_2' occurs more than once in this scope.
<stdin>:013: In clause for predicate `mdb_query.run'/2:
<stdin>:013: warning: variable `_2' occurs more than once in this scope.
<stdin>:014: In clause for predicate `mdb_query.run'/2:
<stdin>:014: warning: variable `_2' occurs more than once in this scope.
<stdin>:015: In clause for predicate `mdb_query.run'/2:
<stdin>:015: warning: variable `_2' occurs more than once in this scope.
<stdin>:026: In clause for predicate `mdb_query.query'/2:
<stdin>:026: warning: variable `_2' occurs more than once in this scope.
<stdin>:026: Inferred :- pred query(list.list(int), list.list(int)).
<stdin>:026: Inferred :- mode query(out, out) is nondet.
List = [2, 1, 3], _2 = [1, 3], true ;
List = [2, 3, 1], _2 = [3, 1], true ;
fail.
No (more) solutions.
?- qperm([1,2,3], List), List = [4 | _].
<stdin>:001: In clause for predicate `mdb_query.query'/2:
<stdin>:001: warning: variable `_2' occurs more than once in this scope.
<stdin>:013: In clause for predicate `mdb_query.run'/2:
<stdin>:013: warning: variable `_2' occurs more than once in this scope.
<stdin>:014: In clause for predicate `mdb_query.run'/2:
<stdin>:014: warning: variable `_2' occurs more than once in this scope.
<stdin>:015: In clause for predicate `mdb_query.run'/2:
<stdin>:015: warning: variable `_2' occurs more than once in this scope.
<stdin>:026: In clause for predicate `mdb_query.query'/2:
<stdin>:026: warning: variable `_2' occurs more than once in this scope.
<stdin>:026: Inferred :- pred query(list.list(int), list.list(int)).
<stdin>:026: Inferred :- mode query(out, out) is nondet.
fail.
No (more) solutions.
?- qperm([1,2,"foo"], List).
<stdin>:001: In clause for predicate `query'/1:
<stdin>:001: in argument 1 of call to predicate `qperm'/2:
<stdin>:001: in list element #2:
<stdin>:001: type error in unification of argument
<stdin>:001: and constant `"foo"'.
<stdin>:001: argument has type `int',
<stdin>:001: constant `"foo"' has type `string'.
For more information, recompile with `-E'.
Compilation error(s) occurred.
?- qperm(List, [1]).
<stdin>:014: In clause for `run(di, uo)':
<stdin>:014: in call to predicate `mdb_query.query'/1:
<stdin>:014: mode error: argument `List' has the following inst:
<stdin>:014: free
<stdin>:014: which does not match any of the valid modes for the callee,
<stdin>:014: because of the following error.
<stdin>:026: In clause for `query(out(not_reached))':
<stdin>:026: in argument 1 of call to predicate `interactive.qperm'/2:
<stdin>:026: mode error: variable `HeadVar__2' has instantiatedness `free',
<stdin>:026: expected instantiatedness was `ground'.
<stdin>:026: Inferred :- pred query(list.list(int)).
For more information, recompile with `-E'.
Compilation error(s) occurred.
?- quit.
mdb> cc_query interactive list
?- append(X, Y, ['a', 'b', 'c']).
<stdin>:017: Inferred :- pred query(list.list(character),
<stdin>:017: list.list(character)).
<stdin>:017: Inferred :- mode query(out, out) is multi.
X = [], Y = ['a', 'b', 'c'], true.
?- qperm([1,2,3], List).
<stdin>:017: Inferred :- pred query(list.list(int)).
<stdin>:017: Inferred :- mode query(out) is nondet.
List = [1, 2, 3], true.
?- qperm([1,2,3], List), List = [2 | _].
<stdin>:001: In clause for predicate `mdb_query.query'/2:
<stdin>:001: warning: variable `_2' occurs more than once in this scope.
<stdin>:011: In clause for predicate `mdb_query.run'/2:
<stdin>:011: warning: variable `_2' occurs more than once in this scope.
<stdin>:012: In clause for predicate `mdb_query.run'/2:
<stdin>:012: warning: variable `_2' occurs more than once in this scope.
<stdin>:017: In clause for predicate `mdb_query.query'/2:
<stdin>:017: warning: variable `_2' occurs more than once in this scope.
<stdin>:017: Inferred :- pred query(list.list(int), list.list(int)).
<stdin>:017: Inferred :- mode query(out, out) is nondet.
List = [2, 1, 3], _2 = [1, 3], true.
?- qperm([1,2,3], List), List = [4 | _].
<stdin>:001: In clause for predicate `mdb_query.query'/2:
<stdin>:001: warning: variable `_2' occurs more than once in this scope.
<stdin>:011: In clause for predicate `mdb_query.run'/2:
<stdin>:011: warning: variable `_2' occurs more than once in this scope.
<stdin>:012: In clause for predicate `mdb_query.run'/2:
<stdin>:012: warning: variable `_2' occurs more than once in this scope.
<stdin>:017: In clause for predicate `mdb_query.query'/2:
<stdin>:017: warning: variable `_2' occurs more than once in this scope.
<stdin>:017: Inferred :- pred query(list.list(int), list.list(int)).
<stdin>:017: Inferred :- mode query(out, out) is nondet.
No solution.
?- quit.
mdb> io_query interactive list
run <-- main.
[1, 3, 5, 2, 4]
run <-- if { append(X, Y, ['a', 'b', 'c']) } then print("X = "), print(X), print(", Y = "), print(Y), nl else print("No solution\n").
X = [], Y = ['a', 'b', 'c']
run <-- if { qperm([1,2,3], List) } then print(List), nl else [].
[1, 2, 3]
run <-- if { qperm([1,2,3], List), List = [2 | _] } then print(List), nl else { true }.
[2, 1, 3]
run <-- if { qperm([1,2,3], List), List = [4 | _] } then print(List), nl else print("No solution, as expected."), io__nl.
No solution, as expected.
run <-- quit.
mdb> continue -n -S
[1, 3, 5, 2, 4]