[m-rev.] For review: fix a bug in pretty-printed output
Ralph Becket
rafe at csse.unimelb.edu.au
Sat May 9 13:31:49 AEST 2009
Estimated hours taken: 0.2
Branches: main
library/pretty_printer.m:
Fix a bug in the pretty printer for arbitrary terms where it would not
start a new line for a functor that could not fit on the remainder of
the line. This made it impossible to see structure from indentation in
some cases.
tests/hard_coded/test_pretty_printer.exp:
tests/hard_coded/test_pretty_printer.m:
Update the test case.
Index: library/pretty_printer.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/pretty_printer.m,v
retrieving revision 1.7
diff -u -r1.7 pretty_printer.m
--- library/pretty_printer.m 15 Oct 2007 04:27:22 -0000 1.7
+++ library/pretty_printer.m 8 May 2009 05:58:54 -0000
@@ -712,7 +712,8 @@
str("{"), indent([format_list(Args, str(", "))]), str("}")
])
else
- Doc0 = docs([
+ Doc0 = group([
+ nl,
str(term_io.quoted_atom(Name)),
str("("), indent([format_list(Args, str(", "))]), str(")")
])
Index: tests/hard_coded/test_pretty_printer.exp
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/test_pretty_printer.exp,v
retrieving revision 1.4
diff -u -r1.4 test_pretty_printer.exp
--- tests/hard_coded/test_pretty_printer.exp 15 Oct 2007 04:27:23 -0000 1.4
+++ tests/hard_coded/test_pretty_printer.exp 9 May 2009 03:19:39 -0000
@@ -32,6 +32,11 @@
limit = triangular(1), max lines = 3, line width = 38
|------------------------------------|
+succ(...)
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
-...
|------------------------------------|
@@ -88,6 +93,11 @@
limit = triangular(1), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+succ(...)
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
-...
|----------------------------------------------------------------------------|
@@ -147,6 +157,11 @@
limit = triangular(1), max lines = 10, line width = 38
|------------------------------------|
+succ(...)
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
-...
|------------------------------------|
@@ -206,6 +221,11 @@
limit = triangular(1), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+succ(...)
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
-...
|----------------------------------------------------------------------------|
@@ -262,6 +282,11 @@
limit = linear(1), max lines = 3, line width = 38
|------------------------------------|
+succ(...)
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
-...
|------------------------------------|
@@ -318,6 +343,11 @@
limit = linear(1), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+succ(...)
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
-...
|----------------------------------------------------------------------------|
@@ -377,6 +407,11 @@
limit = linear(1), max lines = 10, line width = 38
|------------------------------------|
+succ(...)
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
-...
|------------------------------------|
@@ -436,6 +471,11 @@
limit = linear(1), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+succ(...)
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
-...
|----------------------------------------------------------------------------|
@@ -495,6 +535,14 @@
limit = triangular(10), max lines = 3, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ ...
+|------------------------------------|
+
+limit = triangular(10), max lines = 3, line width = 38
+|------------------------------------|
-(-(-(-((... + ...) * ... /
(... * ...)) /
(... / ... * ... + -...)) /
@@ -562,6 +610,11 @@
limit = triangular(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
+|----------------------------------------------------------------------------|
+
+limit = triangular(10), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((... + ...) * ... / (... * ...)) / (... / ... * ... + -...)) /
((x / ... * (... / ...) + -(... / ...)) * ((x + ...) * (... + ...)))) /
((x / x * (x / ...) + -(x / ...)) * ((x + x) * (x + ...)) +
@@ -631,6 +684,20 @@
limit = triangular(10), max lines = 10, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(...))))))))))
+|------------------------------------|
+
+limit = triangular(10), max lines = 10, line width = 38
+|------------------------------------|
-(-(-(-((... + ...) * ... /
(... * ...)) /
(... / ... * ... + -...)) /
@@ -708,6 +775,11 @@
limit = triangular(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
+|----------------------------------------------------------------------------|
+
+limit = triangular(10), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((... + ...) * ... / (... * ...)) / (... / ... * ... + -...)) /
((x / ... * (... / ...) + -(... / ...)) * ((x + ...) * (... + ...)))) /
((x / x * (x / ...) + -(x / ...)) * ((x + x) * (x + ...)) +
@@ -775,6 +847,14 @@
limit = triangular(100), max lines = 3, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ ...
+|------------------------------------|
+
+limit = triangular(100), max lines = 3, line width = 38
+|------------------------------------|
-(-(-(-((x + x) * (x + x) /
(x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
@@ -851,6 +931,11 @@
limit = triangular(100), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
+|----------------------------------------------------------------------------|
+
+limit = triangular(100), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
((x / x * (x / x) + -(x / x)) * ((x + x) * (x + x)))) /
@@ -938,6 +1023,20 @@
limit = triangular(100), max lines = 10, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(zero))))))))))
+|------------------------------------|
+
+limit = triangular(100), max lines = 10, line width = 38
+|------------------------------------|
-(-(-(-((x + x) * (x + x) /
(x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
@@ -1051,6 +1150,11 @@
limit = triangular(100), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
+|----------------------------------------------------------------------------|
+
+limit = triangular(100), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
((x / x * (x / x) + -(x / x)) * ((x + x) * (x + x)))) /
@@ -1141,6 +1245,14 @@
limit = linear(10), max lines = 3, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ ...
+|------------------------------------|
+
+limit = linear(10), max lines = 3, line width = 38
+|------------------------------------|
-(-(-(-((... + ...) * ... / ...) /
...) /
...) /
@@ -1202,6 +1314,11 @@
limit = linear(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
+|----------------------------------------------------------------------------|
+
+limit = linear(10), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((... + ...) * ... / ...) / ...) / ...) / ...)
|----------------------------------------------------------------------------|
@@ -1261,6 +1378,20 @@
limit = linear(10), max lines = 10, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(...))))))))))
+|------------------------------------|
+
+limit = linear(10), max lines = 10, line width = 38
+|------------------------------------|
-(-(-(-((... + ...) * ... / ...) /
...) /
...) /
@@ -1325,6 +1456,11 @@
limit = linear(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(...))))))))))
+|----------------------------------------------------------------------------|
+
+limit = linear(10), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((... + ...) * ... / ...) / ...) / ...) / ...)
|----------------------------------------------------------------------------|
@@ -1387,6 +1523,14 @@
limit = linear(100), max lines = 3, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ ...
+|------------------------------------|
+
+limit = linear(100), max lines = 3, line width = 38
+|------------------------------------|
-(-(-(-((x + x) * (x + x) /
(x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
@@ -1463,6 +1607,11 @@
limit = linear(100), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
+|----------------------------------------------------------------------------|
+
+limit = linear(100), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
((x / x * (x / x) + -(x / x)) * ((x + x) * (x + x)))) /
@@ -1550,6 +1699,20 @@
limit = linear(100), max lines = 10, line width = 38
|------------------------------------|
+succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(
+ succ(zero))))))))))
+|------------------------------------|
+
+limit = linear(100), max lines = 10, line width = 38
+|------------------------------------|
-(-(-(-((x + x) * (x + x) /
(x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
@@ -1663,6 +1826,11 @@
limit = linear(100), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
+succ(succ(succ(succ(succ(succ(succ(succ(succ(succ(zero))))))))))
+|----------------------------------------------------------------------------|
+
+limit = linear(100), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
-(-(-(-((x + x) * (x + x) / (x / x * (x / x))) /
(x / x * (x / x) + -(x / x))) /
((x / x * (x / x) + -(x / x)) * ((x + x) * (x + x)))) /
Index: tests/hard_coded/test_pretty_printer.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/test_pretty_printer.m,v
retrieving revision 1.4
diff -u -r1.4 test_pretty_printer.m
--- tests/hard_coded/test_pretty_printer.m 19 Oct 2007 05:17:18 -0000 1.4
+++ tests/hard_coded/test_pretty_printer.m 9 May 2009 03:14:35 -0000
@@ -52,6 +52,10 @@
; op_tree * op_tree
; op_tree / op_tree.
+:- type church
+ ---> zero
+ ; succ(church).
+
:- type non_canonical_bool
---> non_canonical_bool(int)
where equality is non_canonical_bool_eq.
@@ -209,6 +213,7 @@
func(X, M) = M ^ elem(X) := float(X),
List, map.init : map(int, float)),
OpTree = mk_op_tree(200),
+ Church = list.foldl(func(_, X) = succ(X), 1..10, zero),
Tuple = {1, 2.0, "three", '4', {5}},
Square = list.duplicate(10, 1..10) : list(list(int)),
IndentTest = docs([
@@ -243,6 +248,7 @@
; Doc = format(MapFloat)
; Doc = format(MapStr)
; Doc = format(OpTree)
+ ; Doc = format(Church)
; Doc = fmt_susp_seq(100)
; Doc = format(Tuple)
; Doc = format(Square)
--------------------------------------------------------------------------
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