[m-rev.] for review 1/2: Add test cases for bug300
Paul Bone
paul at bone.id.au
Wed Oct 2 20:25:07 AEST 2013
Add test cases for bug300
tests/valid/bug300.m:
tests/valid/Mmakefile:
Add simple test case
tests/valid/Mercury.options:
Run the new test case with --optimize-constructor-last-call
tests/hard_coded/bug300.m:
tests/hard_coded/bug300.exp:
tests/hard_coded/Mmakefile:
This test case can detect the bug in C grades, where as the test case in
tests/valid/bug300.m only works in Java grades.
tests/hard_coded/Mercury.options:
Setup MCFLAGS so that the test case can detect the bug.
---
tests/hard_coded/Mercury.options | 1 +
tests/hard_coded/Mmakefile | 1 +
tests/hard_coded/bug300.exp | 3 +++
tests/hard_coded/bug300.m | 52 ++++++++++++++++++++++++++++++++++++++++
tests/valid/Mercury.options | 1 +
tests/valid/Mmakefile | 1 +
tests/valid/bug300.m | 34 ++++++++++++++++++++++++++
7 files changed, 93 insertions(+)
create mode 100644 tests/hard_coded/bug300.exp
create mode 100644 tests/hard_coded/bug300.m
create mode 100644 tests/valid/bug300.m
diff --git a/tests/hard_coded/Mercury.options b/tests/hard_coded/Mercury.options
index 2de5c6e..3c7d46a 100644
--- a/tests/hard_coded/Mercury.options
+++ b/tests/hard_coded/Mercury.options
@@ -11,6 +11,7 @@ MCFLAGS-boyer = --infer-all
MCFLAGS-bug103 = --optimize-constructor-last-call
MCFLAGS-bug160 = -w --optimize-peep-mkword
MCFLAGS-bug240 = -O1
+MCFLAGS-bug300 = --no-const-struct --optimize-constructor-last-call
MCFLAGS-checked_nondet_tailcall = --checked-nondet-tailcalls
MCFLAGS-checked_nondet_tailcall_noinline = --checked-nondet-tailcalls --no-inlining
MCFLAGS-cc_and_non_cc_test = --no-inlining
diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index 23e922b..5dcfbb7 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -21,6 +21,7 @@ ORDINARY_PROGS= \
bug103 \
bug160 \
bug240 \
+ bug300 \
builtin_inst_rename \
c_write_string \
calendar_test \
diff --git a/tests/hard_coded/bug300.exp b/tests/hard_coded/bug300.exp
new file mode 100644
index 0000000..ab7b42d
--- /dev/null
+++ b/tests/hard_coded/bug300.exp
@@ -0,0 +1,3 @@
+[] -> functor(["list", "[]"], [])
+[functor(["single"], [])] -> functor(["list", "[|]"], [functor(["single"], []), functor(["list", "[]"], [])])
+[functor(["1"], []), functor(["2"], []), functor(["3"], [])] -> functor(["list", "[|]"], [functor(["1"], []), functor(["list", "[|]"], [functor(["2"], []), functor(["list", "[|]"], [functor(["3"], []), functor(["list", "[]"], [])])])])
diff --git a/tests/hard_coded/bug300.m b/tests/hard_coded/bug300.m
new file mode 100644
index 0000000..cf53ad7
--- /dev/null
+++ b/tests/hard_coded/bug300.m
@@ -0,0 +1,52 @@
+% vim: ts=4 sw=4 et ft=mercury
+% This test case ensures that lco.m handles from ground term scopes properly
+% such as the one that is created for the construction of the terms in the
+% base case of list_data_term.
+
+:- module bug300.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+:- implementation.
+
+:- import_module int.
+:- import_module list.
+:- import_module string.
+
+main(!IO) :-
+ foldl(test,
+ [ [],
+ [functor(["single"], [])],
+ [functor(["1"], []),
+ functor(["2"], []),
+ functor(["3"], [])] ],
+ !IO).
+
+:- pred test(list(data_term)::in, io::di, io::uo) is det.
+
+test(ListTerm, !IO) :-
+ Term = list_data_term(ListTerm),
+ io.format("%s -> %s\n", [s(string(ListTerm)), s(string(Term))], !IO).
+
+:- type data_term == mer_term(literal).
+
+:- type mer_term(T)
+ ---> functor(qualified_name, list(mer_term(T))).
+
+:- type qualified_name == list(unqualified_name).
+
+:- type unqualified_name == string.
+
+:- type literal
+ ---> string(string)
+ ; int(int).
+
+:- func list_data_term(list(data_term)) = data_term.
+
+list_data_term([]) = functor(["list", "[]"], []).
+list_data_term([H | T]) = functor(["list", "[|]"], [H, list_data_term(T)]).
+
diff --git a/tests/valid/Mercury.options b/tests/valid/Mercury.options
index daa185b..87627be 100644
--- a/tests/valid/Mercury.options
+++ b/tests/valid/Mercury.options
@@ -49,6 +49,7 @@ MCFLAGS-bug142 = --optimise-higher-order --inline-single-use
MCFLAGS-bug159 = -w
MCFLAGS-bug180 = --profile-optimized --allow-stubs --no-warn-stubs
MCFLAGS-bug271 = --allow-stubs --no-warn-stubs
+MCFLAGS-bug300 = --optimize-constructor-last-call
MCFLAGS-compl_unify_bug = -O3
MCFLAGS-constraint_prop_bug = -O0 --common-struct --local-constraint-propagation
MCFLAGS-csharp_hello = --no-intermodule-optimization
diff --git a/tests/valid/Mmakefile b/tests/valid/Mmakefile
index 20bf60b..6793540 100644
--- a/tests/valid/Mmakefile
+++ b/tests/valid/Mmakefile
@@ -78,6 +78,7 @@ OTHER_PROGS= \
bug183 \
bug190 \
bug257b \
+ bug300 \
builtin_false \
call_failure \
common_struct_bug \
diff --git a/tests/valid/bug300.m b/tests/valid/bug300.m
new file mode 100644
index 0000000..0e5a149
--- /dev/null
+++ b/tests/valid/bug300.m
@@ -0,0 +1,34 @@
+% vim: ts=4 sw=4 et ft=mercury
+% This test case ensures that lco.m handles from ground term scopes properly
+% such as the one that is created for the construction of the terms in the
+% base case of list_data_term.
+
+:- module bug300.
+
+:- interface.
+
+:- import_module list.
+
+:- func list_data_term(list(data_term)) = data_term.
+
+:- implementation.
+
+:- import_module string.
+:- import_module int.
+
+:- type data_term == mer_term(literal).
+
+:- type mer_term(T)
+ ---> functor(qualified_name, list(mer_term(T))).
+
+:- type qualified_name == list(unqualified_name).
+
+:- type unqualified_name == string.
+
+:- type literal
+ ---> string(string)
+ ; int(int).
+
+list_data_term([]) = functor(["list", "[]"], []).
+list_data_term([H | T]) = functor(["list", "[|]"], [H, list_data_term(T)]).
+
--
1.8.4.rc3
More information about the reviews
mailing list