[m-rev.] diff: io.write and pretty-printing for version_arrays
Julien Fischer
juliensf at csse.unimelb.edu.au
Sat May 21 02:52:19 AEST 2011
Branches: main
Make io.write and the two pretty-printers in the standard library handle
version arrays in a similar way to normal arrays.
library/pprint.m:
library/pretty_printer.m:
library/stream.string_writer.m:
As above.
library/version_array.m:
Add a function for converting a version_array to a pretty_printer.doc
value.
tests/hard_coded/pretty_printing.{m,exp}:
tests/hard_coded/test_pretty_printer_defaults.{m,exp}:
tests/hard_coded/write.{m,exp}:
Include printing version_arrays in these tests.
Julien.
Index: library/pprint.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/pprint.m,v
retrieving revision 1.30
diff -u -r1.30 pprint.m
--- library/pprint.m 17 May 2011 05:37:30 -0000 1.30
+++ library/pprint.m 20 May 2011 07:06:48 -0000
@@ -377,6 +377,7 @@
:- import_module sparse_bitset.
:- import_module term.
:- import_module type_desc.
+:- import_module version_array.
%-----------------------------------------------------------------------------%
@@ -685,6 +686,9 @@
else if dynamic_cast_to_array(X, Array)
then array_to_doc(Depth, Array)
+ else if dynamic_cast_to_version_array(X, VersionArray)
+ then version_array_to_doc(Depth, VersionArray)
+
else if dynamic_cast_to_tuple(X, Tuple)
then tuple_to_doc(Depth, Tuple)
@@ -818,10 +822,10 @@
[ArgTypeDesc] = type_args(type_of(X)),
% Convert ArgTypeDesc to a type variable ArgType.
- (_ `with_type` ArgType) `has_type` ArgTypeDesc,
+ (_ : ArgType) `has_type` ArgTypeDesc,
% Constrain the type of V to be var(ArgType) and do the cast.
- dynamic_cast(X, V `with_type` var(ArgType)).
+ dynamic_cast(X, V : var(ArgType)).
%-----------------------------------------------------------------------------%
@@ -829,13 +833,13 @@
is semidet.
dynamic_cast_to_sparse_bitset_of_int(X, A) :-
- dynamic_cast(X, A `with_type` sparse_bitset(int)).
+ dynamic_cast(X, A : sparse_bitset(int)).
:- some [T2] pred dynamic_cast_to_sparse_bitset_of_var(T1::in,
sparse_bitset(var(T2))::out) is semidet.
dynamic_cast_to_sparse_bitset_of_var(X, A) :-
- dynamic_cast(X, A `with_type` sparse_bitset(var)).
+ dynamic_cast(X, A : sparse_bitset(var)).
%-----------------------------------------------------------------------------%
@@ -846,10 +850,25 @@
[ArgTypeDesc] = type_args(type_of(X)),
% Convert ArgTypeDesc to a type variable ArgType.
- (_ `with_type` ArgType) `has_type` ArgTypeDesc,
+ (_ : ArgType) `has_type` ArgTypeDesc,
% Constrain the type of A to be array(ArgType) and do the cast.
- dynamic_cast(X, A `with_type` array(ArgType)).
+ dynamic_cast(X, A : array(ArgType)).
+
+%-----------------------------------------------------------------------------%
+
+:- some [T2] pred dynamic_cast_to_version_array(T1::in,
+ version_array(T2)::out) is semidet.
+
+dynamic_cast_to_version_array(X, VA) :-
+ % If X is a version array then it has a type with one type argument.
+ [ArgTypeDesc] = type_args(type_of(X)),
+
+ % Convert ArgTypeDesc to a type variable ArgType.
+ (_ : ArgType) `has_type` ArgTypeDesc,
+
+ % Constrain the type of VA to be array(ArgType) and do the cast.
+ dynamic_cast(X, VA : version_array(ArgType)).
%-----------------------------------------------------------------------------%
@@ -860,10 +879,10 @@
[ArgTypeDesc] = type_args(type_of(X)),
% Convert ArgTypeDesc to a type variable ArgType.
- (_ `with_type` ArgType) `has_type` ArgTypeDesc,
+ (_ : ArgType) `has_type` ArgTypeDesc,
% Constrain the type of L to be list(ArgType) and do the cast.
- dynamic_cast(X, L `with_type` list(ArgType)).
+ dynamic_cast(X, L : list(ArgType)).
%-----------------------------------------------------------------------------%
@@ -874,11 +893,11 @@
[KeyTypeDesc, ValueTypeDesc] = type_args(type_of(X)),
% Convert the TypeDescs to type variables.
- (_ `with_type` KeyType) `has_type` KeyTypeDesc,
- (_ `with_type` ValueType) `has_type` ValueTypeDesc,
+ (_ : KeyType) `has_type` KeyTypeDesc,
+ (_ : ValueType) `has_type` ValueTypeDesc,
% Constrain the type of M to be map(KeyType, ValueType) and do the cast.
- dynamic_cast(X, M `with_type` map(KeyType, ValueType)).
+ dynamic_cast(X, M : map(KeyType, ValueType)).
%-----------------------------------------------------------------------------%
@@ -890,12 +909,12 @@
[KeyTypeDesc, ValueTypeDesc] = type_args(type_of(X)),
% Convert the TypeDescs to type variables.
- (_ `with_type` KeyType) `has_type` KeyTypeDesc,
- (_ `with_type` ValueType) `has_type` ValueTypeDesc,
+ (_ : KeyType) `has_type` KeyTypeDesc,
+ (_ : ValueType) `has_type` ValueTypeDesc,
% Constrain the type of MP to be map_pair(KeyType, ValueType)
% and do the cast.
- dynamic_cast(X, MP `with_type` map_pair(KeyType, ValueType)).
+ dynamic_cast(X, MP : map_pair(KeyType, ValueType)).
%-----------------------------------------------------------------------------%
@@ -915,10 +934,10 @@
[ArgTypeDesc] = type_args(type_of(X)),
% Convert ArgTypeDesc to a type variable ArgType.
- (_ `with_type` ArgType) `has_type` ArgTypeDesc,
+ (_ : ArgType) `has_type` ArgTypeDesc,
% Constrain the type of R to be robdd(ArgType) and do the cast.
- dynamic_cast(X, R `with_type` robdd(ArgType)).
+ dynamic_cast(X, R : robdd(ArgType)).
%-----------------------------------------------------------------------------%
@@ -956,6 +975,17 @@
group("array" ++ parentheses(list_to_doc(Depth - 1, array.to_list(A)))).
%-----------------------------------------------------------------------------%
+
+ % XXX Ideally we'd just walk the version array. But that's an optimization
+ % for another day.
+ %
+:- func version_array_to_doc(int, version_array(T)) = doc.
+
+version_array_to_doc(Depth, A) =
+ group("version_array"
+ ++ parentheses(list_to_doc(Depth - 1, version_array.to_list(A)))).
+
+%-----------------------------------------------------------------------------%
% This should only really be used if the item in question really
% is a tuple.
Index: library/pretty_printer.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/pretty_printer.m,v
retrieving revision 1.18
diff -u -r1.18 pretty_printer.m
--- library/pretty_printer.m 17 May 2011 05:37:30 -0000 1.18
+++ library/pretty_printer.m 20 May 2011 07:12:46 -0000
@@ -252,6 +252,7 @@
:- import_module string.
:- import_module term_io.
:- import_module tree234. % For tree234_to_doc.
+:- import_module version_array. % For version_array_to_doc.
%-----------------------------------------------------------------------------%
@@ -1084,7 +1085,9 @@
set_formatter_sv("builtin", "string", 0, fmt_string, !Formatters),
set_formatter_sv("array", "array", 1, fmt_array, !Formatters),
set_formatter_sv("list", "list", 1, fmt_list, !Formatters),
- set_formatter_sv("tree234", "tree234", 2, fmt_tree234, !Formatters).
+ set_formatter_sv("tree234", "tree234", 2, fmt_tree234, !Formatters),
+ set_formatter_sv("version_array", "version_array", 1, fmt_version_array,
+ !Formatters).
%-----------------------------------------------------------------------------%
@@ -1140,6 +1143,22 @@
%-----------------------------------------------------------------------------%
+:- func fmt_version_array(univ, list(type_desc)) = doc.
+
+fmt_version_array(Univ, ArgDescs) =
+ ( if
+ ArgDescs = [ArgDesc],
+ has_type(_Arg : T, ArgDesc),
+ Value = univ_value(Univ),
+ dynamic_cast(Value, X : version_array(T))
+ then
+ version_array_to_doc(X)
+ else
+ str("?version_array?")
+ ).
+
+%-----------------------------------------------------------------------------%
+
:- func fmt_list(univ, list(type_desc)) = doc.
fmt_list(Univ, ArgDescs) =
Index: library/stream.string_writer.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/stream.string_writer.m,v
retrieving revision 1.6
diff -u -r1.6 stream.string_writer.m
--- library/stream.string_writer.m 10 Jun 2009 03:31:57 -0000 1.6
+++ library/stream.string_writer.m 20 May 2011 06:33:51 -0000
@@ -183,6 +183,7 @@
:- import_module rtti_implementation.
:- import_module term_io.
:- import_module type_desc.
+:- import_module version_array.
put_int(Stream, Int, !State) :-
(
@@ -399,6 +400,16 @@
det_univ_to_type(Univ, Array),
write_array(Stream, Array, !State)
;
+ type_ctor_and_args(univ_type(Univ), TypeCtor, ArgTypes),
+ ArgTypes = [ElemType],
+ type_ctor_name(TypeCtor) = "version_array",
+ type_ctor_module_name(TypeCtor) = "version_array"
+ ->
+ has_type(Elem, ElemType),
+ same_version_array_elem_type(VersionArray, Elem),
+ det_univ_to_type(Univ, VersionArray),
+ write_version_array(Stream, VersionArray, !State)
+ ;
% Check if the type is private_builtin.type_info/1.
% See the comments above for array.array/1.
@@ -419,6 +430,11 @@
same_array_elem_type(_, _).
+:- pred same_version_array_elem_type(version_array(T)::unused, T::unused)
+ is det.
+
+same_version_array_elem_type(_, _).
+
:- pred same_private_builtin_type(private_builtin.type_info::unused,
T::unused) is det.
@@ -766,6 +782,18 @@
write(Stream, List, !State),
put(Stream, ")", !State).
+:- pred write_version_array(Stream::in, version_array(T)::in,
+ State::di, State::uo) is det <= (stream.writer(Stream, string, State),
+ stream.writer(Stream, char, State)).
+:- pragma type_spec(write_version_array/4,
+ (Stream = io.output_stream, State = io.state)).
+
+write_version_array(Stream, VersionArray, !State) :-
+ put(Stream, "version_array(", !State),
+ List = version_array.to_list(VersionArray),
+ write(Stream, List, !State),
+ put(Stream, ")", !State).
+
:- pred write_private_builtin_type_info(Stream::in,
private_builtin.type_info::in, State::di, State::uo) is det
<= stream.writer(Stream, string, State).
Index: library/version_array.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/version_array.m,v
retrieving revision 1.34
diff -u -r1.34 version_array.m
--- library/version_array.m 20 May 2011 04:16:53 -0000 1.34
+++ library/version_array.m 20 May 2011 07:12:16 -0000
@@ -52,6 +52,9 @@
:- interface.
:- import_module list.
+:- import_module pretty_printer.
+
+%-----------------------------------------------------------------------------%
:- type version_array(T).
@@ -211,6 +214,10 @@
%
:- func unsafe_rewind(version_array(T)) = version_array(T).
:- pred unsafe_rewind(version_array(T)::in, version_array(T)::out) is det.
+
+ % Convert a version_array to a pretty_printer.doc for formatting.
+ %
+:- func version_array_to_doc(version_array(T)) = pretty_printer.doc.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -1797,5 +1804,23 @@
").
%-----------------------------------------------------------------------------%
+
+version_array_to_doc(A) =
+ indent([str("version_array(["), version_array_to_doc_2(0, A), str("])")]).
+
+:- func version_array_to_doc_2(int, version_array(T)) = doc.
+
+version_array_to_doc_2(I, A) =
+ ( if I > version_array.max(A) then
+ str("")
+ else
+ docs([
+ format_arg(format(A ^ elem(I))),
+ ( if I = version_array.max(A) then str("") else group([str(", "), nl]) ),
+ format_susp((func) = version_array_to_doc_2(I + 1, A))
+ ])
+ ).
+
+%-----------------------------------------------------------------------------%
:- end_module version_array.
%-----------------------------------------------------------------------------%
Index: tests/hard_coded/pretty_printing.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/pretty_printing.exp,v
retrieving revision 1.1
diff -u -r1.1 pretty_printing.exp
--- tests/hard_coded/pretty_printing.exp 2 Nov 2001 00:50:53 -0000 1.1
+++ tests/hard_coded/pretty_printing.exp 20 May 2011 16:21:05 -0000
@@ -4,6 +4,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{...}
{...}
@@ -57,6 +59,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{...}
{...}
@@ -88,6 +92,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{...}
{...}
@@ -110,6 +116,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -163,6 +171,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -194,6 +204,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -216,6 +228,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -269,6 +283,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -300,6 +316,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -322,6 +340,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -375,6 +395,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -406,6 +428,8 @@
[...]
array([...])
array([...])
+version_array([...])
+version_array([...])
{}
{...}
{...}
@@ -428,6 +452,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{1}
{1, 2}
@@ -481,6 +507,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{1}
{1, 2}
@@ -512,6 +540,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{1}
{1, 2}
@@ -534,6 +564,8 @@
[1]
array([[1]])
array([[1]])
+version_array([[1]])
+version_array([[1]])
{}
{1}
{1, 2}
@@ -588,6 +620,8 @@
[1]
array([[1]])
array([[1]])
+version_array([[1]])
+version_array([[1]])
{}
{1}
{1, 2}
@@ -619,6 +653,8 @@
[1]
array([[1]])
array([[1]])
+version_array([[1]])
+version_array([[1]])
{}
{1}
{1, 2}
@@ -645,6 +681,12 @@
[1, 2, ...],
[1, 2, ...],
[1, 2, ...]])
+version_array([
+ [1], [1], [1]])
+version_array([
+ [1, 2, ...],
+ [1, 2, ...],
+ [1, 2, ...]])
{}
{1}
{1, 2}
@@ -713,6 +755,9 @@
array([[1], [1], [1]])
array([[1, 2, ...], [1, 2, ...],
[1, 2, ...]])
+version_array([[1], [1], [1]])
+version_array([[1, 2, ...],
+ [1, 2, ...], [1, 2, ...]])
{}
{1}
{1, 2}
@@ -749,6 +794,8 @@
[1, 2, 3]
array([[1], [1], [1]])
array([[1, 2, ...], [1, 2, ...], [1, 2, ...]])
+version_array([[1], [1], [1]])
+version_array([[1, 2, ...], [1, 2, ...], [1, 2, ...]])
{}
{1}
{1, 2}
@@ -776,6 +823,12 @@
[1, 2, ...],
[1, 2, ...],
[1, 2, ...], ...])
+version_array([
+ [1], [1], [1], ...])
+version_array([
+ [1, 2, ...],
+ [1, 2, ...],
+ [1, 2, ...], ...])
{}
{1}
{1, 2}
@@ -857,6 +910,9 @@
array([[1], [1], [1], ...])
array([[1, 2, ...], [1, 2, ...],
[1, 2, ...], ...])
+version_array([[1], [1], [1], ...])
+version_array([[1, 2, ...],
+ [1, 2, ...], [1, 2, ...], ...])
{}
{1}
{1, 2}
@@ -899,6 +955,8 @@
[1, 2, 3, 4, ...]
array([[1], [1], [1], ...])
array([[1, 2, ...], [1, 2, ...], [1, 2, ...], ...])
+version_array([[1], [1], [1], ...])
+version_array([[1, 2, ...], [1, 2, ...], [1, 2, ...], ...])
{}
{1}
{1, 2}
@@ -925,6 +983,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{1}
{1, 2}
@@ -979,6 +1039,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{1}
{1, 2}
@@ -1010,6 +1072,8 @@
[]
array([])
array([])
+version_array([])
+version_array([])
{}
{1}
{1, 2}
@@ -1032,6 +1096,8 @@
[1]
array([[1]])
array([[1]])
+version_array([[1]])
+version_array([[1]])
{}
{1}
{1, 2}
@@ -1087,6 +1153,8 @@
[1]
array([[1]])
array([[1]])
+version_array([[1]])
+version_array([[1]])
{}
{1}
{1, 2}
@@ -1118,6 +1186,8 @@
[1]
array([[1]])
array([[1]])
+version_array([[1]])
+version_array([[1]])
{}
{1}
{1, 2}
@@ -1143,6 +1213,12 @@
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])
+version_array([
+ [1], [1], [1]])
+version_array([
+ [1, 2, 3],
+ [1, 2, 3],
+ [1, 2, 3]])
{}
{1}
{1, 2}
@@ -1212,6 +1288,9 @@
[1, 2, 3]
array([[1], [1], [1]])
array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
+version_array([[1], [1], [1]])
+version_array([[1, 2, 3], [1, 2, 3],
+ [1, 2, 3]])
{}
{1}
{1, 2}
@@ -1248,6 +1327,8 @@
[1, 2, 3]
array([[1], [1], [1]])
array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
+version_array([[1], [1], [1]])
+version_array([[1, 2, 3], [1, 2, 3], [1, 2, 3]])
{}
{1}
{1, 2}
@@ -1277,6 +1358,15 @@
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5]])
+version_array([
+ [1], [1], [1],
+ [1], [1]])
+version_array([
+ [1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5]])
{}
{1}
{1, 2}
@@ -1423,6 +1513,10 @@
array([[1, 2, 3, 4, 5],
[1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
+version_array([[1], [1], [1], [1], [1]])
+version_array([[1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
{}
{1}
{1, 2}
@@ -1482,6 +1576,9 @@
array([[1], [1], [1], [1], [1]])
array([[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
[1, 2, 3, 4, 5]])
+version_array([[1], [1], [1], [1], [1]])
+version_array([[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5],
+ [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]])
{}
{1}
{1, 2}
Index: tests/hard_coded/pretty_printing.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/pretty_printing.m,v
retrieving revision 1.3
diff -u -r1.3 pretty_printing.m
--- tests/hard_coded/pretty_printing.m 5 Apr 2006 02:12:58 -0000 1.3
+++ tests/hard_coded/pretty_printing.m 20 May 2011 16:18:29 -0000
@@ -25,6 +25,7 @@
:- import_module pprint.
:- import_module int, list, map, array, string, rbtree, solutions.
+:- import_module version_array.
:- type tree(T) ---> branch(tree(T), T, tree(T)) ; leaf.
@@ -42,6 +43,12 @@
%------------------------------------------------------------------------------%
+:- func version_array_doc(int, int, int) = doc.
+
+version_array_doc(M, N, D) = to_doc(D, version_array(duplicate(M, 1 ..N))).
+
+%------------------------------------------------------------------------------%
+
:- func tuple_doc_0(int) = doc.
:- func tuple_doc_1(int) = doc.
:- func tuple_doc_2(int) = doc.
@@ -119,6 +126,8 @@
list_doc(S, D) `<>` line `<>`
array_doc(S, 1, D) `<>` line `<>`
array_doc(S, S, D) `<>` line `<>`
+ version_array_doc(S, 1, D) `<>` line `<>`
+ version_array_doc(S, S, D) `<>` line `<>`
tuple_doc_0(D) `<>` line `<>`
tuple_doc_1(D) `<>` line `<>`
tuple_doc_2(D) `<>` line `<>`
Index: tests/hard_coded/test_pretty_printer_defaults.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/test_pretty_printer_defaults.exp,v
retrieving revision 1.3
diff -u -r1.3 test_pretty_printer_defaults.exp
--- tests/hard_coded/test_pretty_printer_defaults.exp 2 Sep 2007 22:43:03 -0000 1.3
+++ tests/hard_coded/test_pretty_printer_defaults.exp 20 May 2011 16:22:45 -0000
@@ -1,4 +1,4 @@
-two("builtin", two("float", two(0, '<<function>>', empty, empty), two("character", two(0, '<<function>>', empty, empty), empty, empty), three("int", two(0, '<<function>>', empty, empty), "string", two(0, '<<function>>', empty, empty), empty, empty, empty)), two("array", two("array", two(1, '<<function>>', empty, empty), empty, empty), empty, empty), three("list", two("list", two(1, '<<function>>', empty, empty), empty, empty), "tree234", two("tree234", two(2, '<<function>>', empty, empty), empty, empty), empty, empty, empty))
+two("builtin", two("float", two(0, '<<function>>', empty, empty), two("character", two(0, '<<function>>', empty, empty), empty, empty), three("int", two(0, '<<function>>', empty, empty), "string", two(0, '<<function>>', empty, empty), empty, empty, empty)), two("array", two("array", two(1, '<<function>>', empty, empty), empty, empty), empty, empty), four("list", two("list", two(1, '<<function>>', empty, empty), empty, empty), "tree234", two("tree234", two(2, '<<function>>', empty, empty), empty, empty), "version_array", two("version_array", two(1, '<<function>>', empty, empty), empty, empty), empty, empty, empty, empty))
list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, ...]
@@ -19,3 +19,6 @@
ints: 42 -123
floats: 3.141 -10.0
chars: ['a', '*', '\n']
+version_array:version_array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+ 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, ...])
Index: tests/hard_coded/test_pretty_printer_defaults.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/test_pretty_printer_defaults.m,v
retrieving revision 1.2
diff -u -r1.2 test_pretty_printer_defaults.m
--- tests/hard_coded/test_pretty_printer_defaults.m 19 Oct 2007 05:17:18 -0000 1.2
+++ tests/hard_coded/test_pretty_printer_defaults.m 20 May 2011 09:31:39 -0000
@@ -29,12 +29,14 @@
:- import_module list.
:- import_module map.
:- import_module pretty_printer.
+:- import_module version_array.
%-----------------------------------------------------------------------------%
main(!IO) :-
L = 1..100,
A = array(L),
+ VA = version_array(L),
M = map.from_corresponding_lists(L, L) : map(int, int),
pretty_printer.get_default_formatter_map(FMap, !IO),
io.print(FMap, !IO),
@@ -48,7 +50,8 @@
str("strings: "), format("this is a string"), nl,
str("ints: "), format(42), str(" "), format(-123), nl,
str("floats: "), format(3.141), str(" "), format(-10.0), nl,
- str("chars: "), format([a, '*', '\n']), nl
+ str("chars: "), format([a, '*', '\n']), nl,
+ str("version_array:"), format(VA), nl
]),
!IO
).
Index: tests/hard_coded/write.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/write.exp,v
retrieving revision 1.12
diff -u -r1.12 write.exp
--- tests/hard_coded/write.exp 16 Jul 2010 07:19:12 -0000 1.12
+++ tests/hard_coded/write.exp 20 May 2011 16:31:54 -0000
@@ -45,4 +45,5 @@
empty
qwerty(4)
array([1, 2, 3, 4])
+version_array([1, 2, 3, 4])
Index: tests/hard_coded/write.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/write.m,v
retrieving revision 1.8
diff -u -r1.8 write.m
--- tests/hard_coded/write.m 29 Mar 2006 08:08:02 -0000 1.8
+++ tests/hard_coded/write.m 20 May 2011 16:30:08 -0000
@@ -11,6 +11,7 @@
:- implementation.
:- import_module list, int, term, map, array, univ.
+:- import_module version_array.
:- pred test_ops(io__state::di, io__state::uo) is det.
:- pred test_builtins(io__state::di, io__state::uo) is det.
@@ -154,6 +155,9 @@
{ array__from_list([1,2,3,4], Array) },
io__write(Array), newline,
+ { VersionArray = version_array.from_list([1,2,3,4]) },
+ io.write(VersionArray), newline,
+
newline.
newline -->
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list