mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Regression tests for 2 bugs.
Estimated hours taken: 3 Regression tests for 2 bugs. Mmake: Add these two tests. ho_func_reg.m: ho_func_reg.exp: Check for correct creation of references to higher order function types with arity other than two. float_reg.m: float_reg.exp: Check for correct creation of floating point constants with a + in their exponent.
This commit is contained in:
@@ -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
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
|
||||
1
tests/hard_coded/float_reg.exp
Normal file
1
tests/hard_coded/float_reg.exp
Normal file
@@ -0,0 +1 @@
|
||||
2.88000000000000e+32
|
||||
27
tests/hard_coded/float_reg.m
Normal file
27
tests/hard_coded/float_reg.m
Normal file
@@ -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").
|
||||
|
||||
2
tests/hard_coded/ho_func_reg.exp
Normal file
2
tests/hard_coded/ho_func_reg.exp
Normal file
@@ -0,0 +1,2 @@
|
||||
I seem to have compiled ok.
|
||||
8 seems to be the answer
|
||||
41
tests/hard_coded/ho_func_reg.m
Normal file
41
tests/hard_coded/ho_func_reg.m
Normal file
@@ -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).
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user