[m-rev.] diff: Add regression test.

Peter Wang novalazy at gmail.com
Fri Jul 27 17:56:29 AEST 2018


Add regression test for a bug introduced in
commit f6e2290031d4318de693a5d377e602f02e09ed1e
and fixed in
commit 53e73a9e952a9e0c6e11020d5c92a429ae0fd01a

tests/hard_coded/Mmakefile:
tests/hard_coded/static_term_bug.m:
tests/hard_coded/static_term_bug.exp:
    Add new test.
---
 tests/hard_coded/Mmakefile           |  1 +
 tests/hard_coded/static_term_bug.exp |  1 +
 tests/hard_coded/static_term_bug.m   | 40 ++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)
 create mode 100644 tests/hard_coded/static_term_bug.exp
 create mode 100644 tests/hard_coded/static_term_bug.m

diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index 1abce77c5..f539a8ae9 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -311,20 +311,21 @@ ORDINARY_PROGS = \
 	setjmp_test \
 	shift_test \
 	simplify_multi_arm_switch \
 	singleton_dups \
 	solve_quadratic \
 	space \
 	spawn_native \
 	special_char \
 	stable_sort \
 	static_no_tag \
+	static_term_bug \
 	stdlib_init \
 	stream_format \
 	stream_ignore_ws \
 	stream_put_bug \
 	stream_putback \
 	stream_putback_binary \
 	stream_test \
 	string_alignment \
 	string_alignment_bug \
 	string_append_iii \
diff --git a/tests/hard_coded/static_term_bug.exp b/tests/hard_coded/static_term_bug.exp
new file mode 100644
index 000000000..f3a96f1d5
--- /dev/null
+++ b/tests/hard_coded/static_term_bug.exp
@@ -0,0 +1 @@
+data(data_info(top, 1234))
diff --git a/tests/hard_coded/static_term_bug.m b/tests/hard_coded/static_term_bug.m
new file mode 100644
index 000000000..9cc191e97
--- /dev/null
+++ b/tests/hard_coded/static_term_bug.m
@@ -0,0 +1,40 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+
+:- module static_term_bug.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- type data
+    --->    none
+    ;       data(data_info).
+
+:- type data_info
+    --->    data_info(side, int).
+
+:- type side
+    --->    top
+    ;       bottom.
+
+main(!IO) :-
+    ( if get_data("top", Data) then
+        io.write(Data, !IO),
+        io.nl(!IO)
+    else
+        io.write_string("failed\n", !IO)
+    ).
+
+:- pred get_data(string::in, data::out) is semidet.
+:- pragma no_inline(get_data/2).
+
+get_data(Side, Data) :-
+    Side = "top",
+    Data = data(data_info(top, 1234)).
-- 
2.18.0



More information about the reviews mailing list