[m-rev.] Fix a pretty_printer bug
Ralph Becket
rafe at csse.unimelb.edu.au
Fri Aug 24 11:22:22 AEST 2007
Estimated hours taken: 1
Branches: main
library/pretty_printer.m:
The depth limit was being prematurely decremented when formatting
terms, causing one too few functors to be displayed before
truncation. This bug caused everything to be printed as "..."
at depth 1, rather than just showing the top-level functor.
tests/debugger/browse_pretty.exp:
tests/debugger/browser_test.exp3:
tests/debugger/declarative/sort.exp:
tests/hard_coded/test_pretty_printer.exp:
tests/hard_coded/test_pretty_printer_defaults.exp:
Update expected output files.
tests/hard_coded/test_pretty_printer.m:
Test the depth=1 case.
Index: library/pretty_printer.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/pretty_printer.m,v
retrieving revision 1.4
diff -u -r1.4 pretty_printer.m
--- library/pretty_printer.m 22 Aug 2007 22:36:17 -0000 1.4
+++ library/pretty_printer.m 23 Aug 2007 05:18:52 -0000
@@ -684,7 +684,6 @@
formatting_limit::in, formatting_limit::out, ops.priority::in) is det.
expand_format_term(Name, Args, Doc, !Limit, CurrentPri) :-
- decrement_limit(!Limit),
( if Args = [] then
Doc0 = str(term_io.quoted_atom(Name))
else if limit_overrun(!.Limit) then
@@ -701,6 +700,7 @@
str("("), indent([format_list(Args, str(", "))]), str(")")
])
),
+ decrement_limit(!Limit),
Doc = set_formatting_limit_correctly(!.Limit, Doc0).
%-----------------------------------------------------------------------------%
Index: tests/debugger/browse_pretty.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browse_pretty.exp,v
retrieving revision 1.15
diff -u -r1.15 browse_pretty.exp
--- tests/debugger/browse_pretty.exp 22 Aug 2007 22:36:18 -0000 1.15
+++ tests/debugger/browse_pretty.exp 24 Aug 2007 00:57:02 -0000
@@ -60,7 +60,7 @@
browser> width 79
browser> depth 3
browser> ls
-big(big(..., ...), [..., ...], ...)
+big(big(big(...), ...), [..., ...], ...)
browser> format raw_pretty
browser> lines 4
browser> width 40
Index: tests/debugger/browser_test.exp3
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.exp3,v
retrieving revision 1.1
diff -u -r1.1 browser_test.exp3
--- tests/debugger/browser_test.exp3 22 Aug 2007 22:36:18 -0000 1.1
+++ tests/debugger/browser_test.exp3 24 Aug 2007 00:59:43 -0000
@@ -35,7 +35,7 @@
Data (arg 1) big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
mdb> print -p 1
Data (arg 1)
-big(big(..., ...), 3, ...)
+big(big(big(...), ...), 3, ...)
mdb> print -v 1
Data (arg 1)
big
@@ -251,7 +251,7 @@
mdb> finish
E7: C4 EXIT func browser_test.a_func/1-0 (det) browser_test.m:112 (browser_test.m:31)
mdb> print -p
-a_func(big(..., ...)) = big(..., ...)
+a_func(big(big(...), ...)) = big(big(...), ...)
mdb> print -r
a_func(
big(
Index: tests/debugger/declarative/sort.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/sort.exp,v
retrieving revision 1.4
diff -u -r1.4 sort.exp
--- tests/debugger/declarative/sort.exp 22 Feb 2007 05:22:18 -0000 1.4
+++ tests/debugger/declarative/sort.exp 24 Aug 2007 00:55:29 -0000
@@ -35,7 +35,7 @@
write_string(...)
Valid? depth io 10
dd> print io 9
-read_line_as_string_2(<<foreign>>, yes, 0, "rafe
+read_line_as_string_2('<<foreign>>', yes, 0, "rafe
")
dd> depth io 1
dd> no
Index: tests/hard_coded/test_pretty_printer.exp
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/test_pretty_printer.exp,v
retrieving revision 1.2
diff -u -r1.2 test_pretty_printer.exp
--- tests/hard_coded/test_pretty_printer.exp 14 Aug 2007 05:23:20 -0000 1.2
+++ tests/hard_coded/test_pretty_printer.exp 24 Aug 2007 01:14:36 -0000
@@ -1,4 +1,396 @@
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_...
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+{...}
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+100....
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+-...
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+1, ...
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_...
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+{...}
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+100....
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+-...
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+1, ...
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_three
+_1__2__3__4_four
+_1__2__3__4__5_five
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+{...}
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+100....
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+-...
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+1, ...
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_three
+_1__2__3__4_four
+_1__2__3__4__5_five
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+{...}
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+100....
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+-...
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+1, ...
+|----------------------------------------------------------------------------|
+
+limit = triangular(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_...
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+{...}
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+100....
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+-...
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+1, ...
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_...
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+{...}
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+100....
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+-...
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+1, ...
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 3, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_three
+_1__2__3__4_four
+_1__2__3__4__5_five
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+{...}
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+100....
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+-...
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+map([...])
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+1, ...
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 38
+|------------------------------------|
+[...]
+|------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+indentation test:
+_1_one
+_1__2_two
+_1__2__3_three
+_1__2__3__4_four
+_1__2__3__4__5_five
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+{...}
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+100....
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+-...
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+map([...])
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+1, ...
+|----------------------------------------------------------------------------|
+
+limit = linear(1), max lines = 10, line width = 78
+|----------------------------------------------------------------------------|
+[...]
+|----------------------------------------------------------------------------|
+
limit = triangular(10), max lines = 3, line width = 38
|------------------------------------|
indentation test:
@@ -27,10 +419,10 @@
limit = triangular(10), max lines = 3, line width = 38
|------------------------------------|
--(-(-(-(... * ... / ...) /
- (... * ... + ...)) /
- ((x / ... * ... + -...) *
- ...
+-(-(-(-((... + ...) * ... /
+ (... * ...)) /
+ (... / ... * ... + -...)) /
+ ...
|------------------------------------|
limit = triangular(10), max lines = 3, line width = 38
@@ -86,8 +478,8 @@
limit = triangular(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
--(-(-(-(... * ... / ...) / (... * ... + ...)) /
- ((x / ... * ... + -...) * ((x + ...) * ...))) /
+-(-(-(-((... + ...) * ... / (... * ...)) / (... / ... * ... + -...)) /
+ ((x / ... * (... / ...) + -(... / ...)) * ((x + ...) * (... + ...)))) /
((x / x * (x / ...) + -(x / ...)) * ((x + x) * (x + ...)) +
...
|----------------------------------------------------------------------------|
@@ -95,13 +487,13 @@
limit = triangular(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
map([(1 -> "0x1"), (2 -> "0x2"), (3 -> "0x3"), (4 -> "0x4"), (5 -> "0x5"),
- (6 -> "0x6"), (7 -> "0x7"), (8 -> ...), ..., ...])
+ (6 -> "0x6"), (7 -> "0x7"), (8 -> ...), (... -> ...), ...])
|----------------------------------------------------------------------------|
limit = triangular(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
map([(1 -> 1.0), (2 -> 2.0), (3 -> 3.0), (4 -> 4.0), (5 -> 5.0), (6 -> 6.0),
- (7 -> 7.0), (8 -> ...), ..., ...])
+ (7 -> 7.0), (8 -> ...), (... -> ...), ...])
|----------------------------------------------------------------------------|
limit = triangular(10), max lines = 3, line width = 78
@@ -146,14 +538,16 @@
limit = triangular(10), max lines = 10, line width = 38
|------------------------------------|
--(-(-(-(... * ... / ...) /
- (... * ... + ...)) /
- ((x / ... * ... + -...) *
- ((x + ...) * ...))) /
+-(-(-(-((... + ...) * ... /
+ (... * ...)) /
+ (... / ... * ... + -...)) /
+ ((x / ... * (... / ...) +
+ -(... / ...)) *
+ ((x + ...) * (... + ...)))) /
((x / x * (x / ...) + -(x / ...)) *
((x + x) * (x + ...)) +
- (x / ... - x - -... -
- x / ... * ...)))
+ (x / ... - x - -(... / ...) -
+ x / ... * (... / ...))))
|------------------------------------|
limit = triangular(10), max lines = 10, line width = 38
@@ -161,7 +555,8 @@
map([(1 -> "0x1"), (2 -> "0x2"),
(3 -> "0x3"), (4 -> "0x4"),
(5 -> "0x5"), (6 -> "0x6"),
- (7 -> "0x7"), (8 -> ...), ..., ...])
+ (7 -> "0x7"), (8 -> ...),
+ (... -> ...), ...])
|------------------------------------|
limit = triangular(10), max lines = 10, line width = 38
@@ -169,7 +564,7 @@
map([(1 -> 1.0), (2 -> 2.0),
(3 -> 3.0), (4 -> 4.0), (5 -> 5.0),
(6 -> 6.0), (7 -> 7.0), (8 -> ...),
- ..., ...])
+ (... -> ...), ...])
|------------------------------------|
limit = triangular(10), max lines = 10, line width = 38
@@ -211,22 +606,22 @@
limit = triangular(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
--(-(-(-(... * ... / ...) / (... * ... + ...)) /
- ((x / ... * ... + -...) * ((x + ...) * ...))) /
+-(-(-(-((... + ...) * ... / (... * ...)) / (... / ... * ... + -...)) /
+ ((x / ... * (... / ...) + -(... / ...)) * ((x + ...) * (... + ...)))) /
((x / x * (x / ...) + -(x / ...)) * ((x + x) * (x + ...)) +
- (x / ... - x - -... - x / ... * ...)))
+ (x / ... - x - -(... / ...) - x / ... * (... / ...))))
|----------------------------------------------------------------------------|
limit = triangular(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
map([(1 -> "0x1"), (2 -> "0x2"), (3 -> "0x3"), (4 -> "0x4"), (5 -> "0x5"),
- (6 -> "0x6"), (7 -> "0x7"), (8 -> ...), ..., ...])
+ (6 -> "0x6"), (7 -> "0x7"), (8 -> ...), (... -> ...), ...])
|----------------------------------------------------------------------------|
limit = triangular(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
map([(1 -> 1.0), (2 -> 2.0), (3 -> 3.0), (4 -> 4.0), (5 -> 5.0), (6 -> 6.0),
- (7 -> 7.0), (8 -> ...), ..., ...])
+ (7 -> 7.0), (8 -> ...), (... -> ...), ...])
|----------------------------------------------------------------------------|
limit = triangular(10), max lines = 10, line width = 78
@@ -602,9 +997,10 @@
limit = linear(10), max lines = 3, line width = 38
|------------------------------------|
--(-(-(-(... * ... / ...) / ...) /
+-(-(-(-((... + ...) * ... / ...) /
...) /
- ...)
+ ...) /
+ ...
|------------------------------------|
limit = linear(10), max lines = 3, line width = 38
@@ -654,7 +1050,7 @@
limit = linear(10), max lines = 3, line width = 78
|----------------------------------------------------------------------------|
--(-(-(-(... * ... / ...) / ...) / ...) / ...)
+-(-(-(-((... + ...) * ... / ...) / ...) / ...) / ...)
|----------------------------------------------------------------------------|
limit = linear(10), max lines = 3, line width = 78
@@ -704,7 +1100,8 @@
limit = linear(10), max lines = 10, line width = 38
|------------------------------------|
--(-(-(-(... * ... / ...) / ...) /
+-(-(-(-((... + ...) * ... / ...) /
+ ...) /
...) /
...)
|------------------------------------|
@@ -758,7 +1155,7 @@
limit = linear(10), max lines = 10, line width = 78
|----------------------------------------------------------------------------|
--(-(-(-(... * ... / ...) / ...) / ...) / ...)
+-(-(-(-((... + ...) * ... / ...) / ...) / ...) / ...)
|----------------------------------------------------------------------------|
limit = linear(10), max lines = 10, line width = 78
Index: tests/hard_coded/test_pretty_printer.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/test_pretty_printer.m,v
retrieving revision 1.1
diff -u -r1.1 test_pretty_printer.m
--- tests/hard_coded/test_pretty_printer.m 3 Aug 2007 05:18:39 -0000 1.1
+++ tests/hard_coded/test_pretty_printer.m 24 Aug 2007 01:13:48 -0000
@@ -219,6 +219,8 @@
; Limit = linear(10)
; Limit = triangular(100)
; Limit = triangular(10)
+ ; Limit = linear(1)
+ ; Limit = triangular(1)
),
( MaxLines = 10
; MaxLines = 3
--------------------------------------------------------------------------
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