diff --git a/tests/hard_coded/Mmake b/tests/hard_coded/Mmake index b60f328a2..ba575562b 100644 --- a/tests/hard_coded/Mmake +++ b/tests/hard_coded/Mmake @@ -11,7 +11,8 @@ PROGS= qual_basic_test qual_basic_test2 qual_is_test qual_adv_test \ free_free_mode func_test string_alignment tim_qual1 c_write_string \ no_fully_strict float_rounding_bug string_loop func_and_pred \ cc_nondet_disj bidirectional address_of_builtins \ - reverse_arith curry curry2 higher_order_syntax + reverse_arith curry curry2 higher_order_syntax \ + ho_func_reg float_reg #-----------------------------------------------------------------------------# diff --git a/tests/hard_coded/float_reg.exp b/tests/hard_coded/float_reg.exp new file mode 100644 index 000000000..82e115bf7 --- /dev/null +++ b/tests/hard_coded/float_reg.exp @@ -0,0 +1 @@ +2.88000000000000e+32 diff --git a/tests/hard_coded/float_reg.m b/tests/hard_coded/float_reg.m new file mode 100644 index 000000000..5c09f2250 --- /dev/null +++ b/tests/hard_coded/float_reg.m @@ -0,0 +1,27 @@ +% Regression test: +% +% Test case for creation of float constants. +% +% The Mercury compiler of 21 December 1996 failed to compile this on +% SPARC platforms, because the + in the float name was not converted +% correctly. This leads to syntax errors in the generated C code, +% eg +% flo.c:22: syntax error before `+' +% flo.c:23: `mercury_float_const_2pt88e' undeclared (first use this function) +% +% Author: trd + +:- module float_reg. +:- interface. +:- import_module io. + +:- pred main(io__state::di, io__state::uo) is det. + +:- implementation. + +:- import_module io, float. + +main --> + io__write_float(2.88e32), + io__write_string("\n"). + diff --git a/tests/hard_coded/ho_func_reg.exp b/tests/hard_coded/ho_func_reg.exp new file mode 100644 index 000000000..87ede1f62 --- /dev/null +++ b/tests/hard_coded/ho_func_reg.exp @@ -0,0 +1,2 @@ +I seem to have compiled ok. +8 seems to be the answer diff --git a/tests/hard_coded/ho_func_reg.m b/tests/hard_coded/ho_func_reg.m new file mode 100644 index 000000000..3f5934d7a --- /dev/null +++ b/tests/hard_coded/ho_func_reg.m @@ -0,0 +1,41 @@ + +% Regression test: +% +% This program uses a higher order function. Due to the way higher order +% types are represented as terms (which is quite different from any +% other type) manipulations of types that don't take this into account +% would make mistakes. +% +% The Mercury compiler of 20 December, 1996 failed to compile this, +% giving link errors. + +:- module ho_func_reg. + +:- interface. + +:- import_module int, io. + +:- pred main(io__state::di, io__state::uo) is det. + +:- type bar == (func(int) = int). +:- inst bar = (func(in) = out is det). + +:- func foo(bar, int) = int is det. +:- mode foo(in(bar), in) = out is det. + +:- func next(int) = int is det. + +:- implementation. + +main --> + io__write_string("I seem to have compiled ok.\n"), + { Eight = foo(next, 7) }, + io__write_int(Eight), + io__write_string(" seems to be the answer\n"). + +next(I) = I + 1. + +foo(F, I) = apply(F, I). + + +